1

yelp API を Java プロジェクトとして正常に実行できます。
Androidエミュレーターで実行すると、エラーが発生します。私はすべて次のように設定しています: Android での Yelp 統合 私の avd は最新で、Google API パッケージがインストールされています。これらは私のエラーメッセージです。

10-25 15:35:56.686: E/AndroidRuntime(1548): FATAL EXCEPTION: main
10-25 15:35:56.686: E/AndroidRuntime(1548): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.first/com.example.first.MainActivity}: android.os.NetworkOnMainThreadException
10-25 15:35:56.686: E/AndroidRuntime(1548):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at android.app.ActivityThread.access$600(ActivityThread.java:130)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at android.os.Looper.loop(Looper.java:137)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at android.app.ActivityThread.main(ActivityThread.java:4745)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at java.lang.reflect.Method.invokeNative(Native Method)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at java.lang.reflect.Method.invoke(Method.java:511)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at dalvik.system.NativeStart.main(Native Method)
10-25 15:35:56.686: E/AndroidRuntime(1548): Caused by: android.os.NetworkOnMainThreadException
10-25 15:35:56.686: E/AndroidRuntime(1548):     at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at java.net.InetAddress.getAllByName(InetAddress.java:214)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at libcore.net.http.HttpConnection.<init>(HttpConnection.java:70)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:341)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:315)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at libcore.net.http.HttpEngine.connect(HttpEngine.java:310)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:289)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:239)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at org.scribe.model.Response.<init>(Response.java:27)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at org.scribe.model.Request.doSend(Request.java:84)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at org.scribe.model.Request.send(Request.java:59)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at org.scribe.model.OAuthRequest.send(OAuthRequest.java:12)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at com.example.first.Yelp.search(Yelp.java:57)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at com.example.first.MainActivity.onCreate(MainActivity.java:29)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at android.app.Activity.performCreate(Activity.java:5008)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
10-25 15:35:56.686: E/AndroidRuntime(1548):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
4

0 に答える 0