How to Integrate the Google Mobile Ads SDK into a Flutter app

You decided to monetize your mobile application made by Flutter. In a previous article we were speaking about Google Mobile Ads SDK for Flutter (Beta) which is dedicated to easily implementing ads in the mobile app. Today, you will learn how to integrate the Google Mobile Ads SDK into a Flutter app. As soon as integration is complete, you will choose an ad format that is most appropriate for your application. For today, it can be a banner, full-screen, native, and rewarded ads.
Before starting
It is assumed that you have already installed and configured the following tools:
  • Flutter v 1.22.0 or higher
For the Android application development:
  • Android Studio 3.2 or higher;
  • Target Android API level 19 or higher;
  • compileSdkVersion to 28 or higher;
For iOS, you have the latest version of Xcode with enabled command-line tools. Since Google Mobile Ads SDK supports both AdMob and AdManager it would be very useful to create an AdMob account and register an Android and/or iOS app before starting the installation.
Installation of the Mobile Ads SDK
You should use this package as a library and run the command with Flutter: In will run an implicit flutter pub get and in pubspec.yaml will appear a line : Or if your editor support flutter pub get check your editor docs. In your Dart code, you can use:
Specific set up for Android
You should update AndroidManifest.xml. To do this, be sure that your AdMob app ID is included in the AndroidManifest.xml. It is a mandatory requirement. Otherwise, it may lead to a crash on the app launch. Be sure to add the AdMob app ID, which is shown in the AdMob UI, to the app's android/app/src/main/AndroidManifest.xml file. Add a <meta-data> tag with the name com.google.android.gms.ads.APPLICATION_ID for this. Now find your application ID in the AdMob UI. You should insert your own AdMob application ID into quotation marks for android:value like it shown below:
How to configure AndroidManifest.xml and the app ID.
Add a <meta-data> tag with android:name="com.google.android.gms.ads.APPLICATION_ID" for adding your AdMob app ID which is defined in the AdMob UI into the AndroidManifest.xml file. Also, you should insert your AdMob application ID into quotation marks for android:value. You have to be sure to add the <meta-data> tag as shown above. Otherwise, it will lead to a crash with the message:
Specific set up for iOS
You should update your Info.plist. To do this in your app's ios/Runner/Info.plist file, you have to add a GADApplicationIdentifier key with a string value of your AdMob app ID which is defined in the AdMob UI: The same value must be passed when you initialize the plugin in your Dart code. It's a mandatory requirement.
How to configure your Info.plist
For the Info.plist you should make the following changes:
  • Add a GADApplicationIdentifier key with a string value of your AdMob app ID defined in the AdMob UI.
  • Add a SKAdNetworkItems key with SKAdNetworkIdentifier values for Google (cstr6suwn9.skadnetwork) and select additional buyers who have provided these values to Google.
Here is the list of Google and third-party buyers SKAdNetwork identifiers:
NetworkSKAdNetwork Identifier
Googlecstr6suwn9.skadnetwork
Aarki4fzdc2evr5.skadnetwork
Adform2fnua5tdw4.skadnetwork
Adikteevydx93a7ass.skadnetwork
Affle India5a6flpkh64.skadnetwork
Amazonp78axxw29g.skadnetwork
Appierv72qych5uu.skadnetwork
Beeswax.ioc6k4g5qg8m.skadnetwork
Bideases39g8k73mm.skadnetwork
Bigabid3qy4746246.skadnetwork
Centro3sh42y64q3.skadnetwork
Chartboostf38h382jlk.skadnetwork
Chartboostf38h382jlk.skadnetwork
Criteohs6bdukanm.skadnetwork
Cross Installprcb7njmu6.skadnetwork
i-mobilev4nxqhlyqp.skadnetwork
InMobiwzmmz9fp6w.skadnetwork
Jamppyclnxrl5pm.skadnetwork
LifeStreet Mediat38b2kh725.skadnetwork
Liftoff7ug5zh24hu.skadnetwork
Manage9rd848q2bz.skadnetwork
MediaMathn6fk4nfna4.skadnetwork
Mobvistakbd757ywx3.skadnetwork
Moloco Ads9t245vhmpl.skadnetwork
Realtime Technologies GmbH 4468km3ulz.skadnetwork
Remerge 2u9pt9hc89.skadnetwork
RTB House 8s468mfl3y.skadnetwork
ScaleMonk av6w8kgt66.skadnetwork
Sift Media klf5c3l5u5.skadnetwork
Smadex ppxm28t8ap.skadnetwork
Snap 424m5254lk.skadnetwork
The Trade Desk uw77j35x4d.skadnetwork
Unicorn 578prtvx9j.skadnetwork
Unity Ads 4dzt52r2t5.skadnetwork
Verizon Media e5fvkxwrpn.skadnetwork
Yahoo! Japan Ads8c4e2ghe7u.skadnetwork
Yandexzq492l623r.skadnetwork
Zucks3qcr597p9d.skadnetwork
Here is an example how your info.plist should look like:
How to initialize the Google Mobile Ads SDK
At the very beginning of the loading ads, you should initialize the Mobile Ads SDK by calling MobileAds.instance.initialize(). You only have to do it once. It, in turn, will initialize the SDK and return a Future that finishes once exactly initialization is complete. Sometimes its takes a 30-second timeout, but it's normal.