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 generating 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 is required, including updating the AndroidManifest.xml for Android and Info.plist for iOS with your Ad Manager app ID.

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

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 Ad Manager app ID. For details, see Find 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 Ad Manager 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 Ad Manager 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 Ad Manager 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. Ad Manager 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