Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"ClassNotFoundException: Didn't find class on path DexPathList" on API 19

Tags:

android

api

I am making an Android app with targeted SDK version 24 and minimum version 19. It's working fine on the higher API levels but when trying to run it on API level 19 it crashes with the following error:

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{se.android/se.android.SplashScreenActivity}: java.lang.ClassNotFoundException: Didn't find class "se.android.SplashScreenActivity" on path: DexPathList[[zip file "/data/app/se.android-2.apk"],nativeLibraryDirectories=[/data/app-lib/se.android-2, /vendor/lib, /system/lib]]
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
                  at android.app.ActivityThread.access$800(ActivityThread.java:135)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
                  at android.os.Handler.dispatchMessage(Handler.java:102)
                  at android.os.Looper.loop(Looper.java:136)
                  at android.app.ActivityThread.main(ActivityThread.java:5017)
                  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:779)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                  at dalvik.system.NativeStart.main(Native Method)
               Caused by: java.lang.ClassNotFoundException: Didn't find class "se.android.SplashScreenActivity" on path: DexPathList[[zip file "/data/app/se.android-2.apk"],nativeLibraryDirectories=[/data/app-lib/se.android-2, /vendor/lib, /system/lib]]
                  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.newActivity(Instrumentation.java:1061)
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
                  at android.app.ActivityThread.access$800(ActivityThread.java:135) 
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
                  at android.os.Handler.dispatchMessage(Handler.java:102) 
                  at android.os.Looper.loop(Looper.java:136) 
                  at android.app.ActivityThread.main(ActivityThread.java:5017) 
                  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:779) 
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
                  at dalvik.system.NativeStart.main(Native Method) 

The activity in question is set up in the manifest file:

<activity
        android:name=".SplashScreenActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:theme="@style/Theme.AppCompat.NoActionBar">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

</activity>

I have tried changing which activity the app starts on but that doesn't work either. Multidex is enabled in the gradle settings.

I have tried cleaning it and reloading it from the repository but it just won't work.

like image 890
Henrik Ottehall Avatar asked Nov 08 '16 14:11

Henrik Ottehall


2 Answers

I finally managed to solve the problem. Turned out that while I had enabled MultiDex in the gradle settings with

defaultConfig {
   multiDexEnabled true
   ...
}

and imported the MultiDex library with

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

I had forgotten to add it in the AndroidManifest.xml with

<application
   ...
   android:name="android.support.multidex.MultiDexApplication"
   ...
>
   ...
</application>

After adding that part it now works on API level 19.

like image 95
Henrik Ottehall Avatar answered Sep 28 '22 04:09

Henrik Ottehall


use following code in your gradle file.

defaultConfig {
   multiDexEnabled true
   ...
}

and depenencies

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

then syc your project.

like image 21
Surbhi Sharma Avatar answered Sep 28 '22 03:09

Surbhi Sharma