Reputation: 855
I have been following this tutorial
I entered these details for the consumer_key and the consumer_secret
public class Constants {
public static final String CONSUMER_KEY = "<FILL IN YOUR CONSUMER KEY FROM TWITTER HERE>";
public static final String CONSUMER_SECRET= "<FILL IN YOUR CONSUMER SECRET FROM TWITTER HERE>";
public static final String REQUEST_URL = "http://api.twitter.com/oauth/request_token";
public static final String ACCESS_URL = "http://api.twitter.com/oauth/access_token";
public static final String AUTHORIZE_URL = "http://api.twitter.com/oauth/authorize";
public static final String OAUTH_CALLBACK_SCHEME = "x-oauthflow-twitter";
public static final String OAUTH_CALLBACK_HOST = "callback";
public static final String OAUTH_CALLBACK_URL = OAUTH_CALLBACK_SCHEME + "://" + OAUTH_CALLBACK_HOST;
}
I then added the lib directory .classpath also a text document with this path .gitignore
This allowed the files to be recognized the new library files that I had added.
Here is my error log
05-28 21:10:10.586: E/dalvikvm(538): Could not find class 'twitter4j.http.AccessToken', referenced from method alex.android.twitter.feed.TwitterUtils.isAuthenticated
05-28 21:10:10.586: W/dalvikvm(538): VFY: unable to resolve new-instance 67 (Ltwitter4j/http/AccessToken;) in Lalex/android/twitter/feed/TwitterUtils;
05-28 21:10:10.596: D/dalvikvm(538): VFY: replacing opcode 0x22 at 0x0010
05-28 21:10:10.596: E/dalvikvm(538): Could not find class 'twitter4j.http.AccessToken', referenced from method alex.android.twitter.feed.TwitterUtils.sendTweet
05-28 21:10:10.596: W/dalvikvm(538): VFY: unable to resolve new-instance 67 (Ltwitter4j/http/AccessToken;) in Lalex/android/twitter/feed/TwitterUtils;
05-28 21:10:10.606: D/dalvikvm(538): VFY: replacing opcode 0x22 at 0x0010
05-28 21:10:10.606: D/dalvikvm(538): DexOpt: unable to opt direct call 0x006c at 0x12 in Lalex/android/twitter/feed/TwitterUtils;.isAuthenticated
05-28 21:10:10.606: D/dalvikvm(538): DexOpt: unable to opt direct call 0x006a at 0x17 in Lalex/android/twitter/feed/TwitterUtils;.isAuthenticated
05-28 21:10:10.606: D/dalvikvm(538): DexOpt: unable to opt direct call 0x006c at 0x12 in Lalex/android/twitter/feed/TwitterUtils;.sendTweet
05-28 21:10:10.606: D/dalvikvm(538): DexOpt: unable to opt direct call 0x006a at 0x17 in Lalex/android/twitter/feed/TwitterUtils;.sendTweet
05-28 21:10:10.606: D/AndroidRuntime(538): Shutting down VM
05-28 21:10:10.616: W/dalvikvm(538): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
05-28 21:10:10.636: E/AndroidRuntime(538): FATAL EXCEPTION: main
05-28 21:10:10.636: E/AndroidRuntime(538): java.lang.NoClassDefFoundError: twitter4j.http.AccessToken
05-28 21:10:10.636: E/AndroidRuntime(538): at alex.android.twitter.feed.TwitterUtils.isAuthenticated(TwitterUtils.java:17)
05-28 21:10:10.636: E/AndroidRuntime(538): at alex.android.twitter.feed.TwitterActivity.updateLoginStatus(TwitterActivity.java:74)
05-28 21:10:10.636: E/AndroidRuntime(538): at alex.android.twitter.feed.TwitterActivity.onResume(TwitterActivity.java:70)
05-28 21:10:10.636: E/AndroidRuntime(538): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1154)
05-28 21:10:10.636: E/AndroidRuntime(538): at android.app.Activity.performResume(Activity.java:4539)
05-28 21:10:10.636: E/AndroidRuntime(538): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2434)
05-28 21:10:10.636: E/AndroidRuntime(538): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2472)
05-28 21:10:10.636: E/AndroidRuntime(538): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1986)
05-28 21:10:10.636: E/AndroidRuntime(538): at android.app.ActivityThread.access$600(ActivityThread.java:123)
05-28 21:10:10.636: E/AndroidRuntime(538): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-28 21:10:10.636: E/AndroidRuntime(538): at android.os.Handler.dispatchMessage(Handler.java:99)
05-28 21:10:10.636: E/AndroidRuntime(538): at android.os.Looper.loop(Looper.java:137)
05-28 21:10:10.636: E/AndroidRuntime(538): at android.app.ActivityThread.main(ActivityThread.java:4424)
05-28 21:10:10.636: E/AndroidRuntime(538): at java.lang.reflect.Method.invokeNative(Native Method)
05-28 21:10:10.636: E/AndroidRuntime(538): at java.lang.reflect.Method.invoke(Method.java:511)
05-28 21:10:10.636: E/AndroidRuntime(538): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-28 21:10:10.636: E/AndroidRuntime(538): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-28 21:10:10.636: E/AndroidRuntime(538): at dalvik.system.NativeStart.main(Native Method)
Upvotes: 0
Views: 1567
Reputation: 311
I also faced same problem in my project. I changed the folder name lib to libs then it worked fine for me.
This problem is due to the fact that libraries are not managed the same way with the new ADT build.
Upvotes: 1
Reputation: 832
A NoClassDefFoundError means that one of your libraries is depending on another library which couldn't be found. If you don't put all the correct libraries in your classpath this error will most likely show up.
For example, when the twitter library uses the slf4j library for logging, but you haven't included it in the classpath, this error will appear.
Also next time when you post, make sure to put the full error log. Just 1 line isn't much help
Upvotes: 0