CQM
CQM

Reputation: 44230

NoClassDefFoundError , what is overlooked here? (image attached)

Symptom: I am using a project I pulled from the creator's git repository. I included their libraries, as seen in the libs folder. The project has no errors, the project compiles. Yet when it accesses an object that is supposed to be in the jar it crashes.

I've done some other suggestions that I've read here. I've read something about changing the classpath , where is that?

Also, the src code for the jar shows the object in question as actually existing....

ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();

05-30 11:26:16.878: E/AndroidRuntime(11098): FATAL EXCEPTION: main
05-30 11:26:16.878: E/AndroidRuntime(11098): java.lang.NoClassDefFoundError:      twitter4j.conf.ConfigurationBuilder
05-30 11:26:16.878: E/AndroidRuntime(11098):    at com.pigmal.android.ex.twitter4j.TwitterApp.askOAuth(TwitterApp.java:110)
05-30 11:26:16.878: E/AndroidRuntime(11098):    at com.pigmal.android.ex.twitter4j.TwitterApp.onClick(TwitterApp.java:144)
05-30 11:26:16.878: E/AndroidRuntime(11098):    at android.view.View.performClick(View.java:2482)
05-30 11:26:16.878: E/AndroidRuntime(11098):    at android.view.View$PerformClick.run(View.java:9077)
05-30 11:26:16.878: E/AndroidRuntime(11098):    at android.os.Handler.handleCallback(Handler.java:587)
05-30 11:26:16.878: E/AndroidRuntime(11098):    at a ndroid.os.Handler.dispatchMessage(Handler.java:92)
05-30 11:26:16.878: E/AndroidRuntime(11098):    at android.os.Looper.loop(Looper.java:130)
05-30 11:26:16.878: E/AndroidRuntime(11098):    at android.app.ActivityThread.main(ActivityThread.java:3683)
05-30 11:26:16.878: E/AndroidRuntime(11098):    at java.lang.reflect.Method.invokeNative(Native Method)
05-30 11:26:16.878: E/AndroidRuntime(11098):    at java.lang.reflect.Method.invoke(Method.java:507)
05-30 11:26:16.878: E/AndroidRuntime(11098):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-30 11:26:16.878: E/AndroidRuntime(11098):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-30 11:26:16.878: E/AndroidRuntime(11098):    at dalvik.system.NativeStart.main(Native Method)

This is my complete project setup. The fact that this is using Android is probably not relevant here, I don't want to alienate Java experts by tagging it Android

Upvotes: 2

Views: 2872

Answers (5)

den ix
den ix

Reputation: 102

For me rename the folder, and restarting didn't solve the problem. But, inside a pages with links posted in a previous comment, there is an answer the one who solved my problem. This response says:

If you have references to jars that are not in the ‘libs’ folder, for example if you use ‘classpath variable’, you can resolve the NoClassDefFoundError issue with the new ADT 17 by exporting the references. To export the references: simply go to “Properties > Java Build Path > Order and Export”, and check all the references you want exported.

And i must move twitter jar before src folder

Upvotes: 0

Shahid Pasha
Shahid Pasha

Reputation: 81

I had the same problem, removing all twitter libraries from the build path and renaming the lib folder to libs solved the problem for me

Upvotes: 1

CQM
CQM

Reputation: 44230

This solved it for me http://android.foxykeep.com/dev/how-to-fix-the-classdefnotfounderror-with-adt-17

What I did to fix the bug was :

Remove the libraries from the standard Java build path :
Right click on the project name > Properties > Java Build Path > tab Libraries > remove      everything except the “Android X.X” (2.3.3 in my case) and the “Android Dependencies”
Rename the libraries folder from “lib” to “libs”
By doing that, all the libraries in the folder “libs” are found by the Android plugin and   are added to the “Android Dependencies” item of the project
Restart Eclipse
Android Dependencies should be created. Running the app won't produce NoClassDefFoundError anymore

with the exception being that I had to RESTART ECLIPSE after following these instructions, instead of merely cleaning the project afterwards.

Upvotes: 4

Kumar Vivek Mitra
Kumar Vivek Mitra

Reputation: 33534

Try this, this worked from me.

  1. go to the Build Path, remove the twitter4j libraries, and do Ok.

  2. go to the Build Path, select the Add External Libraries, then go to the project folder which you downloaded from the github, then go to its lib folder, you will find the twitter4j files there, select the twitter4j-core only (but only and only if it still fails include the twitter4j-stream too, until then keep the core only) and do Ok.

Upvotes: 2

Kshitij
Kshitij

Reputation: 8614

I think you better tag android also for this question. I have seen people on earlier posts having similar issues even because of ADT version. Ideally, since you have put your code inside libs folder, you should be able to get all those classes. But this seems to be some runtime issue and not compile time.

Also this seems to be specific to android.


Have you manually added jar in classpath? Normally, when a jar is added in libs folder, it start appearing inside Android Dependencies and not directly as shown in the snapshot.

Upvotes: 0

Related Questions