Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to identify source of java.lang.ClassNotFoundException BaseDexClassLoader

Tags:

java

android

I have got lot of crash report in my android app from users as I see in the developer console. The stack trace that I see is:

java.lang.RuntimeException:

  at android.app.ActivityThread.handleReceiver (ActivityThread.java:2884)

  at android.app.ActivityThread.-wrap14 (ActivityThread.java)

  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1565)

  at android.os.Handler.dispatchMessage (Handler.java:111)

  at android.os.Looper.loop (Looper.java:207)

  at android.app.ActivityThread.main (ActivityThread.java:5728)

  at java.lang.reflect.Method.invoke (Native Method)

  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:789)

  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:679)
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.ActivityThread.handleReceiver (ActivityThread.java:2879)

There is no reference to my app's package name. I am using Eclipse for my development. Is it something related to multidex. Do I need to switch to Android Studio to solve this. I am unable to understand the basic reason behind the stack trace so that I can look for a solution for it.

Note: I have google play services, IAP and OneSignal Sdk added to my app

like image 246
Piyush-Ask Any Difference Avatar asked Sep 08 '17 03:09

Piyush-Ask Any Difference


2 Answers

I would personally say that Android Studio has the edge over the two.Android studio is becoming more popular day by day among the android development community and also the open source community. Android Studio or Eclipse?

Read Migrate to Android Studio .

Migrating your projects to Android Studio requires adapting to a new project structure, build system, and IDE functionality. If you are migrating an Android project from Eclipse, Android Studio provides an import tool so you can quickly move your existing code into Android Studio projects and Gradle-based build files.

Logcat Throws

Caused by: java.lang.ClassNotFoundException:
at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:56)

BaseDexClassLoader Base class for common functionality between various dex-based ClassLoader implementations.

In order to configure your app project to use a MultiDex configuration, you must make the following modifications, depending on the minimum Android version that your app supports.

set multiDexEnabled true to your build.gradle module-level file , as shown below:

    android {
    compileSdkVersion //
    buildToolsVersion //

    defaultConfig {
        ...
        minSdkVersion 14
        targetSdkVersion //
        ...

        // Enabling multidex support.
        multiDexEnabled true
    }
    ...
}

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

You can check DexIndexOverflowException .

like image 115
IntelliJ Amiya Avatar answered Oct 15 '22 13:10

IntelliJ Amiya


It seems like you are using pro guard and need to exclude some classes. Make sure you have excluded any library used in your project.

like image 44
KR_Android Avatar answered Oct 15 '22 14:10

KR_Android