1

I've been searching the internet for two days now, and I feel like I've tried everything. Please let me know if any code snippets might be helpful in finding a solution.

I've created an android application with the standard login activity. In the doInBackground()-method, I invoke a static method from another external class. Since this method will be invoked once the submit button is clicked, the error occurs during runtime. The class is included in my file, and there are no compilation errors. Whenever I tap/click on the Submit-button, I get a java.lang.NoClassDefFoundError referring to a class (in my external jar) that is used and properly included in my external file I refer to in the doInBackground()-method.

All my external libraries are in the 'libs'-folder. I've tried adding them to the build path manually instead and checking the boxes next to them in the 'order and export'-tab instead of the checkbox next to the 'Android Private Libraries' entry. I've tried putting the 'gen'-directory above the 'src'-directory, which didn't change anything either. Restarting eclipse, reimporting the project as a whole, playing around with the order of the external libraries in the build path, fixing project properties and cleaning the project over and over, nothing helped. I've checked this

http://javarevisited.blogspot.de/2011/06/noclassdeffounderror-exception-in.html

and tried every solution, but none of them worked for me. I ad a similar problem with a library before, and I could solve it by changing some build path settings and restarting Eclipse. However, this just doesn't work for me any more. I hope anybody has another solution or an idea, I have no clue what's wrong...

Thank you all in advance!

Yeehaw

Edit:

Despite creating a whole new project and adding my previous files to this new project, I still had the same problem in the new project. I think I figured out where this error came from: When I added my external library, I still had dependencies from the just added .jar to other jars. After adding those as well, the compiler said I needed the java.rmi.Remote class, which is in Java's JRE system library (rt.jar). Adding the whole jre library to my project made the compiler error disappear, the runtime error, however, still persisted. After some more research I found out that my external library is probably not compatible with the android runtime environment, which means that the jar's .class-files don't have an equivalent .dex-representation which is neededfor the Dalvik virtualmachine on android powered devices. For many java jar's, especially those designed for use with the android platform, those problems don't occur.

Please correct me if I'm wrong, but this explanation seemed pretty plausible to me. Too bad, since this is the only way to currently access our database programmatically.

Yeehaw
  • 105
  • 2
  • 11
  • one thing that often happens: folder get named "lib" instead of "libs"....are You sure Your folder is named "libs"? – Opiatefuchs May 31 '13 at 13:16
  • Yes, absolutely. I had to change it some time before already, since I had a different initial activity with another external jar. That's the thing I fixed already because I had the same problem before. – Yeehaw May 31 '13 at 13:18
  • possible duplicate of [Libraries do not get added to APK anymore after upgrade to ADT 22](http://stackoverflow.com/questions/16596969/libraries-do-not-get-added-to-apk-anymore-after-upgrade-to-adt-22) – Selvin May 31 '13 at 13:55
  • @Selvin - I tried as CommonsWare says, still the same error occurs. – Yeehaw May 31 '13 at 14:23

1 Answers1

1

Make sure you've updated to the latest version of ADT Eclipse plugin and SDK Tools and also make sure "Android Dependencies" is checked in your project properties.

enter image description here

Ken Wolf
  • 23,133
  • 6
  • 63
  • 84
  • Thanks Ken, there's an update for the Android SDK tools available, I'll try and see how it goes. I'll keep you updated. – Yeehaw May 31 '13 at 13:14
  • I updated the Android SDK tools, restarted eclipse and rebuilt my project. Still, the same error occurs. How come you don't have the standard java JRE System library entry in your view? Mine was checked, I unchecked it and did the same with 'android 4.2.2'. It's still not working.. – Yeehaw May 31 '13 at 14:15
  • Hmm, I'm not sure what else it could be. Only other thing I can suggest is to start a new Android project from scratch (using the Android New Project Wizard) and do a simple test with this external library and then build that new project up from scratch with your old code. – Ken Wolf May 31 '13 at 14:33
  • Yeah, that would have been my next approach. Would still be nice to know what went wrong. Thanks a lot for your help! – Yeehaw May 31 '13 at 14:36