Uncaught exception in Firebase runloop (3.0.0) In my production Android app. Please report to support@firebase.com

纵然是瞬间 提交于 2019-12-07 07:45:31

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 :)

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!