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.
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.
use following code in your gradle file.
defaultConfig {
multiDexEnabled true
...
}
and depenencies
{
...
compile 'com.android.support:multidex:1.0.1'
...
}
then syc your project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With