java.lang.ClassNotFoundException : dalvik.system.BaseDexClassLoader.findClass
Asked Answered
P

2

17

I'm continuously getting this error report in my Google Play developer console. It look like MultiDex error.

java.lang.RuntimeException: 
  at android.app.LoadedApk.makeApplication(LoadedApk.java:516)
  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4514)
  at android.app.ActivityThread.access$1500(ActivityThread.java:151)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1381)
  at android.os.Handler.dispatchMessage(Handler.java:110)
  at android.os.Looper.loop(Looper.java:193)
  at android.app.ActivityThread.main(ActivityThread.java:5299)
  at java.lang.reflect.Method.invokeNative(Native Method:0)
  at java.lang.reflect.Method.invoke(Method.java:515)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
  at dalvik.system.NativeStart.main(Native Method:0)

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

I already added this to gradle.build:

defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...

// Enabling multidex support.
multiDexEnabled true
}

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

 @Override
    protected void attachBaseContext(Context newBase) {
        super.attachBaseContext(newBase);
        try {
            MultiDex.install(this);
        }catch (RuntimeException e){
            e.printStackTrace();
        }catch (Exception e){
            e.printStackTrace();
        }
    }

I'm still getting this error in android 4.4,5.0,5.1, 6.0. Please help !!

Primatology answered 3/7, 2017 at 8:12 Comment(13)
Have you register MutlidexApplication class to manifest ?Assiduous
did you set android:name="android.support.multidex.MultiDexApplication" in application sectionOdin
No, I've added attachBaseContext method in main activityPrimatology
what is the reason for this error, I am also getting this error in dev consoleFerrigno
Actually, I haven't used multi-dex in my appFerrigno
same here. no infoTrauner
Also getting this error in dev console! It is not the MultiDex error though, as that only occurs on pre-lollipop devices. This is something else..Cyndie
Did you try extending your Application class from: MyApplication extends Application To: MyApplication extends MultiDexApplicationLector
This shows in Developer Console (for devices with android 4.2, 4.4, 5.0, 5.1) for app with no multidex (around 11K methods). Should I enable multidex?Wizen
Has anyone tried using a debugger and adding a breakpoint here: ClassLoader.java:457 or here BaseDexClassLoader.java:56 to see what class it's trying to load and investigate if it's on the class path?Peridium
Same problem here. It is rare, but it has been happening periodically for a while. Most of the crashes are from Android 4.4, some are from Android 5.0, Very few are from Android 4.2, Android 5.1.Weathertight
Just a comment so you can check if it works for you. I am using multidex in one app I have, but I am using another version of multidex library: 'com.android.support:multidex:1.0.2' (I'm using android studio 3.1.4)President
It is just a question, but are you using proguard ?Bartram
B
1

There are multiple variants of the java.lang.ClassNotFoundException in Android, most of them are caused by a wrong Proguard configuration, IDE not closing correctly the previous launched instance of the device during build time etc.

Follow Unexpected crash in BaseDexClassLoader for more details.

Brien answered 3/1, 2019 at 5:29 Comment(0)
O
0

It might be because of conflict in dependencies (same class may exists in two libraries). So search for BaseDexClassLoader class in your dependencies.

Ophthalmologist answered 9/10, 2019 at 19:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.