Set up Google Mobile Ads Flutter Plugin

  • Integrating the Google Mobile Ads SDK into a Flutter app is the initial step for displaying ads and earning revenue.

  • Prerequisites for integrating the SDK include Flutter 3.27.0+, the latest Android Studio for Android, and the latest Xcode with enabled command-line tools for iOS.

  • You need to import the Google Mobile Ads SDK for Flutter plugin into your project.

  • Platform-specific setup requires adding your AdMob app ID to the AndroidManifest.xml for Android or Info.plist for iOS.

  • The Google Mobile Ads SDK must be initialized by calling MobileAds.instance.initialize() early in your app.

To deliver ads and earn revenue, integrate Google Mobile Ads Flutter Plugin into your Flutter app. To prepare your project, you import and initialize Google Mobile Ads Flutter Plugin before you request ads.

This guide covers importing and initializing Google Mobile Ads Flutter Plugin, and selecting an ad format.

Prerequisites

Before you continue, you need the following:

  • Flutter version 3.38.1 or higher.
  • For Android, the latest Android Studio version.
  • For iOS, the latest Xcode version with the enabled command-line tools. For details, see Install Flutter.
  • An AdMob app ID. For details, see Find and copy an app ID or ad unit ID.

Import Google Mobile Ads Flutter Plugin

To import Google Mobile Ads Flutter Plugin in your Flutter project, see google_mobile_ads.

Configure your app

After you import Google Mobile Ads Flutter Plugin, select one of the following platforms to configure your app:

Android

  1. In Android Studio, navigate to the android/app/src/main/AndroidManifest.xml file.

  2. In the AndroidManifest.xml file, add a <meta-data> tag to the <application> tag with the following properties:

    <manifest>
        <application>
            <!-- Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 -->
            <meta-data
                android:name="com.google.android.gms.ads.APPLICATION_ID"
                android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
        <application>
    <manifest>
    

    These properties must have the following values:

    • android:name: com.google.android.gms.ads.APPLICATION_ID.
    • android:value: your AdMob app ID.

    For details on setting up the AndroidManifest.xml file, see Set up Google Mobile Ads SDK (Legacy).

iOS

  1. In Xcode, navigate to the ios/Runner/Info.plist file.
  2. In the Info.plist file, add a GADApplicationIdentifier key with your AdMob app ID as a string.

    <key>GADApplicationIdentifier</key>
    <string>ca-app-pub-################~##########</string>
    

    For details on setting up a Info.plist file, see Update your Info.plist.

Initialize Google Mobile Ads Flutter Plugin

Before loading ads, initialize Google Mobile Ads Flutter Plugin by calling MobileAds.instance.initialize().

This method returns a Future that finishes after Google Mobile Ads Flutter Plugin initializes, or after 30 seconds.

The following example initializes Google Mobile Ads Flutter Plugin:

// Initialize the Mobile Ads SDK.
MobileAds.instance.initialize();

Select an ad format

After you import Google Mobile Ads Flutter Plugin, you can select an ad format to implement. AdMob offers the following ad formats:

Ad format Description Documentation
Banner Shows rectangular ads in a designated area. These ads refresh automatically, letting users view ads while remaining on the same screen. Set up banner ads
Interstitial Shows full-page ads in your app. Place these ads at natural transition points, such as between game levels. Interstitial ads
Native Lets you customize assets, such as headlines and calls to action, in your apps. When you customize the ad, you create ads that match your app's visual design. Load a native ad
Rewarded Lets users watch videos or take surveys to earn in-app rewards, like coins or extra lives. For each ad unit, you can specify reward values. Rewarded ads
Rewarded interstitial Lets you offer rewards, such as coins or extra lives, for ads that appear during app transitions. Rewarded interstitial ads
App open Appears when users open or go back to your app. The ad overlays the loading screen. App open ads