应用程序在模拟器中确定,但在设备中崩溃

时间:2012-07-11 00:21:16

标签: android android-emulator admob

我有一个小问题,我无法自己解决。 当我在模拟器中启动应用程序时,它工作正常,但当我尝试在设备(SE X10和Galaxy ACE)上启动它时,应用程序运行2秒钟并崩溃。 我认为这是adMob问题但是......

这是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

3 个答案:

答案 0 :(得分:1)

看到/127.0.0.1:80?从你试图连接到localhost的东西的外观来看,这在设备的上下文中就是它自己。

Android设备可能没有运行网络服务器,因此看起来您错误配置了广告服务。

答案 1 :(得分:0)

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

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

答案 2 :(得分:0)

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