Reputation:
I'm trying to use Simple XML to convert my java objects to XML format in my Android application.
I'm getting NoClassDefFoundError at line
Serializer serializer = new Persister();
java.lang.NoClassDefFoundError: org.simpleframework.xml.core.Persister
I have simple-xml-2.6.1.jar
in project class path and when I got NoClassDefFoundError
I also put these 3 jars in classpath
stax-1.2.0.jar
stax-api-1.0.1.jar
xpp3-1.1.3_8.jar
but made no use.
Still having NoClassDefFoundError
.
Any kind of help will be appreciated.Thank you.
Upvotes: 14
Views: 7255
Reputation: 1
It's little strange, but this works for me.
Serializer serializer;
Persister persiter = new Persister();
serializer = persiter;
Upvotes: 0
Reputation: 377
I resolved same problem like yours modifying Java Build path.
I installed Android DDMS 17.0.0.v201203161636-291853
today and NoClassDefFoundError
appeared.
How to fix -> Check check box against simple-xml
dependency and give it higher priority than yourproject/src/main/java
Upvotes: 6
Reputation: 38238
Do you have Simple XML checked under "Order and Export" in the Build Path configuration?
I just ran across this problem after updating to the latest SDK
and Eclipse plugins for Android, having been successfully using Simple for months.
For some reason, after the update, I had to go and:
simple-xml-2.6.2.jar
under "Order and Export"After those two steps, the problem went away.
Upvotes: 21
Reputation: 1401
You don't need those three other jars in your classpath.
Make sure your classpath looks like this and that you puth the jar file in the lib folder (for conventions sake):
Add the library to the build path
Upvotes: 2
Reputation: 2348
when you deploy your app to your device (or emulator) do you get any errors about the jar that you are trying to include? Not all jars will work on Android. Older code may present a problem You may need to get source and recompile the jar you are interested in. This ensures that the bytecode is compatible with Android. I got this error before with some jars, that said they worked for me even with the errors. They were also xml related (not SimpleXML).
Upvotes: 0
Reputation: 23596
you got this error because might be you do not have declare any of your Activity in to the manifest file. So please add it into your manifest file as like below:
<activity android:name=".DatabaseActivity"></activity>
here DatabaseActivity is my Activity of the application. try it.
Upvotes: 0