Admob显示测试广告,但不显示真实广告

时间:2019-11-16 09:01:12

标签: android

完全一样的问题。
Admob shows Test ads but not real ads
但是我找不到任何答案。

  1. 我的应用发布了30天,广告ID足以应付任何等待过程。
  2. 我没有设置每次点击费用上限/没有限制。应该有很多。
  3. 尝试使用新的广告ID。 (等待了1周还是没事)
  4. 测试广告效果很好。
  5. 清单中除meta之外没有权限
    Which permissions should i include when i use admob android
  6. 实施'com.google.android.gms:play-services-ads:18.2.0'

我的猜测,
1. 18.2.0出了点问题(以前我无法使用18.1.0进行编译)。
2.按照旧版本将权限包括在清单中。

有人建议播放服务广告的工作版本吗?

编辑1:添加代码

TitleActivity.java

MobileAds.initialize(this, new OnInitializationCompleteListener() {
        @Override
        public void onInitializationComplete(InitializationStatus initializationStatus) {
            new Handler().postDelayed(new Runnable(){
                @Override
                public void run() {
                    //Intent intent = new Intent(TitleActivity.this, AllTypes.class);
                    Intent intent = new Intent(TitleActivity.this, QuestionsActivity.class);
                    //Intent intent = new Intent(TitleActivity.this, bkMainActivity.class);
                    TitleActivity.this.startActivity(intent);
                    TitleActivity.this.finish();
                }
            }, delayTime);//1800
            Log.d("Ads", "onInitializationComplete: Initialize complete");
        }
    });

AdsSystem.java

boolean useSampleID = false;    
public void loadInterstitial(Context c){
    //MobileAds.initialize(this,getString(R.string.app_ad_id));

    mInterstitialAd = new InterstitialAd(c);
    if (useSampleID){
        mInterstitialAd.setAdUnitId(interstitialSampleID);
    }else {
        mInterstitialAd.setAdUnitId(String.valueOf(R.string.ad_interstitial_id));
    }
    //load
    mInterstitialAd.loadAd(new AdRequest.Builder().build());
    Log.d("Ads", "The interstitial is loading.");
}

public void showInterstitial(){
    if (mInterstitialAd.isLoaded()) {
        mInterstitialAd.show();
        // Set an AdListener.
        mInterstitialAd.setAdListener(new AdListener() {
            @Override
            public void onAdClosed () {
                AdRequest adRequest = new AdRequest.Builder().build();
                mInterstitialAd.loadAd(adRequest);
                Log.d("Ads", "The interstitial is loading.");
            }
        });
        Log.d("Ads", "The interstitial is showing.");
    } else {
        Log.d("Ads", "The interstitial wasn't loaded yet.");
    }
}

将调用加载并在MainActivity中交替显示。

编辑2从真实设备中添加了logcat

2019-11-19 21:17:43.346 17702-17702/tk.myessentialoils.a16personalities 
I/Ads: This request is sent from a test device.
2019-11-19 21:17:43.392 17702-17702/tk.myessentialoils.a16personalities     
I/DynamiteModule: Considering local module com.google.android.gms.ads.dynamite:0 and remote module com.google.android.gms.ads.dynamite:21001
2019-11-19 21:17:43.392 17702-17702/tk.myessentialoils.a16personalities I/DynamiteModule: Selected remote version of com.google.android.gms.ads.dynamite, version >= 21001
2019-11-19 21:17:43.435 17702-17702/tk.myessentialoils.a16personalities D/Ads: The interstitial is loading.
2019-11-19 21:17:43.567 17702-17803/tk.myessentialoils.a16personalities W/Ads: Not retrying to fetch app settings
2019-11-19 21:17:45.111 2371-15333/? E/Ads: Cannot determine request type. Is your ad unit id correct?
2019-11-19 21:17:46.684 17702-17702/tk.myessentialoils.a16personalities I/Ads: Ad failed to load : 1

1 个答案:

答案 0 :(得分:0)

对于那些查看过该问题的人。

此行有问题

mInterstitialAd.setAdUnitId(String.valueOf(R.string.ad_interstitial_id));

用实际字符串替换id时。

mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/6300978111");

广告现在可以使用了。
PS:此答案中使用的广告单元ID是一个示例。

随时讨论该行的问题。大声笑。我总是觉得它们很有趣,因为在Google上进行了一些更新,所以一个月前一个代码可用的地方现在无法使用。