简体   繁体   中英

android - AdView won't load an ad from AdMob

I'm trying to get a test ad working on a real device. In LogCat I saw the following ( some characters changed due to security reasons ):

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

I did this so my setup looks like:

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

Layout:

   <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" />

I also tried to use an id returned by TelephonyManager.getDeviceId() method. Result didnt change. In the manifest file, adding or removing following line changes absolutely nothing:

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

I'm constantly getting the following message in LogCat ( some values changed due to security reasons ):

         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>

This message appears immediately after I start the app, the device has an active data connection and all required permissions are set. Any ideas?

PS proguard is not enabled

删除Adview属性ads:loadAdOnCreate =“ false”,然后在清洁应用程序后尝试更改设备

issue solved. Since I'm new to AdMob I didn't realize to register my application, so the AdUnitId was invalid (it's not the same as the publisher id, found some wrong info)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM