ClassNotFoundException- .BaseDexClassLoader.findClass
Asked Answered
D

1

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..

Delative answered 16/7, 2018 at 11:11 Comment(2)
Hey, Have you solve the problem? May I know what is the root cause?Wizard
Enabled mulidex and try.Delative
L
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.

Leonelleonelle answered 16/7, 2018 at 11:46 Comment(3)
Thanks for the reply, I am already using MultiDexApplication in the App.Delative
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!Leonelleonelle
This is a play store build issue.. not a debug one.Delative

© 2022 - 2024 — McMap. All rights reserved.