Unable to open any reward Ads in Flutter google_mobile_ads
I have implemented a simple game for which I have added banner, interstitial and reward ads.
The banner and interstitial ads work perfectly both on test and my own google adMob adIds. However only the reward ads do not work. Even the test reward ad gives an error 3.
The code is as follows
Future<void> _loadRewardedAd() async { if (this.mounted) { setState(() { loading = true; }); } await RewardedAd.load( adUnitId: TestAdHelper.rewardedAdUnitId, request: const AdRequest(), rewardedAdLoadCallback: RewardedAdLoadCallback(onAdLoaded: (ad) { ad.fullScreenContentCallback = FullScreenContentCallback(onAdDismissedFullScreenContent: (ad) { ad.dispose(); _rewardedAd = null; widget.close(domain.Dialog.awardAd, show: false); }); _rewardedAd = ad; }, onAdFailedToLoad: (error) { _rewardedAd?.dispose(); failedAttempts++; log("failed to load reward ad $error"); failedAttempts <= 3 ? 2.seconds.delay().then((value) => _loadRewardedAd()) : null; setState(() { loading = false; didntLoad = true; }); })); }
and
ElevatedButton( style: ElevatedButton.styleFrom( minimumSize: Size(90, 60), backgroundColor: Colors.greenAccent.shade700), onPressed: () async { await _loadRewardedAd().then((value) async { await _rewardedAd?.show( onUserEarnedReward: (_, reward) { widget.incrementCoins(); widget.close(domain.Dialog.awardAd, show: false); }); }); }, child: loading ? CircularProgressIndicator( color: Colors.white, backgroundColor: Colors.white38, ) : Icon( Icons.ondemand_video_rounded, size: 40, ))
The test ID helper class uses the following IDs
static String get rewardedAdUnitId { if (Platform.isAndroid) { return "ca-app-pub-3940256099942544/5224354917"; } else if (Platform.isIOS) { return "ca-app-pub-3940256099942544/1712485313"; } else { throw UnsupportedError("Unsupported platform"); } }
I have tried looking up this issue but to no avail, only people agreeing that they have the same issue in threads that go as far as 2021.
I also get this error in the debug console, the number varies although 3 is the most common
I/flutter (10788): Ad with id
1
is not available for onAdFailedToLoad. I/flutter (10788): Ad with id2
is not available for onAdFailedToLoad. I/flutter (10788): Ad with id3
is not available for onAdFailedToLoad.
I was facing a similar issue, closing the app and doing flutter clean solved it for me. Hopefully, this works for others too.