A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.google.com/admob/android/migration below:

SDK Migration | Android | Google for Developers

Last updated: February 7, 2025

This page covers migrations for current and previous versions.

Migrate from v23 to v24

The following subsections describe breaking changes and behavior differences between major version 23 and 24 of the Google Mobile Ads SDK.

The minimum Android API level is 23

Starting in version 24.0.0, the Google Mobile Ads SDK requires all apps to run on a minimum Android API level 23 to run. To adjust the API level, change the minSdk value in your app-level build.gradle file to 23 or higher.

Changes to optimized initialization and loading

By default, the OPTIMIZE_INITIALIZATION and OPTIMIZE_AD_LOADING flags are set to true. For more information on these flags, see Optimize initialization and loading.

Removed firebase-ads and firebase-ads-lite dependencies

Starting with version 24.0.0, SDK releases no longer distribute the firebase-ads and firebase-ads-lite dependencies. Use the play-services-ads dependency instead.

Removed deprecated orientation APIs for app open ads Simplified reward callback for mediation adapters

Version 24.0.0 adds the onUserEarnedReward() callback in MediationRewardedAdCallback and deprecates onUserEarnedReward(RewardItem). Mediation adapters must start calling onUserEarnedReward() when the user earns a reward.

When forwarding callbacks from mediation adapters, all Google Mobile Ads SDK versions return the reward defined in the AdMob UI in OnUserEarnedRewardListener.

Classes removed

The following classes were removed with no replacement:

Methods removed

The following methods were removed with no replacement:

Class Method RewardedInterstitialAdLoadCallback onRewardedInterstitialAdLoaded() onRewardedInterstitialAdFailedToLoad(int) onRewardedInterstitialAdFailedToLoad(LoadAdError) Methods deprecated

The following methods are deprecated with no replacement:

Class Method Adapter loadInterscrollerAd() RtbAdapter loadRtbInterscrollerAd() Migrate from v22 to v23

The following subsections describe breaking changes and behavior differences between major version 22 and 23 of the Google Mobile Ads SDK.

The minimum Android API level is 21

Starting in version 23.0.0, the Google Mobile Ads SDK requires all apps to be on a minimum Android API level 21 to run. To adjust the API level, change the value of minSdkVersion in your app-level build.gradle file to 21 or higher.

Deprecated Methods Removed/Replaced Migrate from v21 to v22

The following subsections describe breaking changes and behavior differences between major version 21 and 22 of the Google Mobile Ads SDK.

Use MobileAds.getVersion() to get the Google Mobile Ads SDK version

The MobileAds.getVersionString() method is removed in version 22.0.0 in favor of MobileAds.getVersion().

The new method returns the expected external version number—for example, 22.0.0. For more information about this change, see Use the new Google Mobile Ads SDK getVersion() method.

Removed or replaced methods

The following table lists the specific changes in version 22.0.0:

Migrate from v20 to v21

The following subsections describe breaking changes and behavior differences between major version 20 and 21 of the Google Mobile Ads SDK:

Update minSdkVersion to 19 or higher

Starting from version 21.0.0, the Google Mobile Ads SDK requires all apps to be on a minimum Android API level 19 to run. To adjust the API level, change the value of minSdkVersion in your app's build file to 19 or higher.

Enforce strict nullability

In preparation for enforcing strict nullability, @NonNull annotations are added in all the APIs that previously did not explicitly define nullability.

This change may break the Kotlin apps and apps that use Java null checking frameworks if there are null safety violations and did not previously handle null values in a safe way (see the Kotlin documentation on Null-safety ).

The addNetworkExtras() method that passes extra parameters as a NetworkExtras instance to a specific ad network adapter was deprecated in SDK version 20.3.0, and will be removed in version 21.0.0. Use the addNetworkExtrasBundle() method from the same AdRequest.Builder class instead.

Removal of location methods

The following location methods will be removed in version 21.0.0:

The location data is not used by Google to target ads. You should use third-party APIs to provide the information to third-party ad networks if required.

Custom event interfaces deprecation

Custom events enable publishers using AdMob Mediation to set up a waterfall ad source that isn't one of the AdMob supported ad sources.

All the custom event interfaces are deprecated in favor of the Adapter class and MediationAdLoadCallback interface.

The following table lists the corresponding class or interface you must use for each custom event interface starting from version 21.0.0:

Migrate from v19 to v20

