-1

I have a small problem which i couldn't resolve it by myself. When i launch the app in the emulator, it works fine, but when I try to launch it on device ( SE X10, and Galaxy ACE) the app runs for 2 seconds and crashes. I think it's adMob problem but ..

Here is the logcat:

07-11 01:45:05.536: W/Ads(1210): java.net.ConnectException: googleads.g.doubleclick.net/127.0.0.1:80 - Connection refused
07-11 01:45:05.536: W/Ads(1210):    at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:207)
07-11 01:45:05.536: W/Ads(1210):    at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:437)
07-11 01:45:05.536: W/Ads(1210):    at java.net.Socket.connect(Socket.java:983)
07-11 01:45:05.536: W/Ads(1210):    at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:75)
07-11 01:45:05.536: W/Ads(1210):    at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:48)
07-11 01:45:05.536: W/Ads(1210):    at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection$Address.connect(HttpConnection.java:322)
07-11 01:45:05.536: W/Ads(1210):    at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:89)
07-11 01:45:05.536: W/Ads(1210):    at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHttpConnection(HttpURLConnectionImpl.java:294)
07-11 01:45:05.536: W/Ads(1210):    at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.makeConnection(HttpURLConnectionImpl.java:276)
07-11 01:45:05.536: W/Ads(1210):    at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:214)
07-11 01:45:05.536: W/Ads(1210):    at b.a(Unknown Source)
07-11 01:45:05.536: W/Ads(1210):    at b.doInBackground(Unknown Source)
07-11 01:45:05.536: W/Ads(1210):    at android.os.AsyncTask$2.call(AsyncTask.java:185)
07-11 01:45:05.536: W/Ads(1210):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
07-11 01:45:05.536: W/Ads(1210):    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
07-11 01:45:05.536: W/Ads(1210):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
07-11 01:45:05.536: W/Ads(1210):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
07-11 01:45:05.536: W/Ads(1210):    at java.lang.Thread.run(Thread.java:1019)
07-11 01:45:05.536: I/Ads(1210): onFailedToReceiveAd(A network error occurred.)
07-11 01:45:07.826: D/AndroidRuntime(1210): Shutting down VM
07-11 01:45:07.826: W/dalvikvm(1210): threadid=1: thread exiting with uncaught exception (group=0x4001d560)
07-11 01:45:07.856: E/AndroidRuntime(1210): FATAL EXCEPTION: main
07-11 01:45:07.856: E/AndroidRuntime(1210): java.lang.NullPointerException
07-11 01:45:07.856: E/AndroidRuntime(1210):     at com.taiic.template.admob.adMain.updateLocation(adMain.java:94)
07-11 01:45:07.856: E/AndroidRuntime(1210):     at com.taiic.template.admob.adMain$1.onLocationChanged(adMain.java:45)
07-11 01:45:07.856: E/AndroidRuntime(1210):     at android.location.LocationManager$ListenerTransport._handleMessage(LocationManager.java:227)
07-11 01:45:07.856: E/AndroidRuntime(1210):     at android.location.LocationManager$ListenerTransport.access$000(LocationManager.java:160)
07-11 01:45:07.856: E/AndroidRuntime(1210):     at android.location.LocationManager$ListenerTransport$1.handleMessage(LocationManager.java:176)
07-11 01:45:07.856: E/AndroidRuntime(1210):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-11 01:45:07.856: E/AndroidRuntime(1210):     at android.os.Looper.loop(Looper.java:123)
07-11 01:45:07.856: E/AndroidRuntime(1210):     at android.app.ActivityThread.main(ActivityThread.java:3701)
07-11 01:45:07.856: E/AndroidRuntime(1210):     at java.lang.reflect.Method.invokeNative(Native Method)
07-11 01:45:07.856: E/AndroidRuntime(1210):     at java.lang.reflect.Method.invoke(Method.java:507)
07-11 01:45:07.856: E/AndroidRuntime(1210):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
07-11 01:45:07.856: E/AndroidRuntime(1210):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
07-11 01:45:07.856: E/AndroidRuntime(1210):     at dalvik.system.NativeStart.main(Native Method)
07-11 01:45:07.876: I/Process(1210): Sending signal. PID: 1210 SIG: 9
4

3 回答 3

1

看到了/127.0.0.1:80吗?从您尝试连接到本地主机的事物的外观来看,本地主机本身就是设备的上下文。

Android 设备可能没有运行网络服务器,因此您似乎以某种方式错误配置了广告服务。

于 2012-07-11T00:24:20.110 回答
0

确保您在网络线程上执行网络连接。这通常是像您所描述的那样奇怪崩溃的原因。你可以在这里阅读更多关于它的信息。

您应该始终在单独的线程上执行可能长时间运行/昂贵的操作!

于 2012-07-11T00:39:47.327 回答
0

在模拟器上,您可以使用 localhost 连接到您的计算机,但在真实设备上,您应该使用计算机的真实 IP 地址 192.168.1.xxx

于 2012-07-11T00:48:56.360 回答