更新 Firebase 依赖项后,我的应用停止工作。崩溃报告显示了这个日志:
java.lang.RuntimeException: Internal error in Firestore (0.6.6-dev).
at com.google.firebase.firestore.g.b.a(com.google.firebase:firebase-firestore@@17.0.5:324)
at com.google.firebase.firestore.g.d.run(com.google.firebase:firebase-firestore@@17.0.5)
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:6165)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)
Caused by: java.lang.AbstractMethodError: abstract method "b.d.g.z$d b.d.g.z$d.a(int)"
at b.d.g.u.a(GeneratedMessageLite.java:1319)
at b.d.c.a.y.a(com.google.firebase:firebase-firestore@@17.0.5:8440)
at b.d.c.a.y$a.a(com.google.firebase:firebase-firestore@@17.0.5:6589)
at com.google.firebase.firestore.f.n.b(com.google.firebase:firebase-firestore@@17.0.5:689)
at com.google.firebase.firestore.c.N.a(com.google.firebase:firebase-firestore@@17.0.5:152)
at com.google.firebase.firestore.c.w.b(com.google.firebase:firebase-firestore@@17.0.5:82)
at com.google.firebase.firestore.c.O.a(com.google.firebase:firebase-firestore@@17.0.5:479)
at com.google.firebase.firestore.c.V.run(com.google.firebase:firebase-firestore@@17.0.5)
at com.google.firebase.firestore.c.u.a(com.google.firebase:firebase-firestore@@17.0.5:117)
at com.google.firebase.firestore.c.O.a(com.google.firebase:firebase-firestore@@17.0.5:474)
at com.google.firebase.firestore.b.f.a(com.google.firebase:firebase-firestore@@17.0.5:165)
at com.google.firebase.firestore.b.o.a(com.google.firebase:firebase-firestore@@17.0.5:79)
at com.google.firebase.firestore.b.r.c(com.google.firebase:firebase-firestore@@17.0.5:132)
at com.google.firebase.firestore.b.w.run(com.google.firebase:firebase-firestore@@17.0.5)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at com.google.firebase.firestore.g.b$a.run(com.google.firebase:firebase-firestore@@17.0.5:190)
at java.lang.Thread.run(Thread.java:761)
由于日志没有对我的源代码的任何类引用,我试图找出依赖关系。
终于明白了,问题是因为R8 shrinker和GRPC。
以下是上述问题的解决方案:
- android.enableR8=false
- -保持类 io.grpc.** { *; }
上述两种解决方案对我来说都不是很有趣。
我不想应用第一种解决方案,因为禁用 R8 会使我的 APK 大小增加 200 KB。第二种解决方案对我来说是个黑客。当单个类引起一些问题时,我不赞成保留整个库。
现在的问题是如何让我的应用程序在启用 R8 的情况下工作并且不让grpc
库远离混淆?