Implementing google rewarded ads in flutter is quite easy now as google has provided powerful library for implementing google rewarded ads in our application and make revenue from it. To implement google rewarded ads in your project, follow this article and make sure that you do all steps same as I shown in this article.
We will be implementing google rewarded ads in two parts
1. Setting up our app to show google ads.
2. Show google rewarded ads.
1. Setup App to show Google Ads
1. Run below command with flutter to add google_mobile_ads in you project:
$ flutter pub add google_mobile_ads
OR
1. Add following under dependencies in your project’s pubspec.yaml file.
dependencies:
google_mobile_ads : ^1.0.0
Now, run flutter pub get
2. Now we have to make some changes in our app level build.gradle file
compileSdkVersion 31
defaultConfig {
applicationId “com.example.googleAds”
minSdkVersion 19
targetSdkVersion 31
multiDexEnabled true
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Make sure that you have compileSdkVersion 28 or higher and minSdkVersion 19 or higher.
Make one variable of type RewardedAd and on of type bool. here, Variable of type RewardedAd will hold our rewarded ad and type bool will hold true if our rewarded ad is loaded else false.