java-在minifyEnabled设置为true的情况下生成带符号的APK后,firebase UI输出空白

java-在minifyEnabled设置为true的情况下生成带符号的APK后,firebase UI输出空白,第1张

概述我几乎已经完成了我的应用程序的制作,并且我一直试图解决最后一个问题.我进行了一项活动,以显示使用FirestoreRecyclerAdapter从Firestore获取的数据,并且在模拟器上运行时,它可以完美运行.但是,当我使用minifyEnabled:true生成签名的APK并将其安装在设备上之后,RecyclerView只会显

我几乎已经完成了我的应用程序的制作,并且我一直试图解决最后一个问题.我进行了一项活动,以显示使用FirestoreRecyclerAdapter从Firestore获取的数据,并且在模拟器上运行时,它可以完美运行.但是,当我使用MinifyEnabled:true生成签名的APK并将其安装在设备上之后,RecyclerVIEw只会显示空白.当我将MinifyEnabled:false设置为完美时.以下是我的代码

对于TransactionRecycler类

public class TransactionRecycler {    private String payment_date;    private String status;    private String meternumber;    public String reference;    private String amount_formatted;    private Double PurchasedUnits;    private Double FreeUnits;    private Double Vat;    public String ID;    private String payment_time;  //  public String state;    private String token;    public String address;    private String account_@R_419_6889@;    public TransactionRecycler(String payment_date, String status, String meternumber, String reference, String ID, String amount_formatted, String payment_time, String token, Double PurchasedUnits,                               Double FreeUnits, Double Vat, String account_@R_419_6889@, String address){        this.payment_date = payment_date;        this.status = status;        this.meternumber = meternumber;        this.reference = reference;        this.amount_formatted = amount_formatted;        this.PurchasedUnits = PurchasedUnits;        this.Vat = Vat;     //   this.state = state;        this.FreeUnits = FreeUnits;        this.ID = ID;        this.payment_time = payment_time;        this.token = token;        this.account_@R_419_6889@ = account_@R_419_6889@;        this.address = address;    }    public TransactionRecycler(){};    public voID setDate(String payment_date){this.payment_date = payment_date;}    public voID setID(String ID){this.ID =ID;}   // public voID setState(String ID){this.state =state;}    public String getPayment_date(){return payment_date;}    public String getStatus(){return status;}    public String getMeternumber(){return meternumber;}    public String getReference(){return reference;}    public String getAddress(){return address;}    public String getAmount_formatted(){return amount_formatted;}    public Double getPurchasedUnits(){return PurchasedUnits;}    public Double getFreeUnits(){return FreeUnits;}    public Double getVat(){return Vat;}    public String getID(){return ID;}   // public String getstate(){return state;}   public String getPayment_time(){return payment_time;}    public String getToken(){return token;}    public String getAccount_@R_419_6889@(){return account_@R_419_6889@;}}

对于TRANSactionActivity

public class TransactionActivity extends AppCompatActivity {    private static final String TAG = "TransactionActivity";    private final static String strUrlID= "https://www.eliminateramp.com?exmen=";    private static final int SERVICE_CHARGE = 100;    private static final String PLEASE_CHECK_YOUR_METER_NUMBER_AND_TRY_AGAIN = "Please check your meter number and try again";    private static final String CouldN_T_CONNECT_AT_THIS_TIME_PLEASE_TRY_AGAIN = "Couldn't connect at this time, Please try again";    private static final String FAILLED = "failled";    private static final String NOT_FOUND = "NOT FOUND";    private FirebaseAuth mAuth;    private String userID;    private RecyclerVIEw mTransactionList;    protected linearlayoutmanager linearlayoutmanager;    public FirestoreRecyclerAdapter adapter;    private SlIDingUpPanelLayout mLayout;    private NavigationVIEw navigation;    private DrawerLayout mDrawerLayout;    private ActionbarDrawerToggle mToggle;    private static final String SPACE = " ";    private static String phone;    private button char@R_419_6889@;    private TextVIEw emailvIEw;    private TextVIEw full@R_419_6889@vIEw;    private TextVIEw priceIDrc;    private static TextVIEw post_meterno;    private static String aamount;    public boolean onCreateOptionsMenu(Menu menu){        getMenuInflater().inflate(R.menu.top_menu, menu);        return super.onCreateOptionsMenu(menu);    }    @OverrIDe    protected voID onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentVIEw(R.layout.activity_transaction);        mTransactionList = findVIEwByID(R.ID.frIEnd_Listinc);        mLayout = findVIEwByID(R.ID.slIDing_layout);        mAuth = FirebaseAuth.getInstance();        userID = mAuth.getCurrentUser().getUID();        Log.d("Error","The UID is: "+userID);        Toolbar mToolbar = findVIEwByID(R.ID.nav_actionbar);        setSupportActionbar(mToolbar);        mDrawerLayout = findVIEwByID(R.ID.drawerlayout);        navigation = findVIEwByID(R.ID.navigationvIEw);        mToggle = new ActionbarDrawerToggle(this, mDrawerLayout, R.string.open, R.string.close);        VIEw headerVIEw = navigation.getheaderVIEw(0);        emailvIEw = headerVIEw.findVIEwByID(R.ID.emailvIEwraw);        full@R_419_6889@vIEw = headerVIEw.findVIEwByID(R.ID.full@R_419_6889@vIEwID);        char@R_419_6889@ = headerVIEw.findVIEwByID(R.ID.char@R_419_6889@ID);        mDrawerLayout.addDrawerListener(mToggle);        mToggle.syncState();        getSupportActionbar().setdisplayHomeAsUpEnabled(true);        try{            getUserData();        }catch (Exception e){            Log.d(TAG, "Failed to get user Data at this time coz: "+e);        }        ImageVIEw imgvIEw = findVIEwByID(R.ID.closeID);        imgvIEw.setonClickListener(new VIEw.OnClickListener() {            @OverrIDe            public voID onClick(VIEw v) {                mLayout.animate();                mLayout.setPanelState(SlIDingUpPanelLayout.PanelState.ColLAPSED);            }        });        char@[email protected](new VIEw.OnClickListener() {            @OverrIDe            public voID onClick(VIEw v) {                startActivity(new Intent(TransactionActivity.this,UpdateActivity.class));            }        });        init();        inTrans();        initInstances();    }    @OverrIDe    public boolean onoptionsItemSelected(MenuItem item) {        return mToggle.onoptionsItemSelected(item) || super.onoptionsItemSelected(item);    }    private voID initInstances() {        //  getSupportActionbar().setHomebuttonEnabled(true);        //   getSupportActionbar().setdisplayHomeAsUpEnabled(true);        navigation = findVIEwByID(R.ID.navigationvIEw);        navigation.setNavigationItemSelectedListener(new NavigationVIEw.OnNavigationItemSelectedListener() {            @OverrIDe            public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {                int ID = menuItem.getItemID();                switch (ID) {                    case R.ID.nav_home:                        //Do some thing here                        // add navigation drawer item onclick method here                        Intent intent2 = new Intent(TransactionActivity.this, HomePageActivity.class);                        startActivity(intent2);                        break;                    case R.ID.nav_estimate:                        mDrawerLayout.closeDrawer(GravityCompat.START);                        break;                    //Do some thing here                    // add navigation drawer item onclick method here                    case R.ID.nav_Settings:                        //Do some thing here                        // add navigation drawer item onclick method here                        Intent intent3 = new Intent(TransactionActivity.this, HelpActivity.class);                        startActivity(intent3);                        break;                    case R.ID.nav_hc:                        //Do some thing here                        // add navigation drawer item onclick method here                        Intent intent = new Intent(TransactionActivity.this, HelpCenteractivity.class);                        startActivity(intent);                        break;                }                return false;            }        });    }    private voID init(){        linearlayoutmanager = new linearlayoutmanager(getApplicationContext(), linearlayoutmanager.VERTICAL, false);        mTransactionList.setLayoutManager(linearlayoutmanager);    }    private voID inTrans(){        @R_301_5962@ @R_301_5962@ = FirebaseFirestore.getInstance().collection("user-orders").document(userID).collection("successful-orders").orderBy("RequestedOn");        FirestoreRecyclerOptions<TransactionRecycler> response = new FirestoreRecyclerOptions.Builder<TransactionRecycler>()                .set@R_301_5962@(@R_301_5962@, TransactionRecycler.class)                .build();        adapter = new FirestoreRecyclerAdapter<TransactionRecycler, TransactionRecyclerHolder>(response){            @OverrIDe            public TransactionRecyclerHolder onCreateVIEwHolder(VIEwGroup parent, int vIEwType) {                VIEw vIEw = LayoutInflater.from(parent.getContext()).inflate(R.layout.transaction_List, parent, false);                return new TransactionRecyclerHolder(vIEw);            }            @OverrIDe            public voID one rror(@NonNull FirebaseFirestoreException e) {                Log.e("error", e.getMessage());            }            @OverrIDe            protected voID onBindVIEwHolder(@NonNull TransactionRecyclerHolder holder, int position, @NonNull final TransactionRecycler model) {                //progressbar.setVisibility(VIEw.GONE);                holder.setDate(model.getPayment_date());                holder.setStatus(model.getStatus());                holder.setReference(model.getID());                holder.setMeterno(model.getMeternumber());                holder.setPrice(model.getAmount_formatted());                mLayout.setFadeOnClickListener(new VIEw.OnClickListener() {                    @OverrIDe                    public voID onClick(VIEw v) {                        mLayout.animate();                        mLayout.setPanelState(SlIDingUpPanelLayout.PanelState.ColLAPSED);                    }                });                holder.itemVIEw.setonClickListener(new VIEw.OnClickListener() {                    @OverrIDe                    public voID onClick(VIEw v) {                        mLayout.setPanelHeight(4);                        mLayout.animate();                       // mLayout.setAnchorPoint(2.0f);                        mLayout.setPanelState(SlIDingUpPanelLayout.PanelState.EXPANDED);                        priceIDrc = findVIEwByID(R.ID.priceIDsc);                        TextVIEw dateIDrc = findVIEwByID(R.ID.dateIDsc);                        TextVIEw referenceIDrc = findVIEwByID(R.ID.refIDsc);                        TextVIEw statusIDrc = findVIEwByID(R.ID.statusIDsc);                        TextVIEw meternoIDrc = findVIEwByID(R.ID.meternoIDsc);                        TextVIEw paymenttimeIDrc = findVIEwByID(R.ID.paymenttimeIDsc);                        TextVIEw tokenIDrc = findVIEwByID(R.ID.tokenIDsc);                        TextVIEw creditIDrc = findVIEwByID(R.ID.creditIDsc);                        TextVIEw freeunitsrc = findVIEwByID(R.ID.freeunitsIDsc);                        TextVIEw vatrc = findVIEwByID(R.ID.vatIDsc);                        TextVIEw account@R_419_6889@IDrc = findVIEwByID(R.ID.@R_419_6889@sIDsc);                        TextVIEw address = findVIEwByID(R.ID.addressIDsc);                        dateIDrc.setText(model.getPayment_date());                        statusIDrc.setText(model.getStatus());                        meternoIDrc.setText(model.getMeternumber());                        priceIDrc.setText(model.getAmount_formatted());                        referenceIDrc.setText(model.getID());                        paymenttimeIDrc.setText(model.getPayment_time());                        tokenIDrc.setText(model.getToken());                        creditIDrc.setText(String.valueOf(model.getPurchasedUnits()));                        freeunitsrc.setText(String.valueOf(model.getFreeUnits()));                        vatrc.setText(String.valueOf(model.getVat()));                        account@[email protected](model.getAccount_@R_419_6889@());                        address.setText(model.getAddress());                    }                });            }        };        adapter.notifyDataSetChanged();        mTransactionList.setAdapter(adapter);    }    @OverrIDe    public voID onStart() {        super.onStart();        adapter.startListening();    }    @OverrIDe    public voID onStop() {        super.onStop();        adapter.stopListening();    }    public static class TransactionRecyclerHolder extends RecyclerVIEw.VIEwHolder {        VIEw mVIEw;        TransactionRecyclerHolder(VIEw itemVIEw) {            super(itemVIEw);            mVIEw = itemVIEw;        }        public voID setDate(String payment_date) {            TextVIEw post_date = mVIEw.findVIEwByID(R.ID.dateID);            post_date.setText(payment_date);        }        public voID setStatus(String status) {            TextVIEw post_status = mVIEw.findVIEwByID(R.ID.statusID);            post_status.setText(status);        }        public voID setMeterno(String meterno) {            post_meterno = mVIEw.findVIEwByID(R.ID.meternoID);            post_meterno.setText(meterno);        }        public voID setReference(String reference) {            TextVIEw post_ref = mVIEw.findVIEwByID(R.ID.refID);            post_ref.setText(reference);        }        public voID setPrice(String price) {            TextVIEw post_price = mVIEw.findVIEwByID(R.ID.priceID);            post_price.setText(price);            aamount=price;        }    }    public voID getUserData() {        mAuth= FirebaseAuth.getInstance();        try{            userID = mAuth.getCurrentUser().getUID();        }catch(Exception e){            Log.d(TAG, "Failled somehow");        }        Log.d(TAG, "ur uID => "+userID);        documentReference mDocRef = FirebaseFirestore.getInstance().collection("users").document(userID);        mDocRef.get().addOnCompleteListener(new OnCompleteListener<documentSnapshot>() {            @OverrIDe            public voID onComplete(@NonNull Task<documentSnapshot> task) {                if(task.isSuccessful()){                    documentSnapshot doc = task.getResult();                    String first@R_419_6889@ = doc.get("first@R_419_6889@").toString();                    String last@R_419_6889@ = doc.get("last@R_419_6889@").toString();                    phone = doc.get("phone").toString();                    String full@R_419_6889@ = first@R_419_6889@+SPACE+last@R_419_6889@;                    full@[email protected](full@R_419_6889@);                    try{                        emailvIEw.setText(mAuth.getCurrentUser().getEmail());                    }catch(Exception e){                        Log.d(TAG,"oops");                    }                    char@[email protected](first@[email protected](0,1));                }            }        });    }    public voID buyAgain(VIEw vIEw){        final Dialog dialog = new Dialog(TransactionActivity.this);        dialog.getwindow().setBackgroundDrawable(new colorDrawable(color.transparent));        dialog.setCanceledOntouchOutsIDe(false);        dialog.setContentVIEw(R.layout.progressbar);        String price = aamount.replaceAll("\D","");       final int amount = Integer.parseInt(price) + SERVICE_CHARGE;       final String mn = post_meterno.getText().toString();       final String ml = "amstadam";        final String ref = String.valueOf(Calendar.getInstance().getTimeInMillis());        @Suppresslint("StaticFIEldLeak") AsyncTask<String, String, String> jesget@R_419_6889@s = new AsyncTask<String, String, String>() {            @OverrIDe            protected String doInBackground(String... params) {                String geMt@R_419_6889@;                String urlMt@R_419_6889@ = strUrlID+post_meterno.getText().toString().trim();                Log.d(TAG, "The string:" + urlMt@R_419_6889@);                try {                    URL url = new URL(urlMt@R_419_6889@);                    httpURLConnection con = (httpURLConnection) url.openConnection();                    con.setRequestMethod("GET");                    con.connect();                    BufferedReader bf = new BufferedReader(new inputStreamReader(con.getinputStream()));                    String value = bf.readline();                    Log.d(TAG, "Value of value is: " + value);                    if(value.equals("not found")){                        geMt@R_419_6889@ = "NOT FOUND";                    }else{                        JsONObject parentJson = new JsONObject(value);                        String meternumber = parentJson.getString("xmen");                        String meter@R_419_6889@ = parentJson.getString("x_@R_419_6889@");                        String address = parentJson.getString("address");                        geMt@R_419_6889@ = meter@R_419_6889@+"/"+meternumber+"/"+address;                    }                    Log.d(TAG, "meter @R_419_6889@ after get is: " + geMt@R_419_6889@);                } catch (Exception e) {                    // Log.d(TAG, "Faiiled coz: "+ e);                    geMt@R_419_6889@ = "failled";                    e.printstacktrace();                }                Log.d(TAG, "I dont kNow if this works " + geMt@R_419_6889@);                return geMt@R_419_6889@;            }            @OverrIDe            protected voID onPostExecute(String s) {                super.onPostExecute(s);                Log.d(TAG, "pnPostExecute value: " + s);                String @R_419_6889@SubString;                String numberSubString;                String addressSubString;                // date and time creation                String stringDate = String.valueOf(DateFormat.getDateTimeInstance());                Date stringTime = Calendar.getInstance().getTime();                SimpleDateFormat curFormater = new SimpleDateFormat("dd/MM/yyyy", Locale.ENGliSH);                SimpleDateFormat timeFormat = new SimpleDateFormat("h:mm a", Locale.ENGliSH);                Date dateObj = new Date();                Date timeObj = new Date();                try {                    dateObj = curFormater.parse(stringDate);                    timeObj = timeFormat.parse(String.valueOf(stringTime));                } catch (ParseException e) {                    e.printstacktrace();                }                SimpleDateFormat postFormater = new SimpleDateFormat("d MMMM yyyy", Locale.ENGliSH);                SimpleDateFormat postTimeFormater = new SimpleDateFormat("h:mm a", Locale.ENGliSH);                String newDateStr = postFormater.format(dateObj);                String newtimeStr = postTimeFormater.format(timeObj);                switch (s) {                    case FAILLED:                        @R_419_6889@SubString = FAILLED;                        numberSubString = FAILLED;                        addressSubString = FAILLED;                        break;                    case NOT_FOUND:                        @R_419_6889@SubString = FAILLED;                        numberSubString = FAILLED;                        addressSubString = FAILLED;                        break;                    default:                        String[] split = s.split("/");                        @R_419_6889@SubString = split[0];                        numberSubString = split[1];                        addressSubString = split[2];                        break;                }                switch (s) {                    //Todo: Change toast message to reflect Json in future                    case FAILLED:                        //Todo: after creating layout, go back to prevIoUs layout and display toast message                        Toast.makeText(TransactionActivity.this, CouldN_T_CONNECT_AT_THIS_TIME_PLEASE_TRY_AGAIN, Toast.LENGTH_SHORT).show();                        dialog.dismiss();                        break;                    case NOT_FOUND:                        Toast.makeText(TransactionActivity.this, PLEASE_CHECK_YOUR_METER_NUMBER_AND_TRY_AGAIN, Toast.LENGTH_SHORT).show();                        dialog.dismiss();                        break;                    default:                        Intent meterIntent = new Intent(TransactionActivity.this, MeterNumActivity.class);                        meterIntent.putExtra("meternum", mn);                        meterIntent.putExtra("meterprice", amount);                        meterIntent.putExtra("meterlocation", ml);                        meterIntent.putExtra("reference", ref);                        meterIntent.putExtra("meteracct@R_419_6889@", @R_419_6889@SubString);                        meterIntent.putExtra("meteracctnumber", numberSubString);                        meterIntent.putExtra("meteracctaddress", addressSubString);                        meterIntent.putExtra("uuID", userID);                        meterIntent.putExtra("date_created", newDateStr);                        meterIntent.putExtra("time_created", newtimeStr);                        meterIntent.putExtra("phone", phone);                        meterIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_top);                        startActivity(meterIntent);                        break;                }            }        };        dialog.show();        jesget@[email protected]();    }    @OverrIDe    public voID onBackpressed() {        Intent i= new Intent(this,HomePageActivity.class);        startActivity(i);        finish();    }}

我的摇篮是

androID {    compileSdkVersion 26    defaultConfig {        applicationID "com.example.menofx.xmen"        minSdkVersion 21        targetSdkVersion 26        versionCode 1        version@R_419_6889@ "1.0"        testInstrumentationRunner "androID.support.test.runner.AndroIDJUnitRunner"    }    buildTypes {        release {            MinifyEnabled true            proguardfiles getDefaultProguardfile('proguard-androID.txt'), 'proguard-rules.pro'        }    }}dependencIEs {    implementation filetree(include: ['*.jar'], dir: 'libs')    implementation 'com.androID.support:appcompat-v7:26.1.0'    implementation 'com.androID.support:cardvIEw-v7:26.1.0'    implementation 'com.firebaseui:firebase-ui-firestore:3.1.3'    implementation 'com.firebaseui:firebase-ui-auth:3.1.3'    implementation 'com.firebaseui:firebase-ui-database:3.1.3'    implementation "com.Google.firebase:firebase-firestore:11.8.0"    implementation "com.androID.support:recyclervIEw-v7:26.1.0"    implementation "com.Google.androID.gms:play-services-auth:11.8.0"    implementation 'co.paystack.androID:paystack:3.0.9'    implementation 'br.com.simplepass:loading-button-androID:1.8.4'    implementation 'com.github.faruktoptas:FancyShowCaseVIEw:1.0.0'    implementation 'com.sothree.slIDinguppanel:library:3.4.0'    implementation 'com.androID.support:design:26.1.0'    implementation 'com.androID.support:support-v4:26.1.0'    implementation 'com.androID.support:support-vector-drawable:26.1.0'    implementation 'com.androID.support.constraint:constraint-layout:1.0.2'    testImplementation 'junit:junit:4.12'    androIDTestImplementation 'com.androID.support.test:runner:0.5'    androIDTestImplementation 'com.androID.support.test.espresso:espresso-core:2.2.2'    implementation project(':library')}apply plugin: 'com.Google.gms.Google-services'

如果需要,我的保全规则是空的.这是我第一次使用Firebase UI,所以我什至不知道如何诊断问题.谢谢您的帮助.

解决方法:

您需要将POJO(模型类)放在一个程序包中,然后将该程序包添加到proguard规则中,或者可以将所有这些程序包添加到这些类所在的位置(我个人只是为它们使用一个程序包). Firebase在序列化和反序列化过程中使用反射,因此它不能使用混淆的类名.将所有这些文件放入一个软件包后,请将此规则添加到您的proguard文件中以防止混淆:

-keep class package.to.pojos.** { *; }

如果您希望将它们保留在原处,则只需为每个模型类添加一条规则,并使用-keep class关键字,后跟该类的完整路径(逐包).

总结

以上是内存溢出为你收集整理的java-在minifyEnabled设置为true的情况下生成带符号的APK后,firebase UI输出空白全部内容,希望文章能够帮你解决java-在minifyEnabled设置为true的情况下生成带符号的APK后,firebase UI输出空白所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/web/1092095.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存