How to solve “ClassNotFoundException : Didn’t find class on path: dexpathlist” error.
A few hours ago i imported several files from another android project.
After long minutes of renaming packages and fixing bugs, i finally start compiling and pressing big ” Build and run ” button to execute our new android project.
As soon as the first screen of our application displayed, our crash occured.
My logcat displayed message like this :
java.lang.ClassNotFoundException: Didn't find class on path: DexPathList [[zip file "/data/app/name_du_package-***==/base.apk" Cobra,nativeLibraryDirectories=
After hours of research on the web and brainstorming i finally found a solution that could solve our problem.
Solution in the next section
Solution for java.lang.ClassNotFoundException: Didn’t find class on path: dexpathlist
Before applying our solution
Before applying the solution that i write on this troubleshoot, make sure you have first tried to apply the following actions:
- Clear your IDE cache by following this command path:
File -> Invalidate Caches / Restart -> Invalidate and Restart
- If the previous test didn’t work, try the following:
Build -> Clean Project
Build -> Rebuild Project
If despite the previous steps, the same error continues to appear, then you can apply our solution:
Our solution to the dexpathlist problem
To resolve the error java.lang.ClassNotFoundException: Didn’t find class on path: dexpathlist i notice one important thing.
The packages contents inside the file mobile.navigation.xml were wrong. I then fixed the names of the packages to resolve the compilation problem.
Now the solution is to check among any xml files (in folder layout ) if there is no error in the package name.
This kind of errors are not automatically detected by android studio until the program crashes in your phone or emulator.
Worse, the package search via android studio did not allow us to find the cause.
If you want to know how i found it, I will say it was instinct and maybe a lot of luck.
The kind of thing that makes you open a file for no reason and BOOM, you find the cause of your problem.