在 Play 商店上传应用时,admob 广告不起作用

admob ads doesn't work when uploading the app on play store

我在应用程序中使用 google admob,当我将它与项目的测试 ID 一起使用时,它运行良好,但当我将其更改为实时 ID 时,广告停止出现。 这是我的 java 代码:

MobileAds.initialize(this, getString(R.string.ad_mob_used_id));

    mInterstitialAd = new InterstitialAd(this);
    mInterstitialAd.setAdUnitId(getString(R.string.ad_mob_used_id));
    mInterstitialAd.loadAd(new AdRequest.Builder().build());
    mInterstitialAd.setAdListener(new AdListener(){
        @Override
        public void onAdLoaded() {
            super.onAdLoaded();
            mInterstitialAd.show();//TODO : check this
        }
    });

这是清单中的代码:

    <meta-data
        android:name="com.google.android.gms.ads.APPLICATION_ID"
        android:value="@string/ad_mob_used_id"/>

这是字符串中的代码:

<string name="ad_mob_live_id">ca-app-pub-1283544791526621~9315704399</string>
<string name="ad_mob_test_id">ca-app-pub-1283544791526621/5955878039</string>

<!-- either live or debug -->
<string name="ad_mob_used_id">ca-app-pub-1283544791526621~9315704399</string>

检查下面的语句,是你的打字错误还是你的错误??

您在 admob_app_idad_unit_id 中使用相同的值!!!

mInterstitialAd.setAdUnitId(getString(R.string.ad_mob_used_id)); // use adunit id instead of AD_ID

应该是

mInterstitialAd.setAdUnitId(getString(R.string.ad_mob_live_ad_unit)); //something in format of ca-app-pub-3940256099942544/1033173712

如果这是您刚刚输入的错误,请等待几个小时。

因为根据 Google :

"It could be that you have only recently created a new Ad Unit ID and requesting for live ads. It could take a few hours for ads to start getting served if that is that case. If you are receiving test ads then your implementation is fine. Just wait a few hours and see if you are able to receive live ads then. If not, can send us your Ad Unit ID for us to look into."