AdMob After Ad receive - IOException connecting to ad url(AdMob 收到广告后 - IOException 连接到广告网址)
本文介绍了AdMob 收到广告后 - IOException 连接到广告网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
i have an android app that need to show ads by AdMob. here's my Log:
07-18 01:55:53.116: INFO/Ads(8682): adRequestUrlHtml: <html><head><script src="http://www.gstatic.com/afma/sdk-core-v40.js"></script><script>AFMA_buildAdURL({"preqs":0,"u_sd":1.5,"slotname":"**************","u_w":320,"msid":"com.paladin.hilula","cap":"m","adtest":"on","js":"afma-sdk-a-v4.1.0","isu":"*********************************","format":"320x50_mb","net":"ed","app_name":"1.android.com.paladin.hilula","hl":"hd","u_h":569,"testing":1,"u_audio":1,"u_so":"p"});</script></head><body></body></html>
07-18 01:55:54.187: INFO/Ads(8682): Received ad url: <"url": "http://r.admob.com:80/ad_source.php?preqs=0&u_sd=1.5&slotname=**************&u_w=320&msid=com.paladin.hilula&cap=m&adtest=on&js=afma-sdk-a-v4.1.0&isu=*************************&format=320x50_mb&net=ed&app_name=1.android.com.paladin.hilula&hl=hd&u_h=569&testing=1&u_audio=1&u_so=p&output=html®ion=mobile_app&u_tz=-180&ex=1&client_sdk=1", "afmaNotifyDt": "null">
07-18 01:56:15.288: WARN/Ads(8682): IOException connecting to ad url.
07-18 01:56:15.288: WARN/Ads(8682): java.net.SocketTimeoutException: Connection timed out
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.platform.OSNetworkSystem.connect(Native Method)
07-18 01:56:15.288: WARN/Ads(8682): at dalvik.system.BlockGuard$WrappedNetworkSystem.connect(BlockGuard.java:357)
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:204)
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:437)
07-18 01:56:15.288: WARN/Ads(8682): at java.net.Socket.connect(Socket.java:983)
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:75)
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:48)
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection$Address.connect(HttpConnection.java:322)
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:89)
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHttpConnection(HttpURLConnectionImpl.java:285)
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.makeConnection(HttpURLConnectionImpl.java:267)
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:205)
07-18 01:56:15.288: WARN/Ads(8682): at b.a(Unknown Source)
07-18 01:56:15.288: WARN/Ads(8682): at b.doInBackground(Unknown Source)
07-18 01:56:15.288: WARN/Ads(8682): at android.os.AsyncTask$2.call(AsyncTask.java:185)
07-18 01:56:15.288: WARN/Ads(8682): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
07-18 01:56:15.288: WARN/Ads(8682): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
07-18 01:56:15.288: WARN/Ads(8682): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
07-18 01:56:15.288: WARN/Ads(8682): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
07-18 01:56:15.288: WARN/Ads(8682): at java.lang.Thread.run(Thread.java:1019)
07-18 01:56:15.296: INFO/Ads(8682): onFailedToReceiveAd(A network error occurred.)
i get the URL but cant show it.
in manifest:
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation"/>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
in .java:
// Create the adView
AdView adView = new AdView(this, AdSize.BANNER, MY_AD_UNIT_ID);
// Lookup your LinearLayout assuming it’s been given
// the attribute android:id="@+id/mainLayout"
RelativeLayout layout = (RelativeLayout)findViewById(R.id.rlayout);
// Add the adView to it
layout.addView(adView);
// Initiate a generic request to load it with an ad
AdRequest r = new AdRequest();
r.setTesting(true);
r.addTestDevice("*****************************");
adView.loadAd(r);
解决方案
The /etc/hosts file on your phone has aliased r.admob.com to 127.0.0.1. I had this occur when I used a flashed ROM on my phone -- the ROM defined a whole bunch of entries like that so I'd never get ads. Which was great until I was testing my own ad-enabled app :-)
Edit your /etc/hosts and take out that entry.
这篇关于AdMob 收到广告后 - IOException 连接到广告网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:AdMob 收到广告后 - IOException 连接到广告网址
基础教程推荐
猜你喜欢
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01