I have come across a strange error. I have an Android project that uses external libraries, in particular:
The project ran fine until I updated some aspects of the plugin (can't recall the specifics as I did not pay too much attention to it) and after that, whenever I try to use any class from the above .jar files (or any of its subclasses, even ones defined by me), I would get a java.lang.NoClassDefFoundError. I could not find the answer after much searching, so I am really stumped.
I believe this problem is related to how my IDE is set up and it has little to do with actual code, so I will not post any unless if it's absolutely necessary.
You need to read this - Dealing with dependencies in Android projects.
This link is also useful - ClassDefNotFoundError with ADT 17
Basically, create a folder called libs
and place all of your jar
files inside. The recent update will automatically take care of the rest for you. You don't need to edit your path anymore.
Android does not support Java1.7 up to now. Jars built with compliance level 1.7 cannot be used in Android Applications. Rebuild your Java project with compliance level 5.0 or 6.0 before exporting the jar file.
I found this post via google and answers above didn't solve my problem. Hope what I say will be helpful to others.
If you see NoClassDefFoundError
after upgrading to ADT 22, try this in Eclipse:
Also a warning to others who have updated to r17 with many dependencies. I had a another referenced project on my build path and it still did not work after following ALL the directions on this r17 issue on the internet.
Found out after an hour that my referenced project used an older version of an external Jar than my main project did. When trying to compile the main project, Eclipse would give up due to this jar version difference and I never noticed the warning message in Console.
Solution was to copy the newer version external jar file to the referenced project's libs directory.
Wow - such a productivity killer.....
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