6

I am facing ClassNotFoundException in production build.

Please find below exception logs.

java.lang.RuntimeException:
at android.app.LoadedApk.makeApplication (LoadedApk.java:578)
at android.app.ActivityThread.handleBindApplication (ActivityThread.java:4680)
at android.app.ActivityThread.access$1600 (ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1405)
at android.os.Handler.dispatchMessage (Handler.java:102)
at android.os.Looper.loop (Looper.java:148)
at android.app.ActivityThread.main (ActivityThread.java:5417)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:616)

Caused by: java.lang.ClassNotFoundException:
at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass (ClassLoader.java:511)
at java.lang.ClassLoader.loadClass (ClassLoader.java:469)
at android.app.Instrumentation.newApplication (Instrumentation.java:982)
at android.app.LoadedApk.makeApplication (LoadedApk.java:573)

I have set progaurd and Multidex properly in the project and this issue occurs in multiple versions of android from 4.2 to 6.0.

Can anyone help with this!

Thanks in advance..

Neo
  • 260
  • 2
  • 14

1 Answers1

2
defaultConfig {
...
minSdkVersion 14
targetSdkVersion // your version 
...

// Enabling multidex support.
multiDexEnabled true
}

dependencies {
  compile 'com.android.support:multidex:1.0.0'
}

Add the above piece to your build.gradle file.

@Override
protected void attachBaseContext(Context base) {
    MultiDex.install(base);
}

Add the above to your Application file which will extend the MultiDexApplication.

  • Thanks for the reply, I am already using MultiDexApplication in the App. – Neo Jul 16 '18 at 12:11
  • Okay can you try the below points and let me know the status? 1) Invalidate Caches/Restart Android Studio. 2) Try building while disabling instant run Not a perfect fix, but can help you going if you are in a hurry! – Jeet Karmakar Jul 16 '18 at 12:30
  • This is a play store build issue.. not a debug one. – Neo Jul 16 '18 at 13:00