Friday, October 5, 2012

Java :Android : java.lang.NoClassDefFoundError

I have added third party jar file in the project.
At compilation time there is no error but at run time the jar is not loaded and throwing "java.lang.NoClassDefFoundError".

Error in Console:
AndroidRuntime(7549): FATAL EXCEPTION: main
AndroidRuntime(7549): java.lang.NoClassDefFoundError:
AndroidRuntime(7549):     at java.lang.Class.newInstanceImpl(Native Method)
AndroidRuntime(7549):     at java.lang.Class.newInstance(

Right click on the project - properties - Java Build Path - Libraries.
We can add jar files in to the location, where it helps in taking the jar file for the project.

If the project is throwing exception "java.lang.NoClassDefFoundError"then check the box of appropriate jar file in "Project - properties - Java Build Path - order and export".

Clean and Build the project and test.

Libraries. Location of other archive files required by this project.

Order and Export. Order in which projects and libraries appear in the build path and the default runtime classpath; e.g., use classes from a workspace project before using the same classes from an archive library.

Above link is taken from Here

No comments :

Post a Comment