The quick start guide shows you how to initialize the Next Gen Mobile Ads SDK.
During that initialization call, mediation adapters also
get initialized. It is important to wait for initialization to complete before
you load ads in order to verify full participation from every ad network on the
first ad request.
The following sample code shows how you can check each adapter's initialization
status prior to making an ad request.
Kotlin
importcom.google.android.libraries.ads.mobile.sdk.MobileAdsimportcom.google.android.libraries.ads.mobile.sdk.initialization.InitializationConfigimportkotlinx.coroutines.CoroutineScopeimportkotlinx.coroutines.Dispatchersimportkotlinx.coroutines.launchclassMainActivity:AppCompatActivity(){overridefunonCreate(savedInstanceState:Bundle?){super.onCreate(savedInstanceState)setContentView(R.layout.activity_main)valbackgroundScope=CoroutineScope(Dispatchers.IO)backgroundScope.launch{// Initialize Next Gen Mobile Ads SDK on a background thread.MobileAds.initialize(this@MainActivity,InitializationConfig.Builder("SAMPLE_APP_ID").build()){initializationStatus->
for((adapterName,adapterStatus)ininitializationStatus.adapterStatusMap){Log.d("MyApp",String.format("Adapter name: %s, Status code: %s, Status string: %s, Latency: %d",adapterName,adapterStatus.initializationState,adapterStatus.description,adapterStatus.latency,),)}// Adapter initialization is complete.}// Other methods on MobileAds can now be called.}}}
Java
importcom.google.android.libraries.ads.mobile.sdk.MobileAds;importcom.google.android.libraries.ads.mobile.sdk.initialization.AdapterStatus;importcom.google.android.libraries.ads.mobile.sdk.initialization.InitializationConfig;publicclassMainActivityextendsAppCompatActivity{protectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);newThread(()->{// Initialize Next Gen Mobile Ads SDK on a background thread.MobileAds.initialize(this,newInitializationConfig.Builder("SAMPLE_APP_ID").build(),initializationStatus->{Map<String,AdapterStatus>adapterStatusMap=initializationStatus.getAdapterStatusMap();for(StringadapterClass:adapterStatusMap.keySet()){AdapterStatusadapterStatus=adapterStatusMap.get(adapterClass);Log.d("MyApp",String.format("Adapter name: %s, Status code: %s, Status description: %s,"+" Latency: %d",adapterClass,adapterStatus.getInitializationState(),adapterStatus.getDescription(),adapterStatus.getLatency()));}// Adapter initialization is complete.});// Other methods on MobileAds can now be called.}).start();}}
Exclude com.google.android.gms modules in mediation integrations
Mediation adapters continue to depend on the current Next Gen Mobile Ads SDK. However,
Next Gen Mobile Ads SDK includes all classes required by mediation adapters.
To avoid compile errors related to duplicate symbols, you need to exclude the
current Next Gen Mobile Ads SDK from being pulled in as a dependency by mediation
adapters.
In your app-level build.gradle file, exclude both play-services-ads and
play-services-ads-lite modules globally from all dependencies.
Check which ad network adapter class loaded the ad
Here is some sample code that logs the ad network class name for a banner ad:
Kotlin
BannerAd.load(BannerAdRequest.Builder("AD_UNIT_ID",AdSize.BANNER).build(),object:AdLoadCallback<BannerAd>{overridefunonAdLoaded(ad:BannerAd){Log.d("MyApp","Adapter class name: "+ad.getResponseInfo().mediationAdapterClassName)}})
Java
BannerAd.load(newBannerAdRequest.Builder("AD_UNIT_ID",AdSize.BANNER).build(),newAdLoadCallback<BannerAd>(){@OverridepublicvoidonAdLoaded(@NonNullBannerAdad){Log.d("MyApp","Adapter class name: "+ad.getResponseInfo().getMediationAdapterClassName());}});
Use banner ads with mediation
Make sure to disable refresh in all third-party ad source UIs for banner ad
units used in mediation. This prevents a
double refresh since Ad Manager also triggers a refresh
based on your banner ad unit's refresh rate.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eThis guide provides instructions for integrating a mediation adapter with your Android app, enabling you to display ads from various ad networks.\u003c/p\u003e\n"],["\u003cp\u003eBefore integrating mediation, ensure you've integrated the desired ad formats (banner, interstitial, native, rewarded, rewarded interstitial) into your app.\u003c/p\u003e\n"],["\u003cp\u003eInitialize the Mobile Ads SDK, which also initializes mediation adapters, and wait for initialization to complete before loading ads for optimal ad network participation.\u003c/p\u003e\n"],["\u003cp\u003eExclude the \u003ccode\u003eplay-services-ads\u003c/code\u003e and \u003ccode\u003eplay-services-ads-lite\u003c/code\u003e modules from your app's \u003ccode\u003ebuild.gradle\u003c/code\u003e file to avoid compile errors due to duplicate symbols.\u003c/p\u003e\n"],["\u003cp\u003eFor banner ads used in mediation, disable refresh in third-party ad source UIs to prevent double refresh.\u003c/p\u003e\n"]]],[],null,["\u003cbr /\u003e\n\nThis guide shows you how to integrate a mediation adapter with your\nAndroid app.\n\nPrerequisites\n\nBefore you can integrate mediation for an ad format, you need to integrate that\nad format into your app:\n\n- [Banner Ads](/ad-manager/mobile-ads-sdk/android/early-access/nextgen/banner)\n- [Interstitial Ads](/ad-manager/mobile-ads-sdk/android/early-access/nextgen/interstitial)\n- [Native Ads](/ad-manager/mobile-ads-sdk/android/early-access/nextgen/native)\n- [Rewarded Ads](/ad-manager/mobile-ads-sdk/android/early-access/nextgen/rewarded)\n- [Rewarded Interstitial\n Ads](/ad-manager/mobile-ads-sdk/android/early-access/nextgen/rewarded-interstitial)\n\nNew to mediation? Read\n\n[Introduction to mediation](//support.google.com/admanager/answer/6272813).\n\nInitialize Next Gen Mobile Ads SDK\n\nThe quick start guide shows you how to [initialize the Next Gen Mobile Ads SDK](/ad-manager/mobile-ads-sdk/android/early-access/nextgen/quick-start#initialize_the_mobile_ads_sdk).\nDuring that initialization call, mediation adapters also\nget initialized. It is important to wait for initialization to complete before\nyou load ads in order to verify full participation from every ad network on the\nfirst ad request.\n| **Important:** Bidding adapters require you to explicitly initialize Next Gen Mobile Ads SDK.\n\nThe following sample code shows how you can check each adapter's initialization\nstatus prior to making an ad request. \n\nKotlin \n\n import com.google.android.libraries.ads.mobile.sdk.MobileAds\n import com.google.android.libraries.ads.mobile.sdk.initialization.InitializationConfig\n import kotlinx.coroutines.CoroutineScope\n import kotlinx.coroutines.Dispatchers\n import kotlinx.coroutines.launch\n\n class MainActivity : AppCompatActivity() {\n override fun onCreate(savedInstanceState: Bundle?) {\n super.onCreate(savedInstanceState)\n setContentView(R.layout.activity_main)\n\n val backgroundScope = CoroutineScope(Dispatchers.IO)\n backgroundScope.launch {\n // Initialize Next Gen Mobile Ads SDK on a background thread.\n MobileAds.initialize(this@MainActivity, InitializationConfig.Builder(\"\u003cvar class=\"readonly\" translate=\"no\"\u003eSAMPLE_APP_ID\u003c/var\u003e\").build()) {\n initializationStatus -\\\u003e\n for ((adapterName, adapterStatus) in initializationStatus.adapterStatusMap) {\n Log.d(\n \"MyApp\",\n String.format(\n \"Adapter name: %s, Status code: %s, Status string: %s, Latency: %d\",\n adapterName,\n adapterStatus.initializationState,\n adapterStatus.description,\n adapterStatus.latency,\n ),\n )\n }\n // Adapter initialization is complete.\n }\n // Other methods on MobileAds can now be called.\n }\n }\n }\n\nJava \n\n import com.google.android.libraries.ads.mobile.sdk.MobileAds;\n import com.google.android.libraries.ads.mobile.sdk.initialization.AdapterStatus;\n import com.google.android.libraries.ads.mobile.sdk.initialization.InitializationConfig;\n\n public class MainActivity extends AppCompatActivity {\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_main);\n\n new Thread(\n () -\\\u003e {\n // Initialize Next Gen Mobile Ads SDK on a background thread.\n MobileAds.initialize(\n this,\n new InitializationConfig.Builder(\"\u003cvar class=\"readonly\" translate=\"no\"\u003eSAMPLE_APP_ID\u003c/var\u003e\")\n .build(),\n initializationStatus -\\\u003e {\n Map\\\u003cString, AdapterStatus\\\u003e adapterStatusMap =\n initializationStatus.getAdapterStatusMap();\n for (String adapterClass : adapterStatusMap.keySet()) {\n AdapterStatus adapterStatus = adapterStatusMap.get(adapterClass);\n Log.d(\n \"MyApp\",\n String.format(\n \"Adapter name: %s, Status code: %s, Status description: %s,\"\n + \" Latency: %d\",\n adapterClass,\n adapterStatus.getInitializationState(),\n adapterStatus.getDescription(),\n adapterStatus.getLatency()));\n }\n // Adapter initialization is complete.\n });\n // Other methods on MobileAds can now be called.\n })\n .start();\n }\n }\n\nExclude `com.google.android.gms` modules in mediation integrations\n\nMediation adapters continue to depend on the current Next Gen Mobile Ads SDK. However,\nNext Gen Mobile Ads SDK includes all classes required by mediation adapters.\nTo avoid compile errors related to duplicate symbols, you need to exclude the\ncurrent Next Gen Mobile Ads SDK from being pulled in as a dependency by mediation\nadapters.\n\nIn your app-level `build.gradle` file, exclude both `play-services-ads` and\n`play-services-ads-lite` modules globally from all dependencies. \n\n configurations {\n all {\n exclude(group = \"com.google.android.gms\", module = \"play-services-ads\")\n exclude(group = \"com.google.android.gms\", module = \"play-services-ads-lite\")\n }\n }\n\nCheck which ad network adapter class loaded the ad\n\nHere is some sample code that logs the ad network class name for a banner ad: \n\nKotlin \n\n BannerAd.load(\n BannerAdRequest.Builder(\"\u003cvar class=\"readonly\" translate=\"no\"\u003eAD_UNIT_ID\u003c/var\u003e\", AdSize.BANNER).build(),\n object : AdLoadCallback\u003cBannerAd\u003e {\n override fun onAdLoaded(ad: BannerAd) {\n Log.d(\n \"MyApp\", \"Adapter class name: \" +\n ad.getResponseInfo().mediationAdapterClassName\n )\n }\n }\n )\n\nJava \n\n BannerAd.load(\n new BannerAdRequest.Builder(\"\u003cvar class=\"readonly\" translate=\"no\"\u003eAD_UNIT_ID\u003c/var\u003e\", AdSize.BANNER).build(),\n new AdLoadCallback\u003cBannerAd\u003e() {\n @Override\n public void onAdLoaded(@NonNull BannerAd ad) {\n Log.d(\"MyApp\",\n \"Adapter class name: \" + ad.getResponseInfo().getMediationAdapterClassName());\n }\n }\n );\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nUse banner ads with mediation\n\nMake sure to disable refresh in all third-party ad source UIs for banner ad\nunits used in mediation. This prevents a\ndouble refresh since Ad Manager also triggers a refresh\nbased on your banner ad unit's refresh rate.\n\n\u003cbr /\u003e\n\nUS states privacy laws and GDPR\n\nIf you need to comply with the [U.S. states privacy\nlaws](//support.google.com/admanager/answer/9561023) or [General Data Protection\nRegulation (GDPR)](//support.google.com/admanager/answer/7666366), follow the\nsteps in [US state regulations\nsettings](//support.google.com/admanager/answer/10115735) or [GDPR\nsettings](//support.google.com/admanager/answer/10113006#adding_ad_partners_to_published_gdpr_messages) to add your\nmediation partners in Ad Manager Privacy \\& messaging's\nUS states or GDPR ad partners list. Failure to do so can lead to partners\nfailing to serve ads on your app.\n\nLearn more about enabling [restricted data processing\n(RDP)](/ad-manager/mobile-ads-sdk/android/early-access/nextgen/privacy/us-states) and obtaining GDPR consent with the\n[Google User Messaging Platform (UMP) SDK](/ad-manager/mobile-ads-sdk/android/privacy)."]]