Android Studio ..应用程序在部署时遇到崩溃apk

时间:2018-02-07 20:50:39

标签: android firebase-authentication

当我直接从Android工作室使用真实设备运行我的应用程序..它工作正常...但是当我构建apk并运行它然后在用户注册期间它崩溃...



public void storeDataToFirebase(){
        progressDialog.setMessage("Storing Data to Database");
        User user=new User(USERNAME,EMAIL,gender,AGE,NUMBER,BG,PASSWORD);
         userEmail=mAuth.getCurrentUser().getEmail();

        assert email != null;
        FirebaseDatabase.getInstance().getReference().child("Users")
                   .child(userEmail.replace(".","_")).setValue(user).addOnCompleteListener(new OnCompleteListener<Void>() {
               @Override
               public void onComplete(@NonNull Task<Void> task) {
                   if (task.isSuccessful()) {
                       Toast.makeText(MainActivity.this, "Data inserted", Toast.LENGTH_SHORT).show();
                   }
                   else {
                       Toast.makeText(MainActivity.this, "Data insertion failed", Toast.LENGTH_SHORT).show();
                   }
               }
           });

        }
&#13;
&#13;
&#13;

... logcat中

muhammadobaid.blooddonationsystem E / AndroidRuntime:FATAL EXCEPTION:main                                                                                              过程:com.example.muhammadobaid.blooddonationsystem,PID:4273                                                                                              com.google.firebase.database.DatabaseException:没有在类com.example.muhammadobaid.blooddonationsystem.Model.User上找到的要序列化的属性                                                                                                  在com.google.android.gms.internal.zzekq。(未知来源)                                                                                                  在com.google.android.gms.internal.zzekp.zzf(未知来源)                                                                                                  在com.google.android.gms.internal.zzekp.zzbw(未知来源)                                                                                                  在com.google.android.gms.internal.zzekp.zzbv(未知来源)                                                                                                  在com.google.firebase.database.DatabaseReference.zza(未知来源)                                                                                                  在com.google.firebase.database.DatabaseReference.setValue(未知来源)                                                                                                  在com.example.muhammadobaid.blooddonationsystem.MainActivity.storeDataToFirebase(MainActivity.java:111)                                                                                                  在com.example.muhammadobaid.blooddonationsystem.MainActivity $ 1 $ 1.onComplete(MainActivity.java:57)                                                                                                  在com.google.android.gms.tasks.zzf.run(未知来源)                                                                                                  在android.os.Handler.handleCallback(Handler.java:815)                                                                                                  在android.os.Handler.dispatchMessage(Handler.java:104)                                                                                                  在android.os.Looper.loop(Looper.java:214)                                                                                                  在android.app.ActivityThread.main(ActivityThread.java:6102)                                                                                                  at java.lang.reflect.Method.invoke(Native Method)                                                                                                  在java.lang.reflect.Method.invoke(Method.java:372)                                                                                                  在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1028)                                                                                                  在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)

1 个答案:

答案 0 :(得分:0)

public class User {

    public String username;
    public String email;
    public String gender;
    public   String age;
    public String number;
    public String bloodGroup;
    public String password;

    public User(String username, String email, String gender, String age, String number, String bloodGroup, String password) {
        this.username = username;
        this.email = email;
        this.gender = gender;
        this.age = age;
        this.number = number;
        this.bloodGroup = bloodGroup;
        this.password = password;
    }
}

我将我的用户类变量设为public ..这解决了我的问题..

它有助于...... Firebase No properties to serialize found on class