我已经在 Admob 广告上苦苦挣扎了近一周,我在互联网上搜索了所有可能的解决方案,但没有任何效果。我的 Android 应用程序不显示测试广告或实时广告。这是日志:
I/Ads: Updating ad debug logging enablement.
I/Ads: Starting ad request.
SDK version: afma-sdk-a-v13280019.11910000.1
I/Ads: This request is sent from a test device.
W/Ads: Not retrying to fetch app settings
W/Ads: Update ad debug logging enablement as false
W/Ads: App does not have the required permissions to get location
I/Ads: Trying mediation network:
I/Ads: Instantiating mediation adapter: com.google.DummyAdapter
I/Ads: No fill from any mediation ad networks.
I/Ads: Scheduling ad refresh 60000 milliseconds from now.
W/Ads: Failed to load ad: 3
我的测试插页式加载没有问题,但实时加载则不然。横幅不显示,无论是测试横幅还是实时横幅。
这是我的 xml AdView:
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111"> //test admob unit id
</com.google.android.gms.ads.AdView>
我加载横幅:
MobileAds.initialize(this, getString(R.string.app_id));
adView1 = findViewById(R.id.adView);
AdRequest adRequest1 = new AdRequest.Builder().addTestDevice("my_test_device_id").build();
adView1.loadAd(adRequest1);
实时插页式广告以这种方式加载,并且它有效(测试无效):
final InterstitialAd mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId("_live_ad_id");
mInterstitialAd.loadAd(new AdRequest.Builder().addTestDevice("my_test_device_id").build());
mInterstitialAd.setAdListener(new AdListener(){
@Override
public void onAdLoaded(){
mInterstitialAd.show();
}
});
if (mInterstitialAd.isLoaded()) {
} else {
Log.d("TAG", "The interstitial wasn't loaded yet.");
}
我尝试过的事情
什么都没起作用。据我了解,我的日志显示广告请求成功,但 admob 目前没有可显示的广告。也许实时广告没有显示是因为我的应用程序尚未上线,但为什么测试广告没有显示?为什么只有实时插页式广告才有效?我还认为我的 admob 帐户可能被禁用,但广告可以在我的其他应用程序上运行。