user7744006
user7744006

Reputation: 39

Android Application crashes at Uncaught exception in Firebase runloop (3.0.0)

I am developing an application in which i am using Firebase database. I need to retrieve some information from the database but the addValueEventListener does not fire at all and after couple of minutes my application crashes with following error E/AndroidRuntime: FATAL EXCEPTION: main Process: shareanddrive.net.net23.myapp, PID: 3317 java.lang.RuntimeException: Uncaught exception in Firebase runloop (3.0.0). Please report to [email protected] at com.google.android.gms.internal.zzagf$1$1.run(Unknown Source) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) Caused by: java.lang.OutOfMemoryError: OutOfMemoryError thrown while trying to throw OutOfMemoryError; no stack trace available

However adValuEventListener works in previous activity but as i come second activity it stops working. I have checked the reference it is correct. My code for the retrieval in second activity is:

adsviewReference.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            textView.append("on add value datachange");

            }

        @Override
        public void onCancelled(DatabaseError databaseError) {
            textView.setText("Failed ");
        }
    });

Neither of the function from onDataChanged or onCancelled fires. Please help in this.

Upvotes: 1

Views: 943

Answers (2)

Enos Okello
Enos Okello

Reputation: 121

This is caused by using an incompatible version of Firebase Auth and the Firebase Realtime Database SDK. Please update your dependency of Firebase Auth and Firebase Database to the latest version. Check https://github.com/firebase/firebase-android-sdk/issues/1086

Upvotes: 1

Frank van Puffelen
Frank van Puffelen

Reputation: 599196

The exception you get is OutOfMemoryError. This means that you're trying to download more data from the database than your device has memory to handle.

The only way to solve this is to reduce the amount of data your app synchronizes at any one time. Things you can do:

  1. Make sure that you remove the listener from the previous activity on its onStop() or onPause(), so that the data from the previous activity can be removed from memory.
  2. Attach your listener lower in the tree, so that less data is synchronized.

Upvotes: 0

Related Questions