虽然在应用程序中将proguard应用于跟随验证错误的过程中,但我看到了验证错误的其他变体,但以下内容似乎有些不同, Proguard版本:5.3.3, 以下MainApplication类扩展了android.app.Application,崩溃发生在super.onCreate();上。 onCreate()方法的
在我的监护人中
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgent
,我也提到过
-dontshrink -dontoptimize
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myapplication, PID: 18598
java.lang.VerifyError: Rejecting class com.myapplication.MainApplication that attempts to sub-type erroneous class ak (declaration of 'com.myapplication.MainApplication' appears in /data/app/com.myapplication-v4oPXfQv5kNLX1oUA9GwUw==/base.apk)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newApplication(Instrumentation.java:1102)
at android.app.Instrumentation.newApplication(Instrumentation.java:1087)
at android.app.LoadedApk.makeApplication(LoadedApk.java:983)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5715)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.VerifyError: Rejecting class ak that attempts to sub-type erroneous class en (declaration of 'ak' appears in /data/app/com.myapplication-v4oPXfQv5kNLX1oUA9GwUw==/base.apk)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newApplication(Instrumentation.java:1102)
at android.app.Instrumentation.newApplication(Instrumentation.java:1087)
at android.app.LoadedApk.makeApplication(LoadedApk.java:983)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5715)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.VerifyError: Verifier rejected class en: void en.<init>(android.content.Context) failed to verify: void en.<init>(android.content.Context): [0xA] thrown class Precise Reference: bjp not instanceof ThrowableVerifier rejected class en: void en.attachBaseContext(android.content.Context) failed to verify: void en.attachBaseContext(android.content.Context): [0x7] thrown class Precise Reference: bjp not instanceof Throwable
通过分析apk,我可以看到没有proguard不会混淆以下内容
.class public Lcom/myapplication/MainApplication;
.super Landroid/app/Application;
.source "MainApplication.java"
但是一旦我申请了proguard,就被混淆了
.class public Lcom/myapplication/MainApplication;
.super Lak;
.source "SourceFile"
如果我错了,请纠正我, 跟着
-keep public class * extends android.app.Application
它一定不能混淆应用程序类,为什么会发生上述情况??
答案 0 :(得分:3)
解决了许多冲突和基准调整后,我遇到了完全相同的错误。我刚刚清理了该项目并对其进行了重建。它再次像魅力一样工作。
答案 1 :(得分:0)
当看着ContextWrapper时……据说:
已知的直接子类
应用程序,BackupAgent,ContextThemeWrapper,IsolatedContext,MutableContextWrapper,RenamingDelegatingContext,Service
...在ProGuard -keep
配置中并非全部声明。
您需要添加与以下规则类似的规则,这是一种不同的方法,而不是通过名称显式地添加所有单个子类... public
关键字在那里是可选的,因为实际上private
/ protected
方法并不需要混淆,仅因为SDK源码包可公开下载。在配置中添加-verbose
开关总是会使ProGuard抱怨“该怎么办”,并且总是带有指向用户手册的超链接。
-keep public class * extends android.content.ContextWrapper {public *;}
将mapping.txt
上载到Crashlytics有助于解决混淆版本中的崩溃问题。