What does MobileAds.initialize() exactly do?

419 views
Skip to first unread message

Sean Oh

unread,
May 5, 2021, 8:25:45 PM5/5/21
to Google Mobile Ads SDK Developers
I have just updated play-services-ads from 19.x.x to 20.1.0 (Android). I noticed that I need an extra step to initialize the SDK.
What exactly happens when I call MobileAds.initialize()? It seems not calling it also displays the banner ads without any problem.

Also, what happens if initialization fails and I just make an attempt to load an ad by calling adManagerAdView.loadAd(AdRequest.Builder.build()) ?

Thank you,
Sean

Mobile Ads SDK Forum Advisor Prod

unread,
May 5, 2021, 11:17:47 PM5/5/21
to seano...@gmail.com, google-adm...@googlegroups.com

Hi Sean,

Thank you for reaching out to us.

When you called MobileAds.initialize() it initializes the SDK and calls back a completion listener once initialization, it also helps you to reduce latency on the session's first ad request. With regards to if initialization fail, most likely if this happened your app may encounter error or your app may crash.

Regards,

Google Logo
Princess Pamela Pineda
Mobile Ads SDK Team
 

 

ref:_00D1U1174p._5004Q2GKLb2:ref

Sean Oh

unread,
May 9, 2021, 9:00:30 PM5/9/21
to Google Mobile Ads SDK Developers
Hi,

Thank you for getting back to me.

When I call the function,

`initializationStatus` comes back with a HashMap with one element of `AdapterStatus` with state of `NOT_READY`.
What does this indicate?

You mentioned the app will encounter error or crash if initialization fails, but how do I know if initialization has failed?
My goal is to add a dialog to retry if initialization fails as banner ads are necessary for the app (if initialization succeeded and we just have no fill, that's Okay).

Do I need to worry about the `OnInitializationCompleteListener` at all?

Thank you,
Sean

Mobile Ads SDK Forum Advisor Prod

unread,
May 10, 2021, 2:35:24 AM5/10/21
to seano...@gmail.com, google-adm...@googlegroups.com

Hi Sean,

Thank you for your response.

Can you confirm if your are using mediation? If yes, could you please provide us sample app with minimum modification? You can send it via Reply privately to author option or send it directly to mobileads...@gmail.com?

With regard to your concern of not_ready, it show if your ads are not yet ready to show. Then with regards to initialization has failed, mostly the initialization failed returned if you miss something in implementation using the SDK. Also, you don't need to worry about the OnInitializationCompleteListener since it calls back a completion listener once initialization is complete and needs to be done only once, ideally at app launch.

Sean Oh

unread,
May 10, 2021, 3:34:21 PM5/10/21
to Google Mobile Ads SDK Developers
Hi,

I'm not using mediation for banner ads.

Now that I don't need to worry about onInitializationCompleteListener, can I just not utilize the callback at all? For example, instead of calling MobileAds.initialize(activity, status -> { ... }), can I just call MobileAds.initialize(activity) ?
I'm calling this function in the splash screen so I want users to go to the main screen ASAP without waiting for banner ads to be ready.

Thank you,
Sean

Mobile Ads SDK Forum Advisor Prod

unread,
May 10, 2021, 4:53:14 PM5/10/21
to seano...@gmail.com, google-adm...@googlegroups.com
Hi Sean,

Thank you for the response back. If you look here it shows you how the initializer() has been changed and using it going forward. Also depending on whether you are using adaptive , which is suggested, or smart can also have an affect on which callback you will need to use.

Regards,
Google Logo
William Pescherine
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2GKLb2:ref

Sean Oh

unread,
May 10, 2021, 7:16:20 PM5/10/21
to Google Mobile Ads SDK Developers
Awesome. Thank you!
I was looking at the AdManager's banner ad documentation and it had the call back in the snippet, now it's gone!

Reply all
Reply to author
Forward
0 new messages