There are many breaking changes in version 20.0.0. Version 19.7.0 introduced many new APIs, and deprecated or renamed many classes in preparation for version 20.0.0. This guide highlights the major changes in version 20.0.0.

Full-screen format API updates

Starting with version 20.0.0, interstitial, rewarded, rewarded interstitial, and App Open ad formats are standardized to follow a consistent API design.

All full-screen format APIs use the following principles:

Legacy RewardedVideoAd API removal

The newer RewardedAd API was first introduced back in March 2019 and has been the preferred rewarded API for over 18 months. It has had more enhancements compared to the legacy RewardedVideoAd API, including the ability to load more than one rewarded ad at a time.

The legacy RewardedVideoAd API is removed in SDK version 20.0.0.

Smart banner ads are deprecated in favor of adaptive banner ads. Adaptive banners provide superior performance and more flexibility in setting ad width. If you prefer to continue using full-width banners, that can still be done using adaptive banner, as shown in the following code snippet:

Java
public class MyActivity extends AppCompatActivity {
  ...
  private AdSize getFullWidthAdaptiveSize() {
    Display display = getWindowManager().getDefaultDisplay();
    DisplayMetrics outMetrics = new DisplayMetrics();
    display.getMetrics(outMetrics);

    float widthPixels = outMetrics.widthPixels;
    float density = outMetrics.density;

    int adWidth = (int) (widthPixels / density);
    return AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(this, adWidth);
  }
}
Kotlin
class MyActivity : AppCompatActivity() {
  ...
  private val adaptiveAdSize: AdSize
    get() {
      val display = windowManager.defaultDisplay
      val outMetrics = DisplayMetrics()
      display.getMetrics(outMetrics)

      val density = outMetrics.density

      var adWidthPixels = ad_view_container.width.toFloat()
      if (adWidthPixels == 0f) {
        adWidthPixels = outMetrics.widthPixels.toFloat()
      }

      val adWidth = (adWidthPixels / density).toInt()
      return AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(this, adWidth)
    }
}
Leave application callback removal

The onAdLeftApplication callback for all ad formats has been removed in favor of ProcessLifecycleOwner. Using an OS-level API notifies you whenever users leave your app, regardless of whether or not it is due to an ad interaction.

Note that the onAdLeftApplication callback was never intended to be an ad click handler, and relying on this callback to report clicks did not produce an accurate metric. For example, a click the AdChoices icon that launched an external browser invoked the callback but did not count as a click.

Class renames

The following table lists specific class names that have changed or are removed:

19.5.0 Class 20.0.0 Class com.google.android.gms.ads. com.google.android.gms.ads. reward.RewardedVideoAd rewarded.RewardedAd reward.RewardedVideoAdListener rewarded.RewardedAdLoadCallback and FullScreenContentCallback reward.RewardItem rewarded.RewardItem rewarded.RewardedAdCallback OnUserEarnedRewardListener formats.UnifiedNativeAdView nativead.NativeAdView formats.UnifiedNativeAd nativead.NativeAd formats.UnifiedNativeAdAssetNames nativead.NativeAdAssetNames formats.UnifiedNativeAd.OnUnifiedNativeAdLoadedListener nativead.NativeAd.OnNativeAdLoadedListener formats.AdChoicesView nativead.AdChoicesView formats.NativeAd.AdChoicesInfo nativead.NativeAd.AdChoicesInfo formats.MediaView nativead.MediaView formats.NativeAdViewHolder nativead.NativeAdViewHolder formats.NativeAdOptions nativead.NativeAdOptions formats.NativeCustomTemplateAd nativead.NativeCustomFormatAd formats.NativeCustomTemplateAd.OnCustomTemplateAdLoadedListener nativead.NativeCustomFormatAd.OnCustomFormatAdLoadedListener MobileAds.Settings Removed doubleclick.PublisherAdRequest admanager.AdManagerAdRequest doubleclick.PublisherAdView admanager.AdManagerAdView formats.PublisherAdViewOptions formats.AdManagerAdViewOptions doubleclick.PublisherInterstitialAd admanager.AdManagerInterstitialAd InterstitialAd interstitial.InterstitialAd NativeExpressAdView Removed instream.InstreamAd Removed mediation.admob.AdMobExtras Removed Correlator Removed search.SearchAdRequest Removed Interface AdRequest.TagForUnderAgeOfConsent Removed Interface AdRequest.MaxAdContentRating Removed formats.NativeAppInstallAd native.NativeAd formats.NativeAppInstallAdView native.NativeAdView mediation.NativeAppInstallAdMapper mediation.UnifiedNativeAdMapper formats.NativeContentAd native.NativeAd formats.NativeContentAdView native.NativeAdView mediation.NativeContentAdMapper mediation.UnifiedNativeAdMapper Methods removed/replaced

