admob 横幅实时广告未显示但测试显示

admob banner live ad not showing but test showing

MainActivity 代码:

MobileAds.initialize(this, getResources().getString(R.string.app_id));
mAdView = findViewById(R.id.adView);
            mAdView.setVisibility(View.VISIBLE);
            AdRequest adRequest = new AdRequest.Builder().build();
            mAdView.loadAd(adRequest); 

main_activity.xml 文件

 <com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto"
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        ads:adSize="BANNER"
        ads:adUnitId="ca-app-pub-7758424290736454/1358492948" />

 

当我添加测试 ID 广告时显示。:

ca-app-pub-3940256099942544/6300978111

我收到以下错误日志

DynamitePackage: Instantiating com.google.android.gms.ads.ChimeraMobileAdsSettingManagerCreatorImpl
    01-29 16:19:28.141 6523-6523/com.recreation.cryptocurrencyrate I/art:     at void com.google.android.gms.ads.MobileAds.initialize(android.content.Context, java.lang.String, com.google.android.gms.ads.MobileAds$Settings) ((null):-1)
    01-29 16:19:28.141 6523-6523/com.recreation.cryptocurrencyrate I/art:     at void com.google.android.gms.ads.MobileAds.initialize(android.content.Context, java.lang.String) ((null):-1)
    01-29 16:19:28.142 6523-6523/com.recreation.cryptocurrencyrate I/art:     at void com.google.android.gms.ads.MobileAds.initialize(android.content.Context, java.lang.String, com.google.android.gms.ads.MobileAds$Settings) ((null):-1)
    01-29 16:19:28.142 6523-6523/com.recreation.cryptocurrencyrate I/art:     at void com.google.android.gms.ads.MobileAds.initialize(android.content.Context, java.lang.String) ((null):-1)
    01-29 16:19:30.961 6523-6523/com.recreation.cryptocurrencyrate I/Ads: Starting ad request.
    01-29 16:19:30.961 6523-6523/com.recreation.cryptocurrencyrate I/Ads: This request is sent from a test device.
    01-29 16:19:30.972 6523-6523/com.recreation.cryptocurrencyrate W/Ads: Not retrying to fetch app settings
    01-29 16:19:33.499 6523-6540/com.recreation.cryptocurrencyrate W/Ads: There was a problem getting an ad response. ErrorCode: 0
    01-29 16:19:33.506 6523-6523/com.recreation.cryptocurrencyrate W/Ads: Failed to load ad: 0

Admob 应用单元 ID 仪表板。

您的 Adunit Id 是新创建的,因此需要一些时间来审核 adunit 并在您的应用中展示广告。问题出在您创建的广告单元 ID 上。它使用您的 AdUnit Id 在我的应用程序中向我展示测试广告。

按照以下步骤操作:-

创建实时广告单元 ID

登录

https://apps.admob.com

在左侧菜单中点击 -> 应用程序 添加应用 选择您是在 Google Play 还是 App Store 上发布您的应用 如果没有 -> 输入您的应用信息 创建广告单元 用新的广告单元替换测试广告单元。 一旦应用程序发布到 Playstore,您就会看到广告!

请检查您是否将以下代码添加到您的 androidmanifest.xml;

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

 <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

看来你已经添加了

compile 'com.google.android.gms:play-services-ads:8.4.0'

给你的build.gradle

如果全部完成,广告应该可以正常工作。