我的大脑被炸了。我搜索了 SO 寻求帮助,但似乎带有此异常的 Proguard 问题特定于相关应用程序。我一直在尝试使用 Proguard 来混淆/缩小我的应用程序,当我在 Generated APK 表单中运行它时,我的应用程序要么崩溃,要么让我遇到:
com.company.project E/a: java.lang.NoSuchMethodException: fromValue [int]
堆栈跟踪:
java.lang.AssertionError: java.lang.NoSuchMethodException: fromValue [int]
at com.squareup.wire.RuntimeEnumAdapter.decode(Unknown Source)
at com.squareup.wire.RuntimeEnumAdapter.getFromValueMethod(Unknown Source)
at com.squareup.wire.RuntimeEnumAdapter.decode(Unknown Source)
at com.company.project.utils.wiremodels.d.a(Unknown Source)
at com.company.project.utils.wiremodels.d.decode(Unknown Source)
at com.company.project.utils.wiremodels.g.a(Unknown Source)
at com.company.project.utils.wiremodels.g.decode(Unknown Source)
at com.squareup.wire.ProtoAdapter.decode(Unknown Source)
at retrofit2.converter.wire.WireResponseBodyConverter.convert(Unknown Source)
at retrofit2.converter.wire.WireResponseBodyConverter.convert(Unknown Source)
at retrofit2.ServiceMethod.toResponse(Unknown Source)
at retrofit2.OkHttpCall.parseResponse(Unknown Source)
at retrofit2.OkHttpCall$1.onResponse(Unknown Source)
at a.az.b(Unknown Source)
at a.a.l.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.NoSuchMethodException: fromValue [int]
at java.lang.Class.getMethod(Class.java:624)
at java.lang.Class.getMethod(Class.java:603)
... 18 more
我的应用使用了来自 Square 的 Retrofit (2.1.0) 和 Wire。然后,当我的应用程序崩溃时,我正在检查mapping.txt
文件以查看导致问题的类(我相信是com.company.project.a
,对吗?)
无论如何,这是我的 proguard 文件(带有模糊的类名 fyi):
-dontwarn okio.**
-dontwarn retrofit2.Platform$Java8
-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keep class com.squareup.wire.** { *; }
-keep class com.company.project.utils.wiremodels.ProtoFile1 { *; }
-keep class com.company.project.utils.wiremodels.ProtoFile2 { *; }
-keep class com.company.project.utils.wiremodels.ProtoFile3 { *; }
-keep class com.company.project.utils.wiremodels.ProtoFile4 { *; }
-keep class com.company.project.utils.wiremodels.ProtoFile5 { *; }
-dontwarn com.google.**
-keepattributes Signature
-keepattributes *Annotation*
-keepattributes Exceptions
-dontwarn org.w3c.dom.bootstrap.DOMImplementationRegistry
-dontwarn org.simpleframework.xml.stream.**
如果我能得到一些帮助,那就太棒了,如果我应该提供更多信息,请告诉我。
编辑:在标记答案的评论中回答的问题(供将来参考)