The following table lists the specific changes in version 20.0.0:

Class v19.5.0 API v20.0.0 API Notes AdSize getPortraitBannerAdSizeWithWidth() getPortraitAnchoredAdaptiveBannerAdSize() getLandscapeBannerAdSizeWithWidth() getLandscapeAnchoredAdaptiveBannerAdSize() getCurrentOrientationBannerAdSizeWithWidth() getCurrentOrientationAnchoredAdaptiveBannerAdSize() MobileAds initialize(Context, String) MobileAds.initialize(Context, OnInitializationCompleteListener) The app ID is now set in the AndroidManifest.xml. initialize(Context, String, MobileAds.Settings) initialize(Context, OnInitializationCompleteListener) The Settings class has been deprecated. getRewardedVideoAdInstance() Removed Use the RewardedAd API instead. AdListener onAdFailedToLoad(int) onAdFailedToLoad(LoadAdError) onAdLeftApplication() Removed Full-screen ad formats use FullscreenContentCallback in place of AdListener, and there is no equivalent method on FullscreenContentCallback. The method has been removed from AdListener. VideoController getAspectRatio() MediaContent.getAspectRatio() AdRequest getGender() Removed getBirthday() Removed getNetworkExtras() Removed setManualImpressionsEnabled() Removed updateCorrelator() Removed See Ad content filtering. AdRequest.Builder setBirthday() Removed setGender() Removed setIsDesignedForFamilies() Removed See guide. addTestDevice() RequestConfiguration.Builder.setTestDeviceIds() See Enable test ads. tagForChildDirectedTreatment() RequestConfiguration.Builder.setTagForChildDirectedTreatment() See Ad content filtering. setTagForUnderAgeOfConsent() RequestConfiguration.Builder.setTagForUnderAgeOfConsent() setMaxAdContentRating() RequestConfiguration.Builder.setMaxAdContentRating() AdView getMediationAdapterClassName() ResponseInfo.getMediationAdapterClassName() A ResponseInfo object is available using the AdView method, getResponseInfo(). NativeAdOptions setImageOrientation() setMediaAspectRatio() getImageOrientation getMediaAspectRatio() RewardedAd loadAd(AdRequest, RewardedAdLoadCallback) RewardedAd.load(Context, String, AdRequest, RewardedAdLoadCallback) RewardedAd now uses the same static load approach as other full-screen formats. loadAd(PublisherAdRequest, RewardedAdLoadCallback) RewardedAd.load(Context, String, AdManagerAdRequest, RewardedAdLoadCallback) isLoaded() Removed The callback from the static load method provides an ad that is already loaded. show(Activity, RewardedAdCallback) show(Activity, OnUserEarnedRewardListener) This show method adheres to the broader full-screen format approach. RewardedAdLoadCallback onRewardedAdFailedToLoad(int) onAdFailedToLoad(LoadAdError) onRewardedAdFailedToLoad(LoadAdError) onAdFailedToLoad(LoadAdError) onRewardedAdLoaded() onAdLoaded(RewardedAd) AppOpenAdLoadCallback onAppOpenAdFailedToLoad(int) onAdFailedToLoad(LoadAdError) onAppOpenAdFailedToLoad(LoadAdError) onAdFailedToLoad(LoadAdError) onAppOpenAdLoaded(AppOpenAd) onAdLoaded(AppOpenAd) RewardedInterstitialAdLoadCallback onRewardedInterstitialAdFailedToLoad(int) onAdFailedToLoad(LoadAdError) onRewardedInterstitialAdFailedToLoad(LoadAdError) onAdFailedToLoad(LoadAdError) onRewardedInterstitialAdLoaded(RewardedInterstitialAd) onAdLoaded(RewardedInterstitialAd) InterstitialAd new InterstitialAd() InterstitialAd.load(Context, String, AdRequest, InterstitialAdLoadCallback) InterstitialAd now uses the same static load approach as other full-screen formats. setAdListener() DynamicHeightSearchAdRequest getNetworkExtras() Removed The NetworkExtras class has been deprecated. AdLoader forContentAd() Removed forAppInstallAd() Removed withCorrelator() Removed getMediationAdapterClassName() Removed

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.3