よろしくお願いします。
今回AndroidStudioでTwitterのアプリを開発しようと思い、Twitter4jを使い開発していました。認証まではしっかりと行えたのですが、そこに”test”という文字列を検索しようと思いコードを追加するとアプリが落ちてしまいます。自分でも調べてみたのですがなかなか原因がわからないので銅かよろしくお願いします。
アプリの全体像としてはツイート全体に検索をかけヒットした直近のものを表示するものを作りたいです。
ベースのソースコードはこちらを参考に制作いたしました。
java
1public class MainActivity extends AppCompatActivity { 2 3 @Override 4 protected void onCreate(Bundle savedInstanceState) { 5 super.onCreate(savedInstanceState); 6 setContentView(R.layout.activity_main); 7 8 if (!TwitterUtils.hasAccessToken(this)){ 9 Intent intent = new Intent(this, TwitterOAuthActivity.class); 10 startActivity(intent); 11 finish(); 12 } 13 14 Twitter twitter = new TwitterFactory().getInstance(); 15 Query query = new Query(); 16 query.setQuery("test"); 17 18 try { 19 QueryResult result = twitter.search(query); 20 TextView tv = (TextView) this.findViewById(R.id.textView); 21 tv.setText( "Hit:" + result.getTweets().size() ); 22 } catch (TwitterException e){ 23 24 } 25 } 26}
エラー文は以下の通りです。
11-11 16:35:44.261 24742-24742/? D/dalvikvm: Late-enabling CheckJNI
11-11 16:35:44.311 24742-24742/com.example.yuki.twitter_test1 D/HyLog: I : /data/font/config/sfconfig.dat, No such file or directory (2)
11-11 16:35:44.311 24742-24742/com.example.yuki.twitter_test1 D/HyLog: I : /data/font/config/dfactpre.dat, No such file or directory (2)
11-11 16:35:44.311 24742-24742/com.example.yuki.twitter_test1 D/HyLog: I : /data/font/config/sfconfig.dat, No such file or directory (2)
11-11 16:35:44.351 24742-24742/com.example.yuki.twitter_test1 W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
11-11 16:35:44.351 24742-24742/com.example.yuki.twitter_test1 I/dalvikvm: Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.internal.view.WindowCallbackWrapper.onSearchRequested
11-11 16:35:44.351 24742-24742/com.example.yuki.twitter_test1 W/dalvikvm: VFY: unable to resolve interface method 14486: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
11-11 16:35:44.351 24742-24742/com.example.yuki.twitter_test1 D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
11-11 16:35:44.351 24742-24742/com.example.yuki.twitter_test1 I/dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.internal.view.WindowCallbackWrapper.onWindowStartingActionMode
11-11 16:35:44.351 24742-24742/com.example.yuki.twitter_test1 W/dalvikvm: VFY: unable to resolve interface method 14490: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
11-11 16:35:44.351 24742-24742/com.example.yuki.twitter_test1 D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
11-11 16:35:44.431 24742-24742/com.example.yuki.twitter_test1 I/dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
11-11 16:35:44.431 24742-24742/com.example.yuki.twitter_test1 W/dalvikvm: VFY: unable to resolve virtual method 412: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
11-11 16:35:44.431 24742-24742/com.example.yuki.twitter_test1 D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
11-11 16:35:44.431 24742-24742/com.example.yuki.twitter_test1 I/dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
11-11 16:35:44.431 24742-24742/com.example.yuki.twitter_test1 W/dalvikvm: VFY: unable to resolve virtual method 434: Landroid/content/res/TypedArray;.getType (I)I
11-11 16:35:44.431 24742-24742/com.example.yuki.twitter_test1 D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
11-11 16:35:44.491 24742-24742/com.example.yuki.twitter_test1 D/AndroidRuntime: Shutting down VM
11-11 16:35:44.491 24742-24742/com.example.yuki.twitter_test1 W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x4179ce48)
11-11 16:35:44.491 24742-24742/com.example.yuki.twitter_test1 E/AndroidRuntime: FATAL EXCEPTION: main
11-11 16:35:44.491 24742-24742/com.example.yuki.twitter_test1 E/AndroidRuntime: Process: com.example.yuki.twitter_test1, PID: 24742
11-11 16:35:44.491 24742-24742/com.example.yuki.twitter_test1 E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.yuki.twitter_test1/com.example.yuki.twitter_test1.MainActivity}: java.lang.IllegalStateException: Authentication credentials are missing. See http://twitter4j.org/en/configuration.html for details
11-11 16:35:44.491 24742-24742/com.example.yuki.twitter_test1 E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2200)
11-11 16:35:44.491 24742-24742/com.example.yuki.twitter_test1 E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250)
11-11 16:35:44.491 24742-24742/com.example.yuki.twitter_test1 E/AndroidRuntime: at android.app.ActivityThread.access$800(ActivityThread.java:139)
11-11 16:35:44.491 24742-24742/com.example.yuki.twitter_test1 E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1200)
11-11 16:35:44.491 24742-24742/com.example.yuki.twitter_test1 E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
11-11 16:35:44.491 24742-24742/com.example.yuki.twitter_test1 E/AndroidRuntime: at android.os.Looper.loop(Looper.java:136)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2015/11/21 09:25