Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ClassNotFoundException: Didn't find class on path: DexPathList

I have a problem since I updated my App on playstore. Since this update, the exception is thrown, but I haven´t changed anything related to this exception.

Stacktrace:

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{de.opiatefuchs.onthejobtimerlight/de.opiatefuchs.onthejobtimerlight.OnTheJobTimerActivity}: java.lang.ClassNotFoundException: Didn't find class "de.opiatefuchs.onthejobtimerlight.OnTheJobTimerActivity" on path: DexPathList[[zip file "/data/app/de.opiatefuchs.onthejobtimerlight-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2236)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.ClassNotFoundException: Didn't find class "de.opiatefuchs.onthejobtimerlight.OnTheJobTimerActivity" on path: DexPathList[[zip file "/data/app/de.opiatefuchs.onthejobtimerlight-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
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.Instrumentation.newActivity(Instrumentation.java:1066)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2226)
... 10 more
Suppressed: java.lang.ClassNotFoundException: de.opiatefuchs.onthejobtimerlight.OnTheJobTimerActivity
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 13 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

The thing is, my App version before runs without problems and I haven´t changed anything related to this activity. I´ve just added a new info dialog that has nothing to do with this activity. This app is a free lite version, I´ve made the exact same changes on the pro version and there nothing is thrown. This works as expected. The only difference between pro and lite is, I have integrated Admob (on the new way) in the lite version and Google Play license in the pro version. But this I have integrated since the beginning and haven´t made changes to this. I also haven´t made any changes to the manifest, I read many posts here but nothing helps.

It seems that it just happen on Android versions since 5.0 . Has anybody an idea what this problem could cause or has anybody the same experiences? Is it possible that proguard just destroyed anything by obfuscating (also here, no changes)?

I posted no code, because it is not important to this problem, like I said I haven´t made changes related to this exception.

This Question is marked as duplicate but it isn´t. The comment with the link doesn´t fix my problem, all libraries are checked and integrated in the right way. Also, I don´t use NDK.

like image 410
Opiatefuchs Avatar asked Apr 23 '15 07:04

Opiatefuchs


2 Answers

Update

After a long time, It turned out that it must have anything to do with proguard. I can´t really say what exactly the error causes, but I tried a little bit and that´s what I noticed (that´s in my case with Eclipse IDE):

  • I have to close every tab from the project I want to sign
  • I have to clean the project and after cleaning, do nothing but export the apk
  • making a small change in manifest, save it and undo the change (and save)
  • if there is any class in manifest named with "YourClass" or ".YourClass", change it to "com.yourpackage.yourClass"

That are the four points I have done and then it worked. This looks suspicious, but I think there is a problem with obfuscating. Because without doing these points, I can simply compile my apk and install it from eclipse. For me, there is no obvious reason for this behavior. Also the package name does work without a change if I only install it from eclipse. I hope these points can help somebody.

like image 116
Opiatefuchs Avatar answered Nov 20 '22 07:11

Opiatefuchs


If you manifest package name is ok, If you clossed the project, and within file explorer renamed your project but after importing one you again encounter this problem the only way here is to

DELETE THAT FOLDER .gradle.

This one can be found in project folder using file explorer. It has artifact files that contain that old project's name. After you reopen the project in Android Studio the folder will be recreated automatically.

like image 17
CodeToLife Avatar answered Nov 20 '22 06:11

CodeToLife