Guide to migrating to version 6
Warning
Be sure to update to the latest adapter versions (Yandex Mediation and adapters for third-party mediation networks). Otherwise, errors from improper adapter integration might occur, preventing the ad 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 your ad type:
Use the BannerAdSize.stickySize(Context context, int width) method to create an adaptive sticky banner.
An adaptive sticky banner is a small, automatically updated ad placed at the bottom or top of the app screen.
The banner doesn't overlap the main app content and is often used in gaming apps.
The height of the sticky banner is determined automatically, adapting to the device screen size and not exceeding 15% of the screen height.
Warning
Starting with version 6.0.0, adaptive sticky banners can refresh automatically.
If you previously implemented auto-refresh for a sticky-banner, you should now disable it.
To create an adaptive inline banner, use the BannerAdSize.inlineSize(Context context, int width, int maxHeight) method.
An adaptive inline banner is a flexible banner ad format that ensures maximum efficiency by optimizing ad size for each device.
The banner height is selected automatically and can reach the height of the device screen.
Typically, this format is used in feed-based apps or contexts where it's acceptable to primarily focus user attention on ads.
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
The approach to creating and loading advertisements has been revised. 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.
|
Loading ads |
SDK 5 One object is now used both for loading and serving ads: Kotlin
Java
SDK 6
Once the ad is loaded (by calling the Kotlin
Java
|
|
Ad serving |
SDK 5 Check if the ad is loaded before displaying it. Kotlin
Java
SDK 6 You don't need to check whether the ad has been 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 ads
The approach to creating and loading advertisements has been revised. 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.
|
Loading ads |
SDK 5 One object is now used both for loading and serving ads: Kotlin
Java
SDK 6
Once the ad is loaded (by calling the Kotlin
Java
|
|
Ad serving |
SDK 5 Kotlin
Java
SDK 6 You don't need to check whether the ad has been 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 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
|
App open ads
Added a new ad format: app open ads. To learn more, see App open ads.
Yandex Mediation
Warning
Be sure to update to the latest adapter versions (Yandex Mediation and adapters for third-party mediation networks). Otherwise, errors from improper adapter integration might occur, preventing the ad 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 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.