MobileAds.initialize(Context, String) is deprecated


Before it looked like this (passing R.string.admob_application_id):

MobileAds.initialize(this, getString(R.string.admob_application_id));

MobileAds method .initialize(Context context, String applicationCode)
now reads:

This method is deprecated. Use initialize(Context, OnInitializationCompleteListener) instead.

Which reads:

Initializes the Google Mobile Ads SDK.
Call this method as early as possible to reduce latency on the session’s first ad request.
If this method is not called, the first ad request automatically initializes the Google Mobile Ads SDK.

MobileAds.Settings also had been deprecated.

What I have tried so far is to get the InitializationStatus per adapter:

MobileAds.initialize(this, initializationStatus -> {

    /* get the adapter status */
    Map<String, AdapterStatus> map = initializationStatus.getAdapterStatusMap();
    for (Map.Entry<String, AdapterStatus> entry : map.entrySet()) {
        AdapterStatus adapterStatus = entry.getValue();
        AdapterStatus.State state = adapterStatus.getInitializationState();
        Log.d(LOG_TAG, "key = " + entry.getKey() + ", state = " + + ", desc = " + adapterStatus.getDescription());

On an emulator it says READY, but .getDescription() has a rather confusing message:

Google Mobile Ads SDK initialization functionality unavailable for this session.
Ad requests can be made at any time.

On a physical device with internet connection it shows four more adapters:

key =, state = READY, desc = 
key =, state = NOT_READY, desc = Failed to create Adapter.
key =, state = NOT_READY, desc = Failed to create Adapter.
key =, state = NOT_READY, desc = Failed to create Adapter.
key =, state = NOT_READY, desc = Failed to create Adapter. reads READY, the other* read NOT_READY and Failed to create Adapter (there is no mediation set up, but it can load test ads).

MobileAds.initialize(this); also works (OnInitializationCompleteListener is optional).

It seems to work without the R.string.admob_application_id, therefore my actual question is:

Is setting R.string.admob_publisher_id and R.string.admob_application_id still required – or is it only the ad-unit ID now? Most of the documentation still uses the deprecated initialization method (alike the one shown above), therefore this isn’t clear.


Get started with AdMob in your Android project seems to answer the application ID part:

Add your AdMob App ID to your app’s AndroidManifest.xml file by adding the <meta-data> tag as shown below.

Important: This step is required as of Google Mobile Ads SDK v17.0.0. If you don’t add this <meta-data> tag, your app will crash with the message: "The Google Mobile Ads SDK was initialized incorrectly."

        <!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->

And the publisher ID still is required for Requesting Consent from European Users.

Answered By – Martin Zeitler

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published