我已在我的Android应用中集成了Admob广告。
测试广告可见。
当我在其他设备上运行该应用程序时,在logcat中它显示来自OnAdLoaded的Log。
但广告在屏幕上不可见。
可能的原因是什么?您可以建议的任何解决方案都将受到赞赏
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'
答案 0 :(得分:0)
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "ca-pub-5303090875900545",
enable_page_level_ads: true
});
</script>
答案 1 :(得分:0)
在广告可见之前,您需要向AdMob注册付款方式。