Guide for migrating to version 6
Warning
Make sure to update your used Yandex mediation adapters and adapters for third-party mediation networks to the latest version. Older versions may cause adapter integration errors that can prevent your ads from being served.
Manual initialization
Manual SDK initialization process changed. You now need to deliver the callback to the MobileAds.initialize()
method when initializing the app.
MobileAds.initialize(this) {
// Now you can use ads
}
MobileAds.initialize(this, () -> {
// Now you can use ads
});
Banners
Renamed the AdSize
class to BannerAdSize
. Removed the fixedSize(int width, int height)
, flexibleSize(int width, int maxHeight)
, and stickySize(int width)
methods.
Use methods depending on the ad type:
Use the BannerAdSize.stickySize(Context context, int width)
method to create an adaptive sticky banner.
That is a small, automatically updated ad placed at the top or bottom of the app screen.
It does not overlap the main app content and is often used in game apps.
The height of a sticky banner is determined automatically, adapting to the screen size of the device and not taking up more than 15% of the screen height.
Warning
Version 6.0.0 added autorefresh support for adaptive sticky banners.
If you have previously implemented autorefresh for sticky banners, disable it.
To create an adaptive inline banner, use the BannerAdSize.inlineSize(Context context, int width, int maxHeight)
method.
Adaptive inline banners are a flexible format of banner advertising, providing maximum efficiency by optimizing the ad size on each device.
The height of the banner is adjusted automatically and might reach the device screen height.
Typically, that format is used in feed-based apps or contexts where it's okay to focus primarily on the ad.
For backward compatibility, we added the fixedSize(Context context, int width, int height)
method instead of fixedSize(int width, int height)
, but we don't recommend using it. Use inlineSize(Context context, int width, int maxHeight)
or stickySize(Context context, int width)
instead. In SDK 6.0.0, the height of the banner is calculated automatically and known before the ad request is sent. You can use this height in your screen layout.
Rewarded ads
We changed the approach to creating and loading ads. We now provide the RewardedAdLoader
loader object, which loads the ads, and the RewardedAd
ad object retrieved by loader callback methods from the RewardedAdLoadListener
.
To learn more about the new API, see the SDK reference.
Ad loading |
SDK 5 A single object for ad loading and rendering: Kotlin
Java
SDK 6
Once the ad is loaded (by calling the Kotlin
Java
|
Ad rendering |
SDK 5 Before showing the ad, see if it loaded. Kotlin
Java
SDK 6 You don't need to check to see if the ad is loaded. The ad is ready for rendering after a To render the ad, you need to pass Activity: Kotlin
Java
|
|
SDK 5 A class that combines ad loading and rendering. SDK 6 Interface of a loaded ad. Added the Kotlin
Java
|
Callback methods |
SDK 5 A single callback method interface that combines event loading and rendering: Kotlin
Java
SDK 6 The Removed the Added the Kotlin
Java
|
Cleaning the |
SDK 5 Call the SDK 6 The To clean an ad object, pass Kotlin
Java
|
Interstitial advertising
We changed the approach to creating and loading ads. We now provide the InterstitialAdLoader
loader object, which loads the ads, and the InterstitialAd
ad object retrieved by the loader callback methods from the InterstitialAdLoadListener
.
For more details about the new API, see the SDK reference.
Ad loading |
SDK 5 A single object for ad loading and rendering: Kotlin
Java
SDK 6
Once the ad is loaded (by calling the Kotlin
Java
|
Ad rendering |
SDK 5 Kotlin
Java
SDK 6 You don't need to check to see if the ad is loaded. The ad is ready for rendering after an To render the ad, you need to pass Activity: Kotlin
Java
|
|
SDK 5 A class that combines loading and rendering of an ad. SDK 6 Interface of a loaded ad. Added the Kotlin
Java
|
Callback methods |
SDK 5 A single callback method interface that combines event loading and rendering: Kotlin
Java
SDK 6 The Removed the Added the Kotlin
Java
|
Cleaning the |
SDK 5 Call the SDK 6 The To clean an ad object, pass Kotlin
Java
|
App open ad
Added a new ad format: app open ad. To learn more, see App open ads.
Yandex mediation
Warning
Make sure to update your used Yandex mediation adapters and adapters for third-party mediation networks to the latest version. Older versions may cause adapter integration errors that can prevent your ads from being served.
New adapter versions
Current versions of Yandex mediation adapters (as of SDK 6.0.1 release):
"com.yandex.ads.mediation:mobileads-adcolony": "4.8.0.6",
"com.yandex.ads.mediation:mobileads-applovin": "11.11.2.0",
"com.yandex.ads.mediation:mobileads-chartboost": "9.3.1.0",
"com.yandex.ads.mediation:mobileads-google": "22.2.0.0",
"com.yandex.ads.mediation:mobileads-inmobi": "10.5.5.0",
"com.yandex.ads.mediation:mobileads-ironsource": "7.4.0.0",
"com.yandex.ads.mediation:mobileads-mintegral": "16.4.71.1",
"com.yandex.ads.mediation:mobileads-mytarget": "5.18.0.0",
"com.yandex.ads.mediation:mobileads-pangle": "5.3.0.4.1",
"com.yandex.ads.mediation:mobileads-startapp": "4.11.0.2",
"com.yandex.ads.mediation:mobileads-tapjoy": "13.1.2.0",
"com.yandex.ads.mediation:mobileads-unityads": "4.8.0.0",
"com.yandex.ads.mediation:mobileads-vungle": "6.12.1.3",
Current versions of adapters for third-party mediation platforms (as of SDK 6.0.1 release):
"com.yandex.ads.adapter:admob-mobileads": "6.0.1.0",
"com.yandex.ads.adapter:ironsource-mobileads": "6.0.1.0"
Renaming the Google AdMob (ex. AdMob) adapter
Renamed the com.yandex.ads.mediation:mobileads-admob
artifact as com.yandex.ads.mediation:mobileads-google
.
If you use the standardized Yandex mediation build, you don't have to do anything. If you add adapters manually, replace the gradle dependency in your project.
SDK 5
|
SDK 6
|
Here you can find the complete examples for integrations:
-
Link to GitHub.