简体   繁体   English

如何解决 android Admob 中的无广告配置问题?

[英]How to resolve No ad config issue in android Admob?

Hello I am trying to use Admob ads on my app but ads are not displaying.您好,我正在尝试在我的应用上使用 Admob 广告,但没有显示广告。 I am getting this error:我收到此错误:

"Code": 3,
  "Message": "No ad config.",
  "Domain": "com.google.android.gms.ads",
  "Cause": "null",
  "Response Info": {
    "Response ID": "null",
    "Mediation Adapter Class Name": "",
    "Adapter Responses": []
  }

The same error occurs with test ids as well.测试 ID 也会出现同样的错误。

This is gradle implementation:这是 gradle 实现:

implementation 'com.google.firebase:firebase-ads:20.3.0'
implementation 'com.google.android.gms:play-services-ads:20.3.0'

I initialize ads like so:我像这样初始化广告:

MobileAds.initialize(this);

This is interstitial initialization:这是插页式初始化:

adRequest = new AdRequest.Builder().build();
        InterstitialAd.load(c,c.getString(R.string.popup), adRequest, new InterstitialAdLoadCallback() {
            @Override
            public void onAdLoaded(@NonNull InterstitialAd interstitialAd) {
                mInterstitialAd = interstitialAd;

            }
            @Override
            public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
                mInterstitialAd = null;

            }
        });

Thanks @Besart, you saved my life.谢谢@Besart,你救了我的命。 some of our games are designed for children below 12, so we have to show DFF ads.我们的一些游戏是为 12 岁以下的儿童设计的,所以我们必须展示 DFF 广告。 following code is important:以下代码很重要:

  // String MAX_AD_CONTENT_RATING_G = "G";
  // String MAX_AD_CONTENT_RATING_PG = "PG";
  // String MAX_AD_CONTENT_RATING_T = "T";
  // String MAX_AD_CONTENT_RATING_MA = "MA";
  // int TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE = 1;
  // int TAG_FOR_CHILD_DIRECTED_TREATMENT_FALSE = 0;

RequestConfiguration configuration = new RequestConfiguration.Builder()
        .setTagForChildDirectedTreatment(1)
        .setMaxAdContentRating("G")
        .build();
MobileAds.setRequestConfiguration(configuration);

But the code will cause "no ad config" error on test ads.但是代码会导致测试广告出现“无广告配置”错误。 So, pls delete the code above if you have, hope helpful.所以,如果你有,请删除上面的代码,希望有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM