2
AndroidRuntime(1109): java.lang.NoClassDefFoundError: sun.misc.BASE64Decoder 

I am running into this error when attempting to use a component jar that depends on the BouncyCastle encryption library. This same component jar is used without any error in a Java Servlet application so I am very confused. I have the same jar references in my Android app that I do for the web application sans the web specific ones.

Please help!

EDIT

For the record, the jar is in the build path AND the export. It's now the first item in the export and I still get the error.

enter image description here

Let me reiterate that this SAME library works fine in a Java Serlvet application.

Roy Hinkley
  • 10,111
  • 21
  • 80
  • 120
  • do not put tags in subject: http://meta.stackexchange.com/questions/19190/should-questions-include-tags-in-their-titles – Marcin Orlowski Nov 21 '12 at 15:36
  • 1
    sun.misc.* aint meant for public use. Couldnt you change it to some other base64 decoder? – Tarun Nov 21 '12 at 16:32
  • The problems seems similar to the one in http://stackoverflow.com/questions/13121954/maven-cant-compile-class-witch-depends-on-rt-jar/13122073 . Consider using another Base64 implementation, e.g. the one from Apache Commons. The Android Java runtime might not contain the classes in the sun.* packages. – Henrik Aasted Sørensen Nov 29 '12 at 11:32

5 Answers5

0

Did you add the jar file into your Java Build Path? If it's added but still does not work, go to "Order and Export" and check the mark of the file and rebuild the project, see it helps.

Neil
  • 448
  • 2
  • 8
  • Yes the jar is in the build path. And, it's near the top of the export list. In fact, it's farther up the export stack than in the web app. – Roy Hinkley Nov 21 '12 at 15:43
0

Make sure your jar is exported in Project properties > Java build bath > Order and export

sdabet
  • 18,360
  • 11
  • 89
  • 158
0

There are only three reasons you will ever get this error:

  1. The class genuinely doesn't exist. If you are using code from an official example and getting this, make sure you have the latest build of the library
  2. You have not added the jar to your build path. To fix this, right click on the jar in Eclipse, and do Build Path ► Add to Build Path.
  3. Your jar is not in the /libs folder. This happens when you have added the jar to the build path, but newer versions of ADT need it to be in /libs. Put it there and re-add it to the build path.

Mostly, such errors occur because newer versions of the ADT require all external jars to be in the `/libs folder. Your colleague was probably on a different version than you, and hence the error.

Raghav Sood
  • 81,899
  • 22
  • 187
  • 195
  • Not sure what libs folder you mean? – Roy Hinkley Nov 21 '12 at 15:46
  • There should be a libs folder in your Android project root in which all your jar files must go. They will not compile into the app otherwise. – Raghav Sood Nov 21 '12 at 15:47
  • I don't have a libs folder in ANY of my Android projects - I do have an Android dependecies folder though. – Roy Hinkley Nov 21 '12 at 15:48
  • You will have to create it then. It doesn't exist by default – Raghav Sood Nov 21 '12 at 15:48
  • Are you confusing the question? My issue is with the Android side, not the web app. – Roy Hinkley Nov 21 '12 at 15:50
  • It's not mandatory to have your jar in the libs folder as long as it is checked in the "Order and export" tab. But I think all jars in the libs folder are exported automatically – sdabet Nov 21 '12 at 15:51
  • I'm not confusing the question. In the Android app, it is mandatory ADT 17 onwards to have all Jars in the /libs folder. Before that they could be in any folder. – Raghav Sood Nov 21 '12 at 15:52
  • Okay, this is new to the latest versions of ADT that I was not aware of. I will look into this change - thank you!!! As for this particular issue, I don't believe that is the problem. – Roy Hinkley Nov 22 '12 at 00:51
0

If you get NoClassDefFoundError during Runtime, then I suspect you did not include your to work at runtime. You have to check the checkbox for each .jar like this:

enter image description here

Ahmad
  • 69,608
  • 17
  • 111
  • 137
0

I resolved the issue - details are found in this SO posting.

Community
  • 1
  • 1
Roy Hinkley
  • 10,111
  • 21
  • 80
  • 120