Admob错误-onAdFailedToLoad错误代码3

时间:2019-12-13 09:22:33

标签: android admob banner-ads

我尝试在我的应用中创建admob横幅,但出现错误代码3 请帮助我获得解决方案。

我的清单中有元数据

布局:

    <com.google.android.gms.ads.AdView
        xmlns:ads="http://schemas.android.com/apk/res-auto"
        android:id="@+id/adView111"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        ads:adSize="SMART_BANNER"
        ads:adUnitId="ca-app-pub-9038559490997069/7964491403">
    </com.google.android.gms.ads.AdView>
</LinearLayout>

Java:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    MobileAds.initialize(this, new OnInitializationCompleteListener() {
        @Override
        public void onInitializationComplete(InitializationStatus initializationStatus) {
        }
    });

    AdView adView = new AdView(this);
    adView.setAdSize(AdSize.BANNER);
    adView.setAdUnitId("ca-app-pub-9038559490997069/7964491403");
    adView = findViewById(R.id.adView111);
    AdRequest adRequest = new AdRequest.Builder().build();
    adView.setAdListener(new com.google.android.gms.ads.AdListener() {
        @Override
        public void onAdLoaded() {
            super.onAdLoaded();
            Log.e("onAdLoaded","AdLoaded");
        }

        @Override
        public void onAdFailedToLoad(int errorCode) {
            super.onAdFailedToLoad(errorCode);
            Log.e("onAdFailedToLoad",""+errorCode);

        }
    });

    adView.loadAd(adRequest);
}

如果admob帐户是新帐户,我知道有错误3, 我在一周前创建了我的admob帐户。

我得到一些日志:

W/FA-Ads: Disabling data collection. Found google_app_id in strings.xml but Google Analytics for Firebase is missing. Remove this value or add Google Analytics for Firebase to resume data collection.2019-12-13 12:06:50.041 6768-6768/myapplication.game D/DynamitePackage: Instantiating com.google.android.gms.ads.ChimeraMobileAdsSettingManagerCreatorImpl
I/Ads: Updating ad debug logging enablement.
D/DynamitePackage: Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl
I/Ads: Use AdRequest.Builder.addTestDevice("94DF0193F80DB5F14BFF0EA958D02BC9") to get test ads on this device.
2019-12-13 12:06:50.248 6768-6768/myapplication.game I/DynamiteModule: Considering local module com.google.android.gms.ads.dynamite:0 and remote module com.google.android.gms.ads.dynamite:21001
I/DynamiteModule: Selected remote version of com.google.android.gms.ads.dynamite, version >= 21001
W/Ads: Update ad debug logging enablement as false
W/Ads: Not retrying to fetch app settings
I/Ads: Ad failed to load : 3

1 个答案:

答案 0 :(得分:1)

AdMob不允许发布商在开发过程中加载和展示真实的广告。您必须使用测试广告单元ID或将您的设备添加为测试设备,以测试广告测试广告实施情况。只是不必担心不加载广告,如果您的应用在Play商店中不可用,则AdMob不会显示任何广告。在发布到Play商店后,AdMob会自动验证您的应用并开始投放广告。

AdRequest adRequest = new AdRequest.Builder().build();

使用

更改此行
AdRequest adRequest = new AdRequest.Builder().addTestDevice("94DF0193F80DB5F14BFF0EA958D02BC9").build();

您可以从日志中获取此测试设备的ID。