Set up Google Mobile Ads Unity Plugin

  • The Google Mobile Ads Unity plugin allows Unity developers to serve Google mobile ads on Android and iOS apps using a C# interface.

  • Prerequisites for using the plugin include Unity Editor 2019.4 or higher and specific version requirements for Xcode, iOS, and Android API levels depending on the deployment platform.

  • You can import the Mobile Ads for Unity plugin using OpenUPM-CLI, OpenUPM, or by importing a .unitypackage from GitHub.

  • Before loading ads, you need to set your Android and iOS AdMob app IDs in the Unity editor settings and initialize the Google Mobile Ads SDK by calling MobileAds.Initialize().

  • AdMob offers various ad formats for Unity apps, including Banner, Interstitial, Native, Rewarded, Rewarded interstitial, and App open ads, each with distinct characteristics and use cases.

The Google Mobile Ads Unity plugin lets Unity developers serve Google mobile ads on Android and iOS apps without having to write Java or Objective-C code. The plugin provides a C# interface for requesting ads that is used by C# scripts in your Unity project.

This guide is intended for publishers who want to monetize a Unity app.

Prerequisites

  • Use Unity Editor 2019.4 or higher.
    • We recommend 2022.2 or higher.
  • To deploy to iOS
    • Xcode 16.0 or higher
    • Target iOS 13.0 or higher
    • CocoaPods
  • To deploy to Android
    • Minimum Android API level of 23 or higher
    • Target Android API level 35 or higher

Android API level is set in Project Settings > Player > Android > Other Settings > Other Settings.

Import the Mobile Ads for Unity plugin

OpenUPM-CLI

If you have the OpenUPM CLI installed, you can install the OpenUPM registry with the following command:

openupm add com.google.ads.mobile

Remove .unitypackage plugin assets

If you are migrating from using a .unitypackage to using OpenUPM, you must manually uninstall the assets from the old location. Remove the following directories that were imported from the .unitypackage:

  • Assets/ExternalDependencyManager
  • Assets/GoogleMobileAds
  • Assets/Plugins/Android/googlemobileads-unity.aar
  • Assets/Plugins/Android/GoogleMobileAdsPlugin
  • Assets/Plugins/iOS/GADUAdNetworkExtras
  • Assets/Plugins/iOS/unity-plugin-library.a

OpenUPM with UI

  1. Open the package manager settings by selecting the Unity menu option Edit > Project Settings > Package Manager.
  2. Add OpenUPM as a scoped registry to the Package Manager window:

    Name: OpenUPM
    URL: https://package.openupm.com
    Scopes: com.google
    
  3. Open the package manager menu by selecting the Unity menu option Window > Package Manager.

  4. Set the manager scope drop-down to select My Registries.

  5. Select the Google Mobile Ads for Unity package from the package list and press Install.

Remove .unitypackage plugin assets

If you are migrating from using a .unitypackage to using OpenUPM, you must manually uninstall the assets from the old location. Remove the following directories that were imported from the .unitypackage:

  • Assets/ExternalDependencyManager
  • Assets/GoogleMobileAds
  • Assets/Plugins/Android/googlemobileads-unity.aar
  • Assets/Plugins/Android/GoogleMobileAdsPlugin
  • Assets/Plugins/iOS/GADUAdNetworkExtras
  • Assets/Plugins/iOS/unity-plugin-library.a

OpenUPM

  1. Fetch the version tag of the most recent release. The tag returned, excluding the v prefix, is the Google Mobile Ads Unity Plugin version.

    • macOS and Linux

      curl -sS https://api.github.com/repos/googleads/googleads-mobile-unity/releases/latest | jq -r '.tag_name'
    • Windows PowerShell

      (Invoke-RestMethod -Uri "https://api.github.com/repos/googleads/googleads-mobile-unity/releases/latest"