简体   繁体   中英

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. 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.

This is gradle implementation:

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. some of our games are designed for children below 12, so we have to show DFF ads. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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