Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error "java.lang.StackOverflowError:" when try to save object in Firebase Database

I am new to the firebase. I tried to save the properties of the users listed in my application into the database Firebase, this is code

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));
            }
        }
    };

the problem here is when I get into my application using the Google sign in, I can not save the information of the user who signed in to my application with google to my firebase database, but I can save the user's login information using email method. This is the code to get into my application using email

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("");
                                }
                            }
                        });

As for the error I get when trying to store user data that sign in using 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

This is one of the data of the user who successfully saved Firebase Database data

any help would be greatly appreciated

like image 636
wildan iskandar Avatar asked Jan 10 '17 11:01

wildan iskandar


People also ask

How do I fix Java Lang StackOverflowError?

Increase Thread Stack Size (-Xss) Increasing the stack size can be useful, for example, when the program involves calling a large number of methods or using lots of local variables. This will set the thread's stack size to 4 mb which should prevent the JVM from throwing a java. lang. StackOverflowError .

What is Java Lang StackOverflowError?

lang. stackoverflowerror is indicative of serious problems that an application cannot catch (e.g., stack running out of space). It is usually caused by a no terminating ​condition of the recursive call.

Can you catch StackOverflowError Java?

StackOverflowError is an error which Java doesn't allow to catch, for instance, stack running out of space, as it's one of the most common runtime errors one can encounter.

What is firebase stackoverflow?

Firebase is a platform for mobile and web apps. There's three main services to Firebase: Realtime database. Authentication. Static Hosting.


1 Answers

Your Member class contains a field of type Uri. Uri is not one of the native types that Firebase serializes.

Change your Member class to store the Uri as a String and use Uri.toString() and Uri.parse() to convert.

like image 155
Bob Snyder Avatar answered Sep 24 '22 14:09

Bob Snyder