Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android java.lang.NoClassDefFoundError

I have an Android project in eclipse IDE which was working. After some imports and tests, I get the error: java.lang.NoClassDefFoundError.

In my project I have two packages: the main one and the second one with some classes.

When I try to instantiate an object from the second package class in the main activity class, I am getting this error.

Here is the logcat:

FATAL EXCEPTION: main java.lang.NoClassDefFoundError: com.neurospeech.wsclient.MDPIforEditorialBoard at milos.mdpi.Journals.<init>(Journals.java:41) at java.lang.Class.newInstanceImpl(Native Method) at java.lang.Class.newInstance(Class.java:1409) at android.app.Instrumentation.newActivity(Instrumentation.java:1040) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1777) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1893) at android.app.ActivityThread.access$1500(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1054) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:150) at android.app.ActivityThread.main(ActivityThread.java:4389) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607) at dalvik.system.NativeStart.main(Native Method) 

Found the solution to my problem:

The solution can be found here: http://android.foxykeep.com/dev/how-to-fix-the-classdefnotfounderror-with-adt-17

like image 557
Milos Cuculovic Avatar asked Mar 26 '12 11:03

Milos Cuculovic


People also ask

How do I fix Java Lang NoClassDefFoundError?

lang. NoClassDefFoundError, which means the Class Loader file responsible for dynamically loading classes can not find the . class file. So to remove this error, you should set your classpath to the location where your Class Loader is present.

Why am I getting a NoClassDefFoundError in Java?

The NoClassDefFoundError is a runtime error in Java that occurs if the Java Virtual Machine (JVM) or a ClassLoader instance attempts to load the definition of a class that could not be found. The class definition exists at compile-time but is not available at runtime.

Is a Java Lang NoClassDefFoundError?

java. lang. NoClassDefFoundError is runtime error thrown when a required class is not found in the classpath and hence JVM is unable to load it into memory.

Can we catch NoClassDefFoundError in Java?

In the case of NoClassDefFoundError, the class was present at compile time, but Java runtime could not find it in Java classpath during runtime.


2 Answers

Did you recently updated your eclipse android plugin (adt r17)? Then the following link might help:

How to fix the classdefnotfounderror with adt-17

Update: One year has passed since the question arose. I will keep the link, because even in 2013 it seem to help some people to solve the problem. But please take care what you are doing, see Erics comment below. Current ADT-Version is 22, I recommend using the most current version.

like image 177
Minsky Avatar answered Oct 04 '22 13:10

Minsky


Edit the build path in this order, this worked for me.

Make sure the /gen is before /src

enter image description here

like image 32
ASP Avatar answered Oct 04 '22 13:10

ASP