I am experiencing an error quite often among my users. The app crashes during startup. When the MainActivity is supposed to be loaded the VM apparently cannot find the class
In my case, I was trying to add a normal java class (from a normal java project) compiled with jre 1.7 to an android app project compiled with jre 1.7.
The solution was to recompile that normal java class with jre 1.6 and add references to the android app project (compiled with jre 1.6 also) as usual (in tab order and export be sure to check the class, project, etc).
The same process, when using an android library to reference external normal java classes.
Don't know what's wrong with jre 1.7, when compiling normal java classes from a normal java project and try to reference them in android app or android library projects.
If you don't use normal java classes (from a normal java project) you don't need to downgrade to jre 1.6.
I met NoClassDefFoundError for a class that exists in my project (not a library class). The class exists but i got NoClassDefFoundError. In my case, the problem was multidex support. The problem and solution is here: Android Multidex and support libraries
You get this error for Android versions lower than 5.0.
I fixed this issue by adding library project path in project.propertied manually. some how eclipse did not added this entry automaticvally along with "add project". so the point where app was trying to refer any componenrt inside lib project it was crashing .
you also can try the same thing . app dependecy in projec.properties like
android.library.reference.1=....\android-sdks\extras\google\google_play_services\libproject/google-play-services_lib
and run .
Some time java.lang.NoClassDefFoundError: error appear when use ART instead of Dalvik runtime. To change runtime just go to Developer Option -> Select Runtime -> Dalvik.
I tried all of the above said solutions but did not worked out for me, Here is what i did to get it done project-> config build path-> order and export-> move dependent project on top
For me this problem was related to the API that I was using not being deployed. For example, I used a ZSDK_API.jar
as a reference.
To fix the issue I had to right click on the project and select properties. From JAVA BUILD PATH, I had to add the API that was not being deployed. This was weird as the app was throwing MainActivity class not found and in reality the error was caused by the DiscoveryHandler class not being found.
Hopes this helps someone.