Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
460 views
in Technique[技术] by (71.8m points)

android - AdMob tries to connect at 127.0.0.1 and fails. Always fires onFailedToReceiveAd(A network error occurred.)


AbMob included in my app is working just fine on emulator but on my device i always getting the same:

08-02 01:14:04.862: DEBUG/webviewglue(14152): nativeDestroy view: 0x7b77d0
08-02 01:14:04.862: INFO/Ads(14152): onFailedToReceiveAd(A network error occurred.)
08-02 01:14:05.002: INFO/Ads(14152): Received ad url: <"url": "http://r.admob.com:80/ad_source.php?preqs=617&u_sd=1&slotname=a14e2d89f8911de&u_h=480&u_w=320&msid=xxxxxxxxxxxxxxx.android&js=afma-sdk-a-v4.1.1&isu=061AC563478AB601B8B121B23C3BC875&format=320x50_mb&net=wi&app_name=1.android.xxxxxxxxxxxxxxxxxx.android&u_audio=3&hl=ru&u_so=p&output=html&region=mobile_app&u_tz=-180&ex=1&client_sdk=1&askip=2", "afmaNotifyDt": "null">
08-02 01:14:05.042: WARN/Ads(14152): IOException connecting to ad url.
08-02 01:14:05.042: WARN/Ads(14152): java.net.ConnectException: r.admob.com/127.0.0.1:80 - Connection refused
08-02 01:14:05.042: WARN/Ads(14152):     at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:254)
08-02 01:14:05.042: WARN/Ads(14152):     at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:533)
08-02 01:14:05.042: WARN/Ads(14152):     at java.net.Socket.connect(Socket.java:1055)
08-02 01:14:05.042: WARN/Ads(14152):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:62)
08-02 01:14:05.042: WARN/Ads(14152):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:88)
08-02 01:14:05.042: WARN/Ads(14152):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHTTPConnection(HttpURLConnectionImpl.java:927)
08-02 01:14:05.042: WARN/Ads(14152):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:909)
08-02 01:14:05.042: WARN/Ads(14152):     at b.run(Unknown Source)
08-02 01:14:05.042: WARN/Ads(14152):     at java.lang.Thread.run(Thread.java:1096)
08-02 01:14:05.042: DEBUG/webviewglue(14152): nativeDestroy view: 0x6a97a0
08-02 01:14:05.042: INFO/Ads(14152): onFailedToReceiveAd(A network error occurred.)
08-02 01:14:05.267: WARN/webcore(14152): Can't get the viewWidth after the first layout
08-02 01:14:05.547: INFO/Ads(14152): Received ad url: <"url": "http://r.admob.com:80/ad_source.php?preqs=618&u_sd=1&slotname=a14e2d89f8911de&u_h=480&u_w=320&msid=xxxxxxxxxxxxxxxxxxxxxxxxxx.android&js=afma-sdk-a-v4.1.1&isu=061AC563478AB601B8B121B23C3BC875&format=320x50_mb&net=wi&app_name=1.xxxxxxxxxxxxxxxxxxxxxxxxxx.android&u_audio=3&hl=ru&u_so=p&output=html&region=mobile_app&u_tz=-180&ex=1&client_sdk=1&askip=3", "afmaNotifyDt": "null">
08-02 01:14:05.572: WARN/Ads(14152): IOException connecting to ad url.
08-02 01:14:05.572: WARN/Ads(14152): java.net.ConnectException: r.admob.com/127.0.0.1:80 - Connection refused
08-02 01:14:05.572: WARN/Ads(14152):     at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:254)
08-02 01:14:05.572: WARN/Ads(14152):     at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:533)
08-02 01:14:05.572: WARN/Ads(14152):     at java.net.Socket.connect(Socket.java:1055)
08-02 01:14:05.572: WARN/Ads(14152):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:62)
08-02 01:14:05.572: WARN/Ads(14152):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:88)
08-02 01:14:05.572: WARN/Ads(14152):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHTTPConnection(HttpURLConnectionImpl.java:927)
08-02 01:14:05.572: WARN/Ads(14152):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:909)
08-02 01:14:05.572: WARN/Ads(14152):     at b.run(Unknown Source)
08-02 01:14:05.572: WARN/Ads(14152):     at java.lang.Thread.run(Thread.java:1096)
08-02 01:14:05.572: DEBUG/webviewglue(14152): nativeDestroy view: 0x6e6508

and this exception constantly repeats. Also it says:

08-02 01:14:23.102: INFO/Ads(14152): onFailedToReceiveAd(A network error occurred.)
08-02 01:14:23.192: INFO/Ads(14152): To get test ads on this device, call adRequest.addTestDevice("061AC563478AB601B8B121B23C3BC875");
08-02 01:14:23.212: INFO/Ads(14152): adRequestUrlHtml: <html><head><script src="http://www.gstatic.com/afma/sdk-core-v40.js"></script><script>AFMA_buildAdURL({"preqs":629,"u_sd":1,"slotname":"xxxxxxxxxxxxxxxxx","u_h":480,"u_w":320,"msid":"xxxxxxxxxxxxxxxxxx.android","js":"afma-sdk-a-v4.1.1","isu":"061AC563478AB601B8B121B23C3BC875","format":"320x50_mb","net":"wi","app_name":"1.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.android","u_audio":3,"hl":"ru"});</script></head><body></body></html>
08-02 01:14:23.402: INFO/Ads(14152): To get test ads on this device, call adRequest.addTestDevice("061AC563478AB601B8B121B23C3BC875");
08-02 01:14:23.422: INFO/Ads(14152): adRequestUrlHtml: <html><head><script src="http://www.gstatic.com/afma/sdk-core-v40.js"></script><script>AFMA_buildAdURL({"preqs":630,"u_sd":1,"slotname":"xxxxxxxxxxxxxxx","u_h":480,"u_w":320,"msid":"xxxxxxxxxx.android","js":"afma-sdk-a-v4.1.1","isu":"061AC563478AB601B8B121B23C3BC875","format":"320x50_mb","net":"wi","app_name":"1.android.xxxxxxxxxxxxxxxxxxxxxxxxxxxx.android","u_audio":3,"hl":"ru"});</script></head><body></body></html>

but admob request started in usual way (meaning there is no .setTesting(true)) Why have I to adRequest.addTestDevice?
Once again - it works fine on emulator but not with my device. I tried Samsung Galaxy Spica with froyo 2.2 and HTC HD2 with different android versions (2.2, 2.3 etc, at least 5 different versions tested). It just drowning the device with those fake requests and displays no ads
Why is that?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your /etc/hosts file has re-defined r.admob.com to 127.0.0.1 -- custom ROMs that you download from various sources all do that, because ti blocks out all the ads. Edit your /etc/hosts file and take out that entry.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...