简体   繁体   English

android-AdView不会从AdMob加载广告

[英]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 ): 在LogCat中,我看到了以下内容( 由于安全原因更改了某些字符 ):

  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. 我还尝试使用TelephonyManager.getDeviceId()方法返回的ID。 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 ): 我一直在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>

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 PS proguard未启用

删除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) 由于我是AdMob的新手,所以我没有意识到要注册我的应用程序,因此AdUnitId无效(与发布商ID不同,发现了一些错误的信息)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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