Android - AdView不会从AdMob加载广告

时间:2013-08-15 20:26:48

标签: android admob

我正在尝试在真实设备上制作测试广告。在LogCat中,我看到以下内容(由于安全原因而更改了某些字符):

  08-15 14:17:55.763: I/Ads(19134): To get test ads on this device, call adRequest.addTestDevice("A84885C745A637A0AC110BF96AFD31D9");

我这样做了,所以我的设置如下:

    AdView ad = (AdView) findViewById(R.id.ad);
    AdRequest req = new AdRequest();
    req.addTestDevice("A84885C995B637A0AC110BF96FFD31D9");
    ad.loadAd(req);

布局:

   <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<android.support.v4.view.ViewPager
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/ad"
    android:background="@drawable/smoke_bg"
    tools:context=".Main" />

<com.google.ads.AdView
    android:id="@+id/ad"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_alignParentBottom="true"
    ads:adSize="BANNER"
    ads:adUnitId="pub-XXXXXXXXXXXXXXX"
    ads:loadAdOnCreate="false" />

我还尝试使用TelephonyManager.getDeviceId()方法返回的ID。结果没有改变。在清单文件中,添加或删除以下行绝对不会改变:

       <meta-data
        android:name="ADMOB_PUBLISHER_ID"
        android:value="pub-XXXXXXXXXXXXXXXXXX" />

我经常在LogCat中收到以下消息(由于安全原因而更改了某些值):

         08-15 22:11:27.173: I/Ads(22524): adRequestUrlHtml: <html><head><script src="http://media.admob.com/sdk-core-v40.js"></script><script>AFMA_buildAdURL({"preqs":4,"session_id":"9062394107923473758","seq_num":"5","slotname":"pub-XXXXXXXXXXXXXXXX","u_w":320,"msid":"some.package.name","adtest":"on","js":"afma-sdk-a-v6.4.1","bas_off":0,"net":"wi","app_name":"1.android.some.app.name","hl":"en","gnt":3,"carrier":"26201","u_audio":1,"u_sd":1.5,"ms":"UsOgPEHFzTwAcLHr9aOtQb9cGMw4bPjww5rwuOT5U8_C7w7-DnLDNFeWVOra8LVymVb1KTpyiq4ZYnNpxAdCt2S8zEO_wW5NGrh8Qcc7ln2sh8EhZifMeF31aXHAgWE_pRjeBuiC6su-pMiqI9cNTfeo4LLgbQUXWD8U9MaJlwPmpU6xwOx2WS3o0PtY42J-WiJNrTtTQg9waYjwGECLCv4sOTMP1a2FZESvPFsg0Xopu_nqxO1UucNVkIcpeeDISp7CN6oBG_MDcZlPHNAwJQn_WuNJTTKOcA6y511UfP3oDHkaZumYzx8YnynZHCa8gJPafnNqnp3M_PnZ0Knmqg","mv":"80230010.com.android.vending","isu":"A86885C745A637A0AB110BF96FDD31D9","format":"320x50_mb","oar":0,"ad_pos":{"height":75,"visible":1,"y":725,"x":0,"width":480},"u_h":533,"pt":1,"bas_on":0,"ptime":245460});</script></head><body></body></html>
     08-15 22:11:27.233: I/Ads(22524): Received ad url: <url: "null" type: "unknown" afmaNotifyDt: "null" activationOverlayUrl: "null" useWebViewLoadUrl: "false">
     08-15 22:11:27.233: D/WebCore(22524): uiOverrideUrlLoading: shouldOverrideUrlLoading() returnstrue
     08-15 22:11:27.233: I/Ads(22524): AdLoader timed out after 60000ms while getting the URL.
     08-15 22:11:27.238: D/webviewglue(22524): nativeDestroy view: 0x4fa92f40
     08-15 22:11:27.238: I/Ads(22524): onFailedToReceiveAd(A network error occurred.)
     08-15 22:11:27.238: I/GATE(22524): <GATE-M>DEV_ACTION_COMPLETED</GATE-M>

此消息在我启动应用程序后立即显示,设备具有活动数据连接并且已设置所有必需权限。有什么想法吗?

P.S。 proguard未启用

2 个答案:

答案 0 :(得分:1)

删除Adview属性广告:loadAdOnCreate =“false”并尝试在清理应用后更改设备

答案 1 :(得分:0)

问题解决了。由于我是AdMob的新用户,我没有意识到要注册我的应用程序,因此AdUnitId无效(它与发布商ID不同,发现了一些错误的信息)