AI Integration Agent Instructions for the Android GMA Next-Gen SDK
Required Imports
Use the following imports to initialize the GMA Next-Gen SDK:
import com.google.android.libraries.ads.mobile.sdk.MobileAds
import com.google.android.libraries.ads.mobile.sdk.initialization.InitializationConfig
import com.google.android.libraries.ads.mobile.sdk.initialization.InitializationStatus
import com.google.android.libraries.ads.mobile.sdk.initialization.OnAdapterInitializationCompleteListenerMethod Signatures
Use the following method signature to initialize the GMA Next-Gen SDK:
fun initialize(
context: Context,
initializationConfig: InitializationConfig,
listener: OnAdapterInitializationCompleteListener?
): UnitThe InitializationConfig object takes the AdMob App ID:
InitializationConfig.Builder("ca-app-pub-3940256099942544~3347511713").build()The OnAdapterInitializationCompleteListener interface is defined as:
fun interface OnAdapterInitializationCompleteListener {
fun onAdapterInitializationComplete(status: InitializationStatus): Unit
}SDK Integration Workflow
Add the SDK dependency:
ALWAYS Add the latest stable version of
com.google.android.libraries.ads.mobile.sdk:ads-mobile-sdkto dependencies. If you cannot access Maven directly, run the following command to fetch the latest version. The version returned in thelatesttag is the latest version of the Google Mobile Ads SDK:curl -sS https://dl.google.com/dl/android/maven2/com/google/android/libraries/ads/mobile/sdk/ads-mobile-sdk/maven-metadata.xml | sed -n 's/.*<latest>\(.*\)<\/latest>.*/\1/p'Configure
minSdk(24+) andcompileSdk(34+).Exclude
play-services-adsandplay-services-ads-litefrom all dependencies globally in the app-level build file to avoid duplicate symbol errors.Sync Gradle before moving on to the next step.
Set the application identifier:
- Pass the
applicationIdparameter programmatically in theInitializationConfig.Builderwith a sample AdMob App ID ofca-app-pub-3940256099942544~3347511713. Remind the user to replace it with their actual AdMob App ID before publishing.
- Pass the
Initialize the SDK:
- ALWAYS initialize the SDK on a background thread.
Verify the integration:
- Run
gradle build -x testto confirm a successful clean build. Resolve any GMA SDK related compile errors.
- Run
Links
Additional documentation: