How to resolve No ad config issue in android Admob?

Viewed 2224

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;

            }
        });
1 Answers

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.

Related