Migrate to GAM Next-Gen
Move from the GAM module (legacy) to the GAM Next-Gen module when you use the GMA Next-Gen SDK.
The GMA Next-Gen SDK can't run in the same app as the legacy Google Mobile Ads SDK. The Experiences BlazeGAM API matches between modules. You change:
- The Ad Manager app ID in the Manifest (required by GMA Next-Gen)
- The Gradle dependency
- Package imports
- Places where you use Google ad objects directly
1. Set your Ad Manager app ID
Add your Ad Manager app ID to AndroidManifest.xml. Find it in Google Ad Manager under Inventory > Apps (Google labels it App ID). The GMA Next-Gen SDK requires this value:
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-XXXXXXXXXXXXXXXX~YYYYYYYYYY" />For how failed initialization reaches your callbacks, see Initialization.
2. Swap the dependency
In your app build.gradle, replace the legacy artifact with the Next-Gen one:
- implementation "com.blaze:gam:<version>"
+ implementation "com.blaze:gam-next-gen:<version>"Exclude the legacy Google Mobile Ads SDK so nothing can reintroduce it. See Google migration guidance:
configurations.all {
exclude group: 'com.google.android.gms', module: 'play-services-ads'
exclude group: 'com.google.android.gms', module: 'play-services-ads-lite'
}Don't keep both com.blaze:gam and com.blaze:gam-next-gen in the same app. The build fails with duplicate-class errors.
3. Update your imports
Change the package from com.blaze.gam to com.blaze.gam.nextgen:
- import com.blaze.gam.BlazeGAM
- import com.blaze.gam.banner.BlazeGAMBannerAdsDelegate
- import com.blaze.gam.custom_native.BlazeGAMCustomNativeAdsDelegate
+ import com.blaze.gam.nextgen.BlazeGAM
+ import com.blaze.gam.nextgen.banner.BlazeGAMBannerAdsDelegate
+ import com.blaze.gam.nextgen.custom_native.BlazeGAMCustomNativeAdsDelegateA project-wide find-and-replace of com.blaze.gam. with com.blaze.gam.nextgen. covers most cases.
4. Update the Google ad types you use
BlazeGAM methods and callbacks stay the same. Update only where you read Google ad objects from Experiences data classes:
| Property | Legacy type | Next-Gen type |
|---|---|---|
BlazeGAMBannerAdsAdData.bannerView | AdManagerAdView | AdView |
BlazeCustomNativeAdData.nativeAd | Legacy Google native ad type | CustomNativeAd |
Update imports and casts wherever you handle the banner view or the custom native ad object.
What stays the same
These BlazeGAM calls don't change:
BlazeGAM.enableBannerAds(context, delegate)
BlazeGAM.enableCustomNativeAds(context, defaultAdsConfig, delegate)
BlazeGAM.disableBannerAds()
BlazeGAM.disableCustomNativeAds()Also unchanged:
- Delegate method names
- Custom targeting
- Publisher-provided ID
- Network extras
You don't add a separate init call. See Initialization for how BlazeGAM handles GMA Next-Gen initialization.
Checklist
- Experiences SDK 1.20 or later
- Ad Manager app ID is in
AndroidManifest.xml - Dependency is
com.blaze:gam-next-genonly (nocom.blaze:gam) - Legacy Google Mobile Ads SDK is excluded
- Imports use
com.blaze.gam.nextgen.* - If you use Google ad objects directly, types updated to
AdView/CustomNativeAd - Ads load and events fire as before
Updated about 2 months ago
