{"id":1438,"date":"2022-08-30T15:16:32","date_gmt":"2022-08-30T15:16:32","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/16\/twitter4j-androidruntime446-java-lang-noclassdeffounderror-twitter4j-http-accesstoken-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:16:32","modified_gmt":"2022-08-30T15:16:32","slug":"twitter4j-androidruntime446-java-lang-noclassdeffounderror-twitter4j-http-accesstoken-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/twitter4j-androidruntime446-java-lang-noclassdeffounderror-twitter4j-http-accesstoken-collection-of-common-programming-errors\/","title":{"rendered":"twitter4j =&gt; AndroidRuntime(446): java.lang.NoClassDefFoundError: twitter4j.http.AccessToken-Collection of common programming errors"},"content":{"rendered":"<p>I am trying to use twitter4j for my app to connect and post to twitter. I am following this tutorial. I have downloaded the example project from here and try to run it on <code>android 2.3.3<\/code>. I am sure that i have modified <code>Constants.java<\/code> file correctly according to my twitter developer website. In <code>TwitterUtils.java<\/code> i have enter <code>OAUTH_TOKEN<\/code> and <code>OAUTH_TOKEN_SECRET<\/code> also. but after running it, i got following error messages :<\/p>\n<pre><code>&gt; E\/dalvikvm(374): Could not find class 'twitter4j.http.AccessToken', referenced from method com.ecs.android.sample.twitter.TwitterUtils.isAuthenticated\n\n&gt;W\/dalvikvm(374): VFY: unable to resolve new-instance 67 (Ltwitter4j\/http\/AccessToken;) in Lcom\/ecs\/android\/sample\/twitter\/TwitterUtils;\n\n&gt;D\/dalvikvm(374): VFY: replacing opcode 0x22 at 0x0010\n\n&gt;D\/dalvikvm(374): VFY: dead code 0x0012-002f in Lcom\/ecs\/android\/sample\/twitter\/TwitterUtils;.isAuthenticated (Landroid\/content\/SharedPreferences;)Z\n\n&gt;E\/dalvikvm(374): Could not find class 'twitter4j.http.AccessToken', referenced from method com.ecs.android.sample.twitter.TwitterUtils.sendTweet\n\n&gt;W\/dalvikvm(374): VFY: unable to resolve new-instance 67 (Ltwitter4j\/http\/AccessToken;) in Lcom\/ecs\/android\/sample\/twitter\/TwitterUtils;\n\n&gt;D\/dalvikvm(374): VFY: replacing opcode 0x22 at 0x0010\n\n&gt;D\/dalvikvm(374): VFY: dead code 0x0012-002b in Lcom\/ecs\/android\/sample\/twitter\/TwitterUtils;.sendTweet (Landroid\/content\/SharedPreferences;Ljava\/lang\/String;)V\n\n&gt;D\/AndroidRuntime(374): Shutting down VM\n\n&gt;W\/dalvikvm(374): threadid=1: thread exiting with uncaught exception (group=0x40015560)\n\n&gt;E\/AndroidRuntime(374): FATAL EXCEPTION: main\n\n&gt;E\/AndroidRuntime(374): java.lang.NoClassDefFoundError: twitter4j.http.AccessToken\n\n&gt;E\/AndroidRuntime(374):     at com.ecs.android.sample.twitter.TwitterUtils.isAuthenticated(TwitterUtils.java:18)\n\n&gt;E\/AndroidRuntime(374):     at com.ecs.android.sample.twitter.AndroidTwitterSample.updateLoginStatus(AndroidTwitterSample.java:72)\n\n&gt;E\/AndroidRuntime(374):     at com.ecs.android.sample.twitter.AndroidTwitterSample.onResume(AndroidTwitterSample.java:68)\n\n&gt;E\/AndroidRuntime(374):     at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1150)\n\n&gt;E\/AndroidRuntime(374):     at android.app.Activity.performResume(Activity.java:3832)\n\n&gt;E\/AndroidRuntime(374):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2110)\n\n&gt;E\/AndroidRuntime(374):     at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2135)\n\n&gt;E\/AndroidRuntime(374):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1668)\n\n&gt;E\/AndroidRuntime(374):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)\n\n&gt;E\/AndroidRuntime(374):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)\n\n&gt;E\/AndroidRuntime(374):     at android.os.Handler.dispatchMessage(Handler.java:99)\n\n&gt;E\/AndroidRuntime(374):     at android.os.Looper.loop(Looper.java:130)\n\n&gt;E\/AndroidRuntime(374):     at android.app.ActivityThread.main(ActivityThread.java:3683)\n\n&gt;E\/AndroidRuntime(374):     at java.lang.reflect.Method.invokeNative(Native Method)\n\n&gt;E\/AndroidRuntime(374):     at java.lang.reflect.Method.invoke(Method.java:507)\n\n&gt;E\/AndroidRuntime(374):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)\n\n&gt;E\/AndroidRuntime(374):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)\n\n&gt;E\/AndroidRuntime(374):     at dalvik.system.NativeStart.main(Native Method)\n<\/code><\/pre>\n<p>am not sure if i am wrong, in Constant.java, i haven&#8217;t change anything in<\/p>\n<pre><code>public static final String REQUEST_URL = \"https:\/\/api.twitter.com\/oauth\/request_token\";\n\npublic static final String ACCESS_URL = \"https:\/\/api.twitter.com\/oauth\/access_token\";\n\npublic static final String AUTHORIZE_URL = \"https:\/\/api.twitter.com\/oauth\/authorize\";\n\npublic static final String OAUTH_CALLBACK_SCHEME = \"x-oauthflow-twitter\";\n\npublic static final String OAUTH_CALLBACK_HOST = \"callback\";\n\npublic static final String OAUTH_CALLBACK_URL = OAUTH_CALLBACK_SCHEME + \":\/\/\" + OAUTH_CALLBACK_HOST;\n<\/code><\/pre>\n<p>I have tried changing <code>\"callback\"<\/code> with <code>\"http:\/\/www.MyWebsite.com\"<\/code> Please advice how can I correct these problems.<\/p>\n<ol>\n<li>\n<p>You need to change your Folder name from <code>lib<\/code> to <code>libs<\/code> as you have updated ADT 17.<\/p>\n<p>Checkout this <strong>Article<\/strong> for in detail information on this topic.<\/p>\n<\/li>\n<li>\n<p>In case someone is using ADT 18, I did not have a lib folder at all, I was using Project, Properties, Java Build Path, Libraries tab exclusively. To resolve this issue, I created a libs folder within my project, copied my external jars to this folder, and then removed the references in the Libraries tab. The project rebuilt and worked!<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-16 20:53:09. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I am trying to use twitter4j for my app to connect and post to twitter. I am following this tutorial. I have downloaded the example project from here and try to run it on android 2.3.3. I am sure that i have modified Constants.java file correctly according to my twitter developer website. In TwitterUtils.java i [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1438","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1438","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1438"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1438\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}