1

我正在尝试在真实设备上制作测试广告。在 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>

此消息在我启动应用程序后立即出现,设备具有活动的数据连接并设置了所有必需的权限。有任何想法吗?

PS proguard 未启用

4

2 回答 2

2

删除 Adview 属性 ads:loadAdOnCreate="false" 并在清理应用后尝试更换设备

于 2013-08-16T05:52:29.823 回答
0

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

于 2013-08-15T22:04:47.970 回答