This is similar to Rejecting class because it failed compile-time verification Android and java.lang.VerifyError: Verifier rejected class on Lollipop when using release APK but the origin of my problem is still unknown and all the proposed solutions do not help.
Manually installing a signed release apk with MultiDex support and ProGuard enabled throws this exception on start:
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)
This will not happen with -dontoptimize
. Current minimal optimization setting:
-optimizations "code/*"
I get the same error without -optimizations
or with less restrictive options. Adding -keep class android.*
wont help either. I get no error with "code/removal/*,code/simplification/*"
, but this ignores -assumenosideeffects
android.support.g.b is the obfuscated android.support.multidex.MultiDex class itself, and the error is caused when the overridden attachBaseContext(Context)
is called:
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
Decoding this method (the default constructor) with the byte code viewer results in:
private b() { // <init> //()V
return
}
- It would be useful to disable optimization by class specification.
- Alternative: Knowing the minimum
-optimizations
option that considers-assumenosideeffects
Do not use member wildcards with
-assumenosideeffects
because this will "spill over" to Object for other classes. See https://sourceforge.net/p/proguard/bugs/716/#98d4Similar problems may come up for any rules with interfaces. Example: