Firebase 数据库 - Firebase 数据库运行循环中未捕获的异常 (19.3.0)

use*_*073 2 android firebase firebase-realtime-database firebase-crash-reporting

我在项目中遇到了这个问题,但不知道如何解决。请帮帮我。

我的项目之前(11.8.0)已经实现了firebase data并且运行正常。我最近添加了 firebase crashlytics sdk(数据库更新到 19.3.0),并在以发布模式(minifyEnable = true)运行项目时崩溃。

我的 gradle 文件

implementation("com.google.firebase:firebase-core:17.4.1")
    implementation("com.google.firebase:firebase-analytics:17.2.3")
    implementation("com.google.firebase:firebase-messaging:20.1.7")
    implementation("com.google.firebase:firebase-database:19.3.0")
    implementation("com.google.firebase:firebase-auth:19.3.1")
    implementation("com.google.firebase:firebase-crashlytics:17.0.0")
Run Code Online (Sandbox Code Playgroud)

我的代码

FirebaseDatabase database = FirebaseDatabase.getInstance();

        DatabaseReference dbRef = database.getReference("/mydbkey");
        dbRef.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
               // Do my stuff
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {
                // Do my stuff
            }
        });
Run Code Online (Sandbox Code Playgroud)

崩溃的消息:

Fatal Exception: java.lang.RuntimeException: Uncaught exception in Firebase Database runloop (19.3.0). If you are not already on the latest version of the Firebase SDKs, try updating your dependencies. Should this problem persist, please file a report at https://github.com/firebase/firebase-android-sdk
       at com.google.firebase.database.android.AndroidPlatform$1$1.run(AndroidPlatform.java:96)
       at android.os.Handler.handleCallback(Handler.java:873)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:201)
       at android.app.ActivityThread.main(ActivityThread.java:6820)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:922)
Caused by java.lang.NoSuchMethodError: No virtual method object()Lcom/***/android/am4; in class Lcom/***/android/am4; or its super classes (declaration of 'com.***.android.am4' appears in /data/app/com.***.debug-fG3zQ87gx1RUrYnvZ7rj7g==/base.apk!classes3.dex)
       at com.google.firebase.database.util.JsonMapper.serializeJsonValue(JsonMapper.java:69)
       at com.google.firebase.database.util.JsonMapper.serializeJsonValue(JsonMapper.java:58)
       at com.google.firebase.database.util.JsonMapper.serializeJson(JsonMapper.java:38)
       at com.google.firebase.database.connection.WebsocketConnection.send(WebsocketConnection.java:231)
       at com.google.firebase.database.connection.Connection.sendData(Connection.java:243)
       at com.google.firebase.database.connection.Connection.sendRequest(Connection.java:117)
       at com.google.firebase.database.connection.PersistentConnectionImpl.sendSensitive(PersistentConnectionImpl.java:1177)
       at com.google.firebase.database.connection.PersistentConnectionImpl.sendAction(PersistentConnectionImpl.java:1164)
       at com.google.firebase.database.connection.PersistentConnectionImpl.sendStats(PersistentConnectionImpl.java:1116)
       at com.google.firebase.database.connection.PersistentConnectionImpl.sendConnectStats(PersistentConnectionImpl.java:1159)
       at com.google.firebase.database.connection.PersistentConnectionImpl.onReady(PersistentConnectionImpl.java:310)
       at com.google.firebase.database.connection.Connection.onConnectionReady(Connection.java:217)
       at com.google.firebase.database.connection.Connection.onHandshake(Connection.java:210)
       at com.google.firebase.database.connection.Connection.onControlMessage(Connection.java:182)
       at com.google.firebase.database.connection.Connection.onMessage(Connection.java:132)
       at com.google.firebase.database.connection.WebsocketConnection.appendFrame(WebsocketConnection.java:256)
       at com.google.firebase.database.connection.WebsocketConnection.handleIncomingFrame(WebsocketConnection.java:303)
       at com.google.firebase.database.connection.WebsocketConnection.access$000(WebsocketConnection.java:34)
       at com.google.firebase.database.connection.WebsocketConnection$WSClientTubesock$2.run(WebsocketConnection.java:86)
       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
       at java.lang.Thread.run(Thread.java:764)
Run Code Online (Sandbox Code Playgroud)

use*_*073 6

就我而言,将其添加到 proguard 规则中

-keep 类 org.json.* { *; }