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广告时显示。:我得到以下错误日志
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信息中心。最佳答案
您的广告单元ID是新创建的,因此需要花费一些时间来审核广告单元并在您的应用中展示广告。问题与您创建的广告单元ID有关。它使用您的AdUnit ID在我的应用中向我显示测试广告。
请按照以下步骤操作:-
创建实时广告单元ID
登录到
https://apps.admob.com
在左侧菜单中,单击-> Apps
添加应用
选择您是否已在Google Play或App Store上发布了您的应用程序
如果没有->输入您的应用信息
建立广告单元
将测试广告单元替换为新的广告单元。
将应用发布到Playstore后,您将看到广告!
关于android - admob横幅实时广告未展示但正在测试展示,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48501029/