0

The ad loads and is shown successfully the first time but throws an exception if called again.

This is the code snippet for where an interstitial ad is made -

InterstitialAd createInterstitialAd() {
  return InterstitialAd(
    adUnitId: InterstitialAd.testAdUnitId,
    targetingInfo: targetingInfo,
    listener: (MobileAdEvent event) {
      print("InterstitialAd event $event");
    },
  );

}

This is the code snippet for where it is called -

      if (!(await interstitialAd.isLoaded()))
          interstitialAd = createInterstitialAd()..load();
      interstitialAd.show();
      interstitialAd?.dispose();
      interstitialAd = createInterstitialAd()..load();

Error body -

    [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(no_ad_for_id, isAdLoaded failed, no add exists for id=444270692, null)
E/flutter (19241): #0      StandardMethodCodec.decodeEnvelope 
package:flutter/…/services/message_codecs.dart:569
E/flutter (19241): #1      MethodChannel._invokeMethod 
package:flutter/…/services/platform_channel.dart:156
E/flutter (19241): <asynchronous suspension>
E/flutter (19241): #2      MethodChannel.invokeMethod 
package:flutter/…/services/platform_channel.dart:329
E/flutter (19241): #3      _invokeBooleanMethod 
package:firebase_admob/firebase_admob.dart:611
E/flutter (19241): #4      MobileAd.isLoaded 
package:firebase_admob/firebase_admob.dart:255
E/flutter (19241): #5      buildConsumer.<anonymous closure>.<anonymous closure> 
package:compactimg/widgets/select_image_button.dart:56
E/flutter (19241): <asynchronous suspension>
E/flutter (19241): #6      buildConsumer.<anonymous closure>.<anonymous closure> (package:compactimg/widgets/select_image_button.dart)
E/flutter (19241): #7      _InkResponseState._handleTap 
package:flutter/…/material/ink_well.dart:779
E/flutter (19241): #8      _InkResponseState.build.<anonymous closure> 
package:flutter/…/material/ink_well.dart:862
E/flutter (19241): #9      GestureRecognizer.invokeCallback 
package:flutter/…/gestures/recognizer.dart:182
E/flutter (19241): #10     TapGestureRecognizer.handleTapUp 
package:flutter/…/gestures/tap.dart:504
E/flutter (19241): #11     BaseTapGestureRecognizer._checkUp 
package:flutter/…/gestures/tap.dart:282
E/flutter (19241): #12     BaseTapGestureRecognizer.handlePrimaryPointer 
package:flutter/…/gestures/tap.dart:217
E/flutter (19241): #13     PrimaryPointerGestureRecognizer.handleEvent 
package:flutter/…/gestures/recognizer.dart:475
E/flutter (19241): #14     PointerRouter._dispatch 
package:flutter/…/gestures/pointer_router.dart:76
E/flutter (19241): #15     PointerRouter._dispatchEventToRoutes.<anonymous closure> 
package:flutter/…/gestures/pointer_router.dart:122
E/flutter (19241): #16     _LinkedHashMapMixin.forEach  (dart:collection-patch/compact_hash.dart:379:8)
E/flutter (19241): #17     PointerRouter._dispatchEventToRoutes 
cmd_prompter
  • 1,566
  • 10
  • 16
  • Make sure that you gave the correct Admob ID..not sure if that's the case..just check on it once again... – srikanth7785 Jun 17 '20 at 10:37
  • It's the test app id – cmd_prompter Jun 17 '20 at 12:53
  • 1
    Had the problem and the mistake i did is different appId in androidmanifest.xml and await FirebaseAdMob.instance.initialize("wrongAppid"),so make sure you have given the correct appid in both places – Rajesh Oct 16 '20 at 15:42

0 Answers0