I am adding reward ads to my flutter app but I am getting this error. I also want to ad score once rewarded ads get viewed.
I/Choreographer(30860): Skipped 21 frames! The application may be doing too much work on its main thread.
W/Ads (30860): Update ad debug logging enablement as false
W/Ads (30860): Not retrying to fetch app settings
W/ConnectionStatusConfig(30860): Dynamic lookup for intent failed for action: com.google.android.gms.ads.service.START
I/DynamiteModule(30860): Considering local module com.google.android.gms.ads.dynamite:0 and remote module com.google.android.gms.ads.dynamite:224400003
I/DynamiteModule(30860): Selected remote version of com.google.android.gms.ads.dynamite, version >= 224400003
I/Ads (30860): This request is sent from a test device.
W/Ads (30860): Not retrying to fetch app settings
I/Ads (30860): Ad failed to load : 3
my code
class purchase extends StatefulWidget { const purchase({Key? key}) : super(key: key);
@override
State<purchase> createState() => _purchaseState();
}
class _purchaseState extends State {
RewardedAd? _rewardedAd;
int _rewardedScore = 0;
void _createRewardedAd() {
RewardedAd.load(
adUnitId: AdMobService.rewardedAdUnitId!,
request: AdRequest(),
rewardedAdLoadCallback: RewardedAdLoadCallback(
onAdLoaded: (ad) => setState(() => _rewardedAd = ad),
onAdFailedToLoad: (error) => setState(() => _rewardedAd =
null))); }
void _showRewardedAd(){
print(' dnull');
if(_rewardedAd != null){
print('not null');
_rewardedAd!.fullScreenContentCallback =
FullScreenContentCallback(
onAdDismissedFullScreenContent: (ad){
ad.dispose();
_createRewardedAd();
},
onAdFailedToShowFullScreenContent: (ad,error){
ad.dispose();
_createRewardedAd();
}
);
_rewardedAd!.show(onUserEarnedReward: (ad, reward)
=>setState(()=> _rewardedScore++));
_rewardedAd = null;
}
}
@override
void initState() {
// TODO: implement initState
super.initState();
_createRewardedAd();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
child: Column(
children: [
Text('Rewarded score is : $_rewardedScore',style: TextStyle(color: Colors.white),),
ElevatedButton(onPressed: (){
_showRewardedAd();
}, child: Text('earns coins')),
],
),
),
);
}
}