How to Setup AdMob

Use this guide to configure the raw Google AdMob integration — the ad provider used whenever AdsProviderType.AdMob is selected. Based directly on the Google Mobile Ads Unity plugin (version 8.7.0, imported as a raw plugin under Assets/GoogleMobileAds/, not via UPM) and the project's GoogleAdMobProxy implementation.

Architecture Context

Ad provider selection is centralized in AdsManager.Initialize(): it reads AdsProviderType from RemoteConfigManager.FetchedAdsProvider (falling back to GameConfig.AdsProviderMobile if remote config hasn't returned a value yet), overridden by GameConfig.AdsProviderEditor in the Unity Editor and forced to Fake on WebGL builds. When the resolved provider is AdMob, AdsManager instantiates a GoogleAdMobProxy, which is the only class in this guide's scope.

  • App ID (one per platform, format ca-app-pub-XXXXXXXXXXXXXXXX~YYYYYYYYYY) lives in a single asset: Assets/GoogleMobileAds/Resources/GoogleMobileAdsSettings.asset (adMobAndroidAppId / adMobIOSAppId fields). This is also the asset the Google plugin reads to inject the required Android manifest meta-data and iOS Info.plist entries at build time — you don't touch those files by hand.
  • Ad Unit IDs (one per format × platform, format ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY — note the /, not ~) are plain const string fields in AdsConstants.cs (AdMobBannerIDAndroid, AdMobInterstitialIDAndroid, AdMobRewardedIDAndroid, and the matching ...IDiOS versions), plus a parallel set of ...Test constants that point at Google's public sample ad units (ca-app-pub-3940256099942544/...) — never edit the test constants.
  • GoogleAdMobProxy.SetIDs() picks between the real and test constants based on GameConstants.IsDebugBuild(), per platform (#if UNITY_ANDROID / #elif UNITY_IOS). There is no manual switch — whichever build configuration you use decides this automatically.
  • Before requesting any ad, GoogleAdMobProxy.Initialize() runs Google's User Messaging Platform (UMP) consent flow (ConsentInformation.Update → ConsentForm.LoadAndShowConsentFormIfRequired) and only calls MobileAds.Initialize() once ConsentInformation.CanRequestAds() is true.

Pre-Setup Checklist

  • An AdMob account with an app registered for each platform you ship, and that app's App ID in hand.
  • Ad units created in the AdMob console for every format you actually use (Banner / Interstitial / Rewarded), per platform.
  • The Google Mobile Ads Unity plugin, version 8.7.0, imported under Assets/GoogleMobileAds/.
  • Decide how the provider gets selected for your build: a hardcoded GameConfig.AdsProviderMobile / AdsProviderEditor value, or a remote config "AdsProvider" key set to "AdMob".

Main Procedure

Step 1: Set the App ID

Open Assets/GoogleMobileAds/Resources/GoogleMobileAdsSettings.asset (or use the Assets → Google Mobile Ads → Settings menu the plugin adds) and set adMobAndroidAppId and adMobIOSAppId to your real per-platform App IDs from the AdMob console.

Step 2: Set the Ad Unit IDs

In AdsConstants.cs, replace the six production constants with your real ad unit IDs:

public const string AdMobBannerIDAndroid = "ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY";
public const string AdMobInterstitialIDAndroid = "ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY";
public const string AdMobRewardedIDAndroid = "ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY";
// ...and the matching AdMob...IDiOS constants

Leave the ...Test constants as they are — they're Google's shared sample ad units and work the same in every project.

Step 3: Select AdMob as the Active Provider

Set GameConfig.AdsProviderMobile (and AdsProviderEditor, for testing in-editor) to AdsProviderType.AdMob, or drive it from remote config by setting the "AdsProvider" key to "AdMob".

If you present an App Tracking Transparency prompt on iOS, set userTrackingUsageDescription on GoogleMobileAdsSettings.asset — it's blank by default. For consent testing during development, add your test device's hashed ID to TestDeviceIDs.List so RequestConsentInfoUpdate() shows the EEA consent form on demand instead of only for real EEA users.

Step 5: Validate

  • Confirm Debug.Logs from GoogleAdMobProxy show ads loading ("Loading interstitial ad." / "...rewarded ad." / banner load callbacks) after INITIALIZED fires.
  • In a debug build, confirm the Test ad unit IDs are being used (ads show Google's placeholder test creative). In a release build, confirm the real IDs are used instead.

Common Edit Recipes

Recipe A: Rotate an Ad Unit ID

If you create a new ad unit in the AdMob console (or need to replace one that's been disabled), just update the matching constant in AdsConstants.cs — GoogleAdMobProxy always reads from there, no other code changes needed.

Recipe B: Force Test Ads in a Specific Build

Ad selection is entirely driven by GameConstants.IsDebugBuild(). To force test ads without touching production constants, use whatever build configuration makes that method return true (rather than editing AdsConstants.cs directly).

Troubleshooting

  • Ads never load, no errors either. Check adMobAndroidAppId / adMobIOSAppId aren't left as placeholder values, and that ConsentInformation.CanRequestAds() is actually returning true — ads are never requested before consent is resolved.
  • "...ad is not ready yet." when trying to show. Interstitial and Rewarded ads are loaded lazily and reloaded on a timer (GoogleAdMobProxy.OnPostTick) — ShowInterstitial() / ShowRewarded() only work once a load has actually completed; call LoadInterstitial() / LoadRewarded() well before you intend to show.
  • Real ads appear in a debug build, or test ads appear in production. This is entirely controlled by GameConstants.IsDebugBuild() — confirm that returns the value you expect for the build configuration in question.
  • Consent form never appears during testing. Add your device to TestDeviceIDs.List and confirm DebugGeography.EEA is set on the debug settings — without it, the consent form only appears for users Google detects as actually being in the EEA.