Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.ClassNotFoundException in dalvik.system.BaseDexClassLoader.findClass

Tags:

java

android

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.me.hexavoidaa/com.me.hexavoidaa.PTPlayer}: java.lang.ClassNotFoundException: Didn't find class "com.me.hexavoidaa.PTPlayer" on path: DexPathList[[zip file "/data/app/com.me.hexavoidaa-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.me.hexavoidaa-1, /vendor/lib, /system/lib]]
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2208)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2340)
    at android.app.ActivityThread.access$800(ActivityThread.java:157)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:157)
    at android.app.ActivityThread.main(ActivityThread.java:5293)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.me.hexavoidaa.PTPlayer" on path: DexPathList[[zip file "/data/app/com.me.hexavoidaa-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.me.hexavoidaa-1, /vendor/lib, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
    at android.app.Instrumentation.newActivity(Instrumentation.java:1079)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2199)
    ... 11 more
like image 720
Joel Avatar asked Jan 02 '17 12:01

Joel


5 Answers

add this to gradle.build:

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

// Enabling multidex support.
multiDexEnabled true
}

dependencies {
  compile 'com.android.support:multidex:1.0.0'
}
  • follow android developers page's instruction: https://developer.android.com/studio/build/multidex.html
like image 173
Ranjith KP Avatar answered Oct 27 '22 06:10

Ranjith KP


In Android 9 likely to help adding to manifest into "application" tag:

<uses-library
        android:name="org.apache.http.legacy"
        android:required="false" />
like image 3
AlexS Avatar answered Oct 27 '22 06:10

AlexS


In some cases, this could be a MultiDex issue. Try this in your application class. That is in App.java which extends Application:

@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this); // this is the key code
}

source: https://github.com/opendatakit/collect/issues/387

like image 2
kc ochibili Avatar answered Oct 27 '22 08:10

kc ochibili


if you already added multidex in both gradle and manifest then try to disable instant run and then create apk to test, i was facing same issue and searched a lot and tried every solution but at last this solved my problem

like image 1
Muhammad Natiq Avatar answered Oct 27 '22 08:10

Muhammad Natiq


Solved:

Step 1: create MyApp class as follows:

public class MyApp extends Application {

@Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this); // this is the key code
    }
}

Step 2: Add the name property to the app in the manifest as follows:

<application
        android:name=".MyApplication">
like image 1
Basil Rawa Avatar answered Oct 27 '22 06:10

Basil Rawa