当前位置:  开发笔记 > 编程语言 > 正文

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

如何解决《尝试在Firebase数据库中保存对象时出现错误"java.lang.StackOverflowError:"》经验,为你挑选了1个好方法。

我是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() {
                            @Override
                            public void onComplete(@NonNull Task 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("");
                                }
                            }
                        });

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

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数据库数据的用户的 数据之一

任何帮助将不胜感激



1> Bob Snyder..:

您的Member类包含一个类型的字段Uri. Uri不是Firebase序列化的本机类型之一.

更改您的Member类以将Uri存储为String并使用Uri.toString()和Uri.parse()进行转换.


非常感谢,因为这个原因,我一直在拉我的头发过夜.Firebase应该会产生更易于理解的错误消息,而不是发送垃圾邮件给这行`com.google.android.gms.internal.zzbqi $ zza`
推荐阅读
周扒pi
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有