广告无法加载

时间:2016-09-16 06:57:32

标签: android ads

 Starting ad request.
   09-16 09:31:56.827 9836-9836/com.netvariant.panic I/Ads: Use    
   AdRequest.Builder.addTestDevice("F92724BDB6A4403A8C027B851F7DA3AF")   
   to get    test ads on this device.
   09-16 09:31:58.385 9836-9849/com.netvariant.panic I/Ads: No fill 
    from ad server.
   09-16 09:31:58.392 9836-9836/com.netvariant.panic W/Ads: Failed to load ad: 3

我的xml中出现此错误:

 <?xml version="1.0" encoding="utf-8"?>
   <RelativeLayout     
 xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/tesd"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.gms.ads.doubleclick.PublisherAdView
    android:id="@+id/ad_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    ads:adSize="BANNER"
    ads:adUnitId="ca-app-pub-4532549351948034/7622739505" />
   </RelativeLayout>

我的java代码是:

 mAdView = (PublisherAdView) rootView.findViewById(R.id.ad_view);
        // Create an ad request. Check logcat output for the hashed   
        device ID to
        // get test ads on a physical device. e.g.
        // "Use AdRequest.Builder.addTestDevice("ABCDEF012345") to 
        get test ads on this device."
        PublisherAdRequest adRequest = new   
        PublisherAdRequest.Builder().build();
        // Start loading the ad in the background.
        mAdView.loadAd(adRequest);

这就是加载它的方式。问题是什么?谢谢。我创建了firebase,并使用我的Mac sha1(不是我用来在商店上传的密钥库)来创建帐户.am从我的android工作室运行到设备,它不工作。我的app也有google-services.json

我按照这个说明

[https://firebase.google.com/docs/admob/][1]

1 个答案:

答案 0 :(得分:0)

就像在logcat控制台中所说的那样,您需要将以下行添加到您发起广告的代码块中。

AdRequest.Builder.addTestDevice("F92724BDB6A4403A8C027B851F7DA3AF");

这有助于Google广告了解您正在模拟器上测试广告功能并返回测试广告。这样做的原因是为了确保开发人员不会在测试时点击广告(偶然),这可能会导致您的广告帐户被禁止,而且,在实际设备上运行的其他应用也会使用真实广告投放。