1

I know there are already many issues in StackOverflow. But I didn't found any of these fixed my issue.

My Android app is in production and I am getting this error almost everyday from my user.

Fatal Exception: java.lang.RuntimeException: Uncaught exception in Firebase runloop (3.0.0). Please report to support@firebase.com
   at com.google.android.gms.internal.zzagf$1$1.run(Unknown Source)
   at android.os.Handler.handleCallback(Handler.java:815)
   at android.os.Handler.dispatchMessage(Handler.java:104)
   at android.os.Looper.loop(Looper.java:194)
   at android.app.ActivityThread.main(ActivityThread.java:5763)
   at java.lang.reflect.Method.invoke(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:372)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by java.util.ConcurrentModificationException
   at java.util.HashMap$HashIterator.remove(HashMap.java:805)
   at bvi.l(:com.google.android.gms.DynamiteModulesC:648)
   at bvi.a(:com.google.android.gms.DynamiteModulesC:388)
   at buw.a(:com.google.android.gms.DynamiteModulesC:82)
   at buw.a(:com.google.android.gms.DynamiteModulesC:4199)
   at bvz.b(:com.google.android.gms.DynamiteModulesC:226)
   at bvz.a(:com.google.android.gms.DynamiteModulesC:271)
   at bwg.run(:com.google.android.gms.DynamiteModulesC:1020)
   at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
   at java.util.concurrent.FutureTask.run(FutureTask.java:237)
   at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152)
   at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
   at java.lang.Thread.run(Thread.java:818)

This issue is really annoying and it might also cause me loosing users.

My build.gradle:

compile 'com.google.android.gms:play-services-auth:9.2.1'
compile 'com.google.firebase:firebase-database:9.2.1'
compile 'com.google.firebase:firebase-auth:9.2.1'
compile 'com.google.firebase:firebase-invites:9.2.1'
compile 'com.firebaseui:firebase-ui-database:0.4.0'

NOTE: I am not using Firebase Crash Reporting, since it is creating a different Process which also can be the cause of this defect. But dont know why I still get this defect.

I have already asked the slack community about this. Seems like they are not able to help me because the code is obfuscated.

Here is my app link: 2048 Live

Chandra Sekhar
  • 18,914
  • 16
  • 84
  • 125
  • are you using Transaction operation in your app? – Wilik Aug 17 '16 at 17:29
  • @Wilik, yes. There are many places in my app liking or disliking a game, winning a game or losing a game, etc. In these case I need previous server data, manipulate and update. So transaction. – Chandra Sekhar Aug 17 '16 at 17:30
  • I've removed the Crashlytics link as this might cause the question to be closed as either too localised or not self-contained. I agree that a stack trace would be good though - please paste the relevant bit into the question as a formatted text block. Thanks. – halfer Aug 17 '16 at 19:21
  • 1
    @ChandraSekhar Hi, any update about this? – Ihor Bykov Mar 15 '17 at 22:21

2 Answers2

1

If you're using transaction method, the error occurs if the user taps the button repeatedly (creating multiple transaction requests) and in a short time before the previous transaction finished.

I had the same problem and my solution in my app is by avoiding transaction method if the operation can be done in a short time.

Or you can disable the button and enable it when the previous transaction is finished or prevent the user from abusing the button.

private void onLikeButtonClicked() {
    likeButton.setEnabled(false);
    ref.runTransaction(new Transaction.Handler() {
        @Override
        public Transaction.Result doTransaction(MutableData mutableData) {
            // transaction operation 
            return Transaction.success(mutableData);
        }

        @Override
        public void onComplete(DatabaseError databaseError, boolean b,
                               DataSnapshot dataSnapshot) {
            likeButton.setEnabled(true);
        }
    });
}

I hope you understand my explanation, hope this helps :)

Wilik
  • 7,630
  • 3
  • 29
  • 35
  • That is already taken care. There are also other situation in my app, where I have to do transactions multiple times. For example: when an user wins a challenge, then some reward points should be added and deducted from respective accounts. As well as I need to update the winner details and winning counts too. So its almost 4 transactions in code and that should be done. – Chandra Sekhar Aug 17 '16 at 17:44
  • can you post the simplified code of those transactions? maybe we can figure a better way to achieve what you want. and also try to update your firebase library to 9.4.0 and firebase-ui to 0.4.4 – Wilik Aug 17 '16 at 17:58
  • This also happens in 9.4.0 – Makalele Sep 07 '16 at 06:37
  • Also happening in 9.6.1 – Borja Oct 07 '16 at 07:20
0

This happens when you enable persistent storage. And it seems they are yet to fix it. But if you disable persistent storage, you wont see this issue again.

//FirebaseDatabase.getInstance().setPersistenceEnabled(true);

Comment out this line and it will work. It happen as a result of corrupt database stored locally.

Sunday G Akinsete
  • 802
  • 13
  • 14