AdMob加载广告失败

时间:2015-06-23 02:20:08

标签: android admob

好的,问题解决了,没有做任何事情。

我使用了以下指南: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

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

画布代码:

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

行。我想我确认问题是画布。通过通货膨胀或其他方式,我可以优先考虑广告吗?帆布每秒刷新一次。或者我可以重新设计我的画布以覆盖屏幕的所有部分,但广告?

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

<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.

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

2 个答案:

答案 0 :(得分:3)

关注广告代码

<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:广告=&#34; HTTP://schemas.android.com/apk/res-auto"

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

这将解决您的问题

答案 1 :(得分:2)

您只需要关注标记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有时效果不佳,因此无法成功加载广告。确保您有良好的互联网连接并正确遵循指南。