java.lang.ClassNotFoundException: Didn't find class on path: DexPathList , After updating sdk
Asked Answered
S

5

7

Hello guys My application was all working fine till yesterday, i updated my SDK yesterday and it started giving error first it gave an error

No resource found at values v24 ....

some thing like this i searched and solved it by changing following lines in build.gradle

compileSdkVersion 25
buildToolsVersion '25.0.2'

now that error is gone and It is running completely fine in higher android version 7.1.1 but when i run in lower version of android it is giving following error

E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: com.wowio.ebookreader, PID: 15469
                  java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.wowio.ebookreader/com.eminosoft.ebookread.activity.SplashScreenActivity}: java.lang.ClassNotFoundException: Didn't find class "com.eminosoft.ebookread.activity.SplashScreenActivity" on path: DexPathList[[zip file "/data/app/com.wowio.ebookreader-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.wowio.ebookreader-1, /vendor/lib, /system/lib]]
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2378)
                      at android.app.ActivityThread.access$800(ActivityThread.java:155)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1244)
                      at android.os.Handler.dispatchMessage(Handler.java:102)
                      at android.os.Looper.loop(Looper.java:136)
                      at android.app.ActivityThread.main(ActivityThread.java:5433)
                      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:1268)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
                      at dalvik.system.NativeStart.main(Native Method)
                   Caused by: java.lang.ClassNotFoundException: Didn't find class "com.eminosoft.ebookread.activity.SplashScreenActivity" on path: DexPathList[[zip file "/data/app/com.wowio.ebookreader-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.wowio.ebookreader-1, /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:1068)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2186)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2378) 
                      at android.app.ActivityThread.access$800(ActivityThread.java:155) 
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1244) 
                      at android.os.Handler.dispatchMessage(Handler.java:102) 
                      at android.os.Looper.loop(Looper.java:136) 
                      at android.app.ActivityThread.main(ActivityThread.java:5433) 
                      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:1268) 
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084) 
                      at dalvik.system.NativeStart.main(Native Method) 

I have already tried following things

1.Clean project

2.invalidate cache /restart

3.The deletion of app on device

already looked at these questions Question 1 , Question 2 nothing worked . How can i fix this issue?

if you need any thing i will update it in question

my build.gradle file

 apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.2'

    defaultConfig {
        applicationId "com.wowio.ebookreader"
        minSdkVersion 14
        targetSdkVersion 23
        multiDexEnabled true

    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }
}

dependencies {

    compile 'com.android.support:appcompat-v7:+'
    compile 'com.google.android.gms:play-services:+'
    compile 'com.android.support:multidex:1.0.1'
     // the are many more dependencies i removed to decrease size

    }
Socorrosocotra answered 5/1, 2017 at 6:18 Comment(1)
If you are using Cleanmaster or similar apps on your device, try uninstalling itEnneahedron
S
4

Write a class EnableMultiDex like below

public class EnableMultiDex extends MultiDexApplication {
    private static EnableMultiDex enableMultiDex;
    public static Context context;

    public EnableMultiDex(){
        enableMultiDex=this;
    }

    public static EnableMultiDex getEnableMultiDexApp() {
        return enableMultiDex;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        context = getApplicationContext();

    }
}

and in AndroidManifest.xml write this class inside Application tag

 <application
    android:name="YourPakageName.EnableMultiDex"
    android:hardwareAccelerated="true"
    android:icon="@drawable/launch_logo"
    android:label="@string/app_name"
    android:largeHeap="true"
    tools:node="replace">
Socorrosocotra answered 5/1, 2017 at 7:21 Comment(1)
This requires extending Application class.Assimilable
B
4

Yes may be above answer is correct I did not try as it is. But I resolved in opposite way is "You remove the instant run option in the settings of android studio"

Go to --> file menu --> select settings --> select build,execution,deployment-->select instant run --> un check the "enable instant run".

It was worked for me. but some applications like google maps integrated apps required Instant run.

Beholden answered 15/5, 2017 at 15:3 Comment(1)
Thank you so much. It works for me after disabling the Instant Run. It took whole day to solve this issue.Anecdotic
B
2

In my case my project began to work again after:

  • Uninstall my project from the emulator (or real device)
  • Clean Project
  • Make Project
Bondsman answered 7/9, 2017 at 14:41 Comment(0)
A
0

Same error happened to me because I installed the debug apk that created inside outputs\apk folder and it turns to be smaller and with missing classes because it probably was the outcome of an instant run. So instead of turning instant run off just build APK (by Build->build apk in the menu) and use this one.

Anomalistic answered 22/6, 2017 at 9:45 Comment(0)
L
0

Disable instant run worked for me I think this issue occurs because some class is missing when build with install run ( reduce apk size)

Lithuanian answered 13/9, 2017 at 3:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.