错误" java.lang.StackOverflowError:"尝试在Firebase数据库中保存对象时

时间:2017-01-10 11:20:26

标签: java android firebase firebase-realtime-database firebase-authentication

我是firebase的新手。 我尝试将应用程序中列出的用户的属性保存到数据库Firebase中,这是代码

mAuthListener = new FirebaseAuth.AuthStateListener() {
        @Override
        public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
            firebaseuser = firebaseAuth.getCurrentUser();
            if (firebaseuser != null) {
                finish();
                firebaseuser = mAuth.getCurrentUser();
                String nama = firebaseuser.getDisplayName();
                String mail = firebaseuser.getEmail();
                //String pass = password.getText().toString();
                String id = firebaseuser.getUid();
                //Uri gambar = firebaseuser.getPhotoUrl();
                member1 = new Member(nama, mail, "", "belum", "belum", "belum", id);
                datab.getReference("member").push().setValue(member1);
                startActivity(new Intent(getApplicationContext(), HalamanUtama.class));
            }
        }
    };

这里的问题是当我使用Google登录进入我的应用程序时,我无法将使用google登录到我的应用程序的用户的信息保存到我的firebase数据库,但我可以保存用户'使用电子邮件方法登录信息。 这是使用电子邮件进入我的应用程序的代码

mAuth.createUserWithEmailAndPassword(email.getText().toString(), password.getText().toString())
                        .addOnCompleteListener(HalamanPendaftaran.this, new OnCompleteListener<AuthResult>() {
                            @Override
                            public void onComplete(@NonNull Task<AuthResult> task) {
                                if (task.isSuccessful()) {
                                    progressdialog.dismiss();
                                    finish();
                                    firebaseuser = mAuth.getCurrentUser();
                                    String nama = firebaseuser.getDisplayName();
                                    String mail = firebaseuser.getEmail();
                                    String pass = password.getText().toString();
                                    String id = firebaseuser.getUid();
                                    Uri gambar = firebaseuser.getPhotoUrl();
                                    member1 = new Member(nama, mail, pass, "belum", "belum", "belum", id, gambar);
                                    datab.getReference("member").push().setValue(member1);
                                    startActivity(new Intent(HalamanPendaftaran.this, HalamanUtama.class));
                                } else {
                                    progressdialog.dismiss();
                                    Toast.makeText(HalamanPendaftaran.this, "tidak dapat mendaftarkan user, tolong coba lagi !", Toast.LENGTH_SHORT).show();
                                    email.setText("");
                                    password.setText("");
                                }
                            }
                        });

至于我在尝试存储使用Google登录的用户数据时遇到的错误

01-10 18:42:00.619 8218-8218/com.example.asus.fastapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.asus.fastapp, PID: 8218
java.lang.StackOverflowError: stack size 8MB
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzax(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source)
at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzax(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source)
at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzax(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source)
at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzax(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source)
at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzax(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source)
at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzax(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source)
at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzax(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source)
at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzax(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source)
at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzax(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source)
at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzax(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source)
at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzax(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source)
at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzax(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source)
at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzax(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source)
at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzax(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source)
at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzax(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source)
at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzax(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source)
at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzax(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source)
at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzax(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source)
at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzax(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source)
at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzax(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzaE

这是成功保存的用户的数据之一 Firebase Database data

任何帮助将不胜感激

1 个答案:

答案 0 :(得分:16)

您的Member类包含Uri类型的字段。 <{1}}不是Firebase序列化的one of the native types

更改您的Uri类,将Uri存储为字符串,并使用Uri.toString()Uri.parse()进行转换。