"No ad config" error onAdFailedToLoad even with test ad unit

717

As I remember, after loading an Ad object, you need to show it to the user so the device can know when to show Ad based on condition or event, etc.

To load an Ad :

InterstitialAd.load(
  adUnitId: '<ad unit id>',
  request: AdRequest(),
  adLoadCallback: InterstitialAdLoadCallback(
    onAdLoaded: (InterstitialAd ad) {
      // Keep a reference to the ad so you can show it later.
      this._interstitialAd = ad;
    },
    onAdFailedToLoad: (LoadAdError error) {
      print('InterstitialAd failed to load: $error');
    },
  ));

Ad events to listen to the Ad status :


interstitialAd.fullScreenContentCallback = FullScreenContentCallback(
  onAdShowedFullScreenContent: (InterstitialAd ad) =>
     print('$ad onAdShowedFullScreenContent.'),
  onAdDismissedFullScreenContent: (InterstitialAd ad) {
    print('$ad onAdDismissedFullScreenContent.');
    ad.dispose();
  },
  onAdFailedToShowFullScreenContent: (InterstitialAd ad, AdError error) {
    print('$ad onAdFailedToShowFullScreenContent: $error');
    ad.dispose();
  },
  onAdImpression: (InterstitialAd ad) => print('$ad impression occurred.'),
);

To display an Ad :


myInterstitial.show();

As I see in your code, you did not show an Interstitial Ad in your UI code. Correct me if I'm wrong.

EDIT:

If you ask how to use it myInterstitial.show(); in your code, you can use it inside a FlatButton, TextButton, GestureDetector etc. and inside onTap or onPressed functions, use myInterstitial.show();

Share:
717
iDecode
Author by

iDecode

When developers want to hide something from you, they put it in docs.

Updated on December 30, 2022

Comments

  • iDecode
    iDecode over 1 year

    Android (Java) way:

    Minimal reproducible code:

    public class MainActivity extends Activity {
        private static final String TAG = "MyTag";
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            MobileAds.initialize(this);
            AdRequest adRequest = new AdRequest.Builder().build();
            InterstitialAd.load(this, "ca-app-pub-3940256099942544/1033173712", adRequest,
                    new InterstitialAdLoadCallback() {
                        @Override
                        public void onAdLoaded(@NonNull InterstitialAd interstitialAd) {
                            Log.i(TAG, "onAdLoaded");
                            interstitialAd.show(MainActivity.this);
                        }
    
                        @Override
                        public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
                            Log.i(TAG, loadAdError.getMessage());
                        }
                    });
        }
    }
    

    My build.gradle(app)

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

    My AndroidManifest.xml:

    <meta-data
        android:name="com.google.android.gms.ads.APPLICATION_ID"
        android:value="ca-app-pub-3940256099942544~3347511713"/>
    

    Problem (on Android):

    Even using the test Ad ID and test App ID, the ads are not loading up.


    Flutter (Dart) way:

    Minimal reproducible code:

    void main() {
      WidgetsFlutterBinding.ensureInitialized();
      MobileAds.instance.initialize();
      runApp(MaterialApp(home: MyApp()));
    }
    
    class MyApp extends StatefulWidget {
      @override
      MyAppState createState() => MyAppState();
    }
    
    class MyAppState extends State<MyApp> {
      @override
      void initState() {
        super.initState();
        InterstitialAd.load(
          adUnitId: 'ca-app-pub-3940256099942544/1033173712',
          request: AdRequest(),
          adLoadCallback: InterstitialAdLoadCallback(
            onAdLoaded: (ad) => ad.show(),
            onAdFailedToLoad: (e) => print('Failed: $e'),
          ),
        );
      }
    
      @override
      Widget build(BuildContext context) => Container();
    }
    

    Problem (on Flutter):

    The test ads show up but when I try to use my own Ad ID and App ID (even in the release mode), it fails with this error.

    No ad config.

    It's been a week now since I created that ad unit on Admob. I also have a different app on the Play Store (which is showing ad) but even if I use that app's ID in my code, it fails to load the ad with error code 3.

    PS: Tried this solution already but it didn't work.

    Either of Android or Flutter solution would work for me