这类似于Rejecting class because it failed compile-time verification Android和java.lang.VerifyError: Verifier rejected class on Lollipop when using release APK,但是我的问题的根源仍然未知,所有提议的解决方案都无济于事。
手动安装具有MultiDex支持并启用ProGuard的签名发行版APK会在启动时引发此异常:
475-475/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: ..., PID: 475
java.lang.VerifyError: Verifier rejected class android.support.g.b due to bad method void android.support.g.b.<init>() (declaration of 'android.support.g.b' appears in /data/app/...-2/base.apk)
at ...MyApp.attachBaseContext(Unknown Source)
at android.app.Application.attach(Application.java:181)
-dontoptimize
不会发生这种情况。当前的最小优化设置:
-optimizations "code/*"
在没有-optimizations
或限制性较小的选项的情况下,我也会遇到相同的错误。添加-keep class android.*
也无济于事。我没有遇到"code/removal/*,code/simplification/*"
的错误,但这忽略了-assumenosideeffects
android.support.g.b是混淆的android.support.multidex.MultiDex类本身,并且在调用重写的attachBaseContext(Context)
时引起错误:
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
使用字节码查看器对该方法(默认构造函数)进行解码会导致:
private b() { // <init> //()V
return
}
-optimizations
的最小-assumenosideeffects
选项答案 0 :(得分:1)
请勿将成员通配符与-assumenosideeffects
一起使用,因为这将“溢出”到其他类的Object。参见https://sourceforge.net/p/proguard/bugs/716/#98d4
任何带有接口的规则都可能出现类似的问题。示例:
-assumenosideeffects class * implements Interface {
public <init>();
public Object interfacemethod(); # May concern methods with same signature in other Objects
}