While applying proguard to application m getting following verify error, I have seen other variants of verify errors but the following seems bit different, Proguard version: 5.3.3, Following MainApplication class extends android.app.Application and crash occurs at super.onCreate(); of onCreate() method
and in my proguard m having
-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
,also I have mentioned
-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
With analyze apk I can see following is not obfuscated without proguard
.class public Lcom/myapplication/MainApplication;
.super Landroid/app/Application;
.source "MainApplication.java"
but same was obfuscated once I apply proguard,
.class public Lcom/myapplication/MainApplication;
.super Lak;
.source "SourceFile"
correct me if m wrong, with following
-keep public class * extends android.app.Application
it must not obfuscate application classes, why does above happen..?
I had the exactly same error after resolving a lot of conflicts and rebases. I just cleaned the project and rebuilt it. It was working again like a charm.