AdMob 加载广告失败

AdMob load ad failure

ok 什么都没做就解决了

我使用了以下指南:https://developers.google.com/admob/android/quick-start。但它没有用,所以我在 onCreate() 中使用了 .addTestDevice。但是,广告(请求横幅)仍然加载失败

 AdView mAdView = (AdView) findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice("The Correct Code extracted from logcat")
            .build();
    mAdView.loadAd(adRequest);

错误如下:

        06-22 19:40:49.327    2341-2360/nocompany.CashingCash D/dalvikvm﹕ DexOpt: --- BEGIN 'ads117496078.jar' (bootstrap=0) ---
06-22 19:40:49.377    2341-2341/nocompany.CashingCash I/Ads﹕ CsiReporterFactory: CSI is not enabled. No CSI reporter created.
06-22 19:40:49.377    2341-2341/nocompany.CashingCash I/Ads﹕ Starting ad request.
06-22 19:40:49.397    2341-2360/nocompany.CashingCash D/dalvikvm﹕ DexOpt: --- END 'ads117496078.jar' (success) ---
06-22 19:40:49.397    2341-2360/nocompany.CashingCash D/dalvikvm﹕ DEX prep '/data/data/nocompany.CashingCash/cache/ads117496078.jar': unzip in 0ms, rewrite 71ms
06-22 19:40:52.157    2341-2376/nocompany.CashingCash W/Ads﹕ There was a problem getting an ad response. ErrorCode: 2
06-22 19:40:52.177    2341-2341/nocompany.CashingCash I/dalvikvm﹕ Could not find method android.webkit.WebSettings.setMixedContentMode, referenced from method com.google.android.gms.ads.internal.t.h.<init>
06-22 19:40:52.217    2341-2341/nocompany.CashingCash I/Ads﹕ Scheduling ad refresh 60000 milliseconds from now.
06-22 19:40:52.217    2341-2341/nocompany.CashingCash W/Ads﹕ Failed to load ad: 2
06-22 19:41:52.227    2341-2341/nocompany.CashingCash I/Ads﹕ Starting ad request.
06-22 19:41:52.549    2341-3515/nocompany.CashingCash W/Ads﹕ There was a problem getting an ad response. ErrorCode: 2
06-22 19:41:52.569    2341-2341/nocompany.CashingCash I/Ads﹕ Scheduling ad refresh 60000 milliseconds from now.
06-22 19:41:52.569    2341-2341/nocompany.CashingCash W/Ads﹕ Failed to load ad: 2

这可能是因为我的canvas覆盖了整个屏幕吗?

Canvas代码:

 android:id="@+id/rec_canvas"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:textColor="#000000" />

好的。我想我确认问题出在 canvas。我可以通过 inflation 或其他方式让广告优先于 canvas 吗? Canvas 每秒刷新一次。或者我可以重新构建我的 canvas 以覆盖除广告以外的所有屏幕部分吗?

其他一些相关代码: (activity 主要)

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:id="@+id/container"
android:layout_height="match_parent"  tools:context=".MainActivity"
<com.google.android.gms.ads.AdView
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:id="@+id/xadView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    ads:adSize="SMART_BANNER"
    ads:adUnitId="@string/banner_ad_unit_id" />

(字符串)

    <string name="banner_ad_unit_id">ca-app-pub-3940256099942544/6300978111</string>

(清单)

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/

可见性错误

    06-22 19:48:56.968    2341-2341/? I/Ads﹕ Ad is not visible. Not refreshing ad.
06-22 19:48:56.968    2341-2341/? I/Ads﹕ Scheduling ad refresh 60000 milliseconds from now.
06-22 19:49:01.648    1575-1575/? D/HeadsetTangibleController﹕ [TangibleIO] HeadsetTangibleController onAction action = android.intent.action.BATTERY_CHANGED
06-22 19:49:32.518  11424-15647/? E/Ads﹕ Failed to connect to https://googleads.g.doubleclick.net/pagead/drt/m. No DRT retrieved.

为 phone 确认网络连接,访问了网站和作品。 我在模拟器上测试过,它可以工作,但它不适用于实际 phone (Lg G3)。

你只需要关心标签Ads:

06-22 19:18:17.207  20075-20110/nocompany.CashingCash W/Ads﹕ There was a problem getting an ad response. ErrorCode: 2

因为有时候Google Admob 不能很好地工作所以加载广告不成功。请确保您的互联网连接良好并正确遵循指南。

关注标签广告:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:ads="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
        android:id="@+id/container"
        android:layout_height="match_parent"  tools:context=".MainActivity"
        <com.google.android.gms.ads.AdView
            xmlns:ads="http://schemas.android.com/apk/res-auto"
            android:id="@+id/xadView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            ads:adSize="SMART_BANNER"
            ads:adUnitId="@string/banner_ad_unit_id" />

放第二行我在这个例子里放

xmlns:ads="http://schemas.android.com/apk/res-auto"

在你可以在我的回答中看到的同一个地方

这将解决您的问题