我一直在关注这个教程
我为 consumer_key 和 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;
}
然后我添加了 lib 目录 .classpath 也是一个带有此路径 .gitignore 的文本文档
这允许文件被识别为我添加的新库文件。
这是我的错误日志
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)