我已将Admob广告集成到了我的Android应用中。Admob广告已加载但未显示在andrioid应用中 - 仅显示测试广告
测试广告可见。
当我在其他设备上运行应用程序时,在logcat中显示OnAdLoaded的日志。
但是广告在屏幕上不可见。
可能的原因是什么?你可以提出任何解决方案,将不胜感激
Java代码的
MobileAds.initialize(this, "ca-app-pub-7480926640170381~7951418856");
adView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice("EDDA7ADAB0640D8A735BAD5C5AD56F06")
.addTestDevice("92C2E8C0BE19A733B5E747993F8DCB69")
.build();
adView.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
// Code to be executed when an ad finishes loading.
Log.i("Ads", "onAdLoaded");
}
@Override
public void onAdFailedToLoad(int errorCode) {
// Code to be executed when an ad request fails.
Log.i("Ads", "onAdFailedToLoad");
}
@Override
public void onAdOpened() {
// Code to be executed when an ad opens an overlay that
// covers the screen.
Log.i("Ads", "onAdOpened");
}
@Override
public void onAdLeftApplication() {
// Code to be executed when the user has left the app.
Log.i("Ads", "onAdLeftApplication");
}
@Override
public void onAdClosed() {
// Code to be executed when when the user is about to return
// to the app after tapping on an ad.
Log.i("Ads", "onAdClosed");
}
});
adView.loadAd(adRequest);
XML CODE:
<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_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="ca-app-pub-7480926640170381/1386010508">
</com.google.android.gms.ads.AdView>
Gradle
compile 'com.google.android.gms:play-services-ads:11.0.0'
很难说没有看代码,但有几件事情可以尝试 - 1.其他设备是否注册了测试设备的电子邮件? 2.您是否真的从AdMob获取广告内容? –
这里是我的代码 –
我刚刚编辑我的问题,请检查@NileshRajani –