<br />

**Last updated:** September 17, 2026

This page covers migrations for current and previous versions.

## Migrate from v24 to v25

The following subsections describe breaking changes and behavior differences
between major version 24 and 25 of Google Mobile Ads SDK (Legacy).

### The minimum Android API level is 24

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

### Removed deprecated ad callbacks

The following deprecated ad callbacks were removed from the following classes:

| Class | Callbacks removed | Replacement |
|---|---|---|
| SignalCallbacks | `onFailure(String)` `onAdFailedToShow(String)` | `onFailure(AdError)` `onAdFailedToShow(AdError)` |
| MediationAdLoadCallback | `onFailure(String)` `onAdFailedToShow(String)` | `onFailure(AdError)` `onAdFailedToShow(AdError)` |
| MediationInterstitialAdCallback | `onFailure(String)` `onAdFailedToShow(String)` | `onFailure(AdError)` `onAdFailedToShow(AdError)` |
| MediationRewardedAdCallback | `onFailure(String)` `onAdFailedToShow(String)` | `onFailure(AdError)` `onAdFailedToShow(AdError)` |

### Changes to anchored adaptive banner size APIs

Version 25.0.0 deprecates the existing anchored adaptive banner size APIs and
introduces size APIs for large anchored adaptive banner ads. Google Mobile Ads SDK (Legacy) can
serve video demand to banner ads using the new large anchored adaptive banner
size APIs.

The following table details the deprecated sizing APIs and their replacements:

| v24 (Deprecated) | v25 (Replacement) |
|---|---|
| `getCurrentOrientationAnchoredAdaptiveBannerAdSize(Context, int)` | `getLargeAnchoredAdaptiveBannerAdSize(Context, int)` |
| `getLandscapeAnchoredAdaptiveBannerAdSize(Context, int)` | `getLargeLandscapeAnchoredAdaptiveBannerAdSize(Context, int)` |
| `getPortraitAnchoredAdaptiveBannerAdSize(Context context, int width)` | `getLargePortraitAnchoredAdaptiveBannerAdSize(Context context, int width)` |

### Removal of `mediation.VersionInfo` class

The VersionInfo class in `com.google.android.gms.ads.mediation` package is
removed. Instead, use the `com.google.android.gms.ads.VersionInfo` package.

### Removal of `getConfiguration()` method in the `RtbSignalData` class

The deprecated method `getConfiguration()` API in `RtbSignalData` is removed.
Instead, use the
[`getConfigurations()`](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/mediation/rtb/RtbSignalData.md.txt#getConfigurations())
method, which returns a `List<MediationConfiguration>` list.

## Migrate from v23 to v24

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

### The minimum Android API level is 23

Starting in version 24.0.0, Google Mobile Ads SDK (Legacy) requires all apps to run
on a minimum Android API level 23. 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](https://developers.google.com/ad-manager/mobile-ads-sdk/android/optimize-initialization.md.txt).

### Removed firebase-ads and firebase-ads-lite dependencies

Starting with version 24.0.0, SDK releases no longer distribute the
[`firebase-ads`](https://maven.google.com/web/index.html?q=firebase-ads#com.google.firebase:firebase-ads)
and [`firebase-ads-lite`](https://maven.google.com/web/index.html?q=firebase-ads-lite#com.google.firebase:firebase-ads-lite)
dependencies. Use the [`play-services-ads`](https://maven.google.com/web/index.html?q=play-services-ads#com.google.android.gms:play-services-ads) dependency instead.

### Set custom targeting parameters

To set custom targeting on an ad request, use
[`addCustomTargeting()`](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/AbstractAdRequestBuilder.md.txt#addCustomTargeting(java.lang.String,java.lang.String)).

### Removed deprecated orientation APIs for app open ads

- Removed `AppOpenAd.load()` methods that accept an orientation input parameter. Use `AppOpenAd.load()` methods that don't take an orientation instead.
- Removed `AppOpenAdOrientation` enum.

### 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 (Legacy)
versions return the reward defined in the Ad Manager UI in
[`OnUserEarnedRewardListener`](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/OnUserEarnedRewardListener.md.txt).

### Classes removed

The following classes were removed with no replacement:

- `DynamicHeightSearchAdRequest`
- `SearchAdRequest`
- `SearchAdView`

### Methods removed

The following methods were removed with no replacement:

| Class | Method |
|---|---|
| RewardedInterstitialAdLoadCallback | `onRewardedInterstitialAdLoaded()` |
| RewardedInterstitialAdLoadCallback | `onRewardedInterstitialAdFailedToLoad(int)` |
| RewardedInterstitialAdLoadCallback | `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 Google Mobile Ads SDK (Legacy).

### The minimum Android API level is 21

Starting in version 23.0.0, Google Mobile Ads SDK (Legacy) 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.

### `AdManagerAdRequest.Builder` methods inherited from superclass can be chained

In version 23.0.0, [`AdManagerAdRequest.Builder`](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/admanager/AdManagerAdRequest.Builder.md.txt)
methods inherited from its parent can be chained together to build an
[`AdManagerAdRequest`](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/admanager/AdManagerAdRequest.md.txt)
using a single call:

### Java

```java
AdManagerAdRequest request = new AdManagerAdRequest.Builder()
    .addCustomTargeting("age", "25") // AdManagerAdRequest.Builder method.
    .setContentUrl("https://www.example.com") // Method inherited from parent.
    .build(); // Builds an AdManagerAdRequest.
```

### Kotlin

```kotlin
var request = AdManagerAdRequest.Builder()
  .addCustomTargeting("age", "25") // AdManagerAdRequest.Builder method.
  .setContentUrl("https://www.example.com") // Method inherited from parent.
  .build() // Builds an AdManagerAdRequest.
```

> [!NOTE]
> **Note:** A side effect of this change is [`AdManagerAdRequest.Builder`](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/admanager/AdManagerAdRequest.Builder.md.txt) no longer inherits from [`AdRequest.Builder`](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/AdRequest.Builder.md.txt).

### Deprecated Methods Removed/Replaced

| v22.0.0 API | v23.0.0 API |
|---|---|
| AdRequest.Builder.addTestDevice() | [RequestConfiguration.Builder.setTestDeviceIds()](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/RequestConfiguration.Builder.md.txt#setTestDeviceIds(java.util.List<java.lang.String>)) |
| AdRequest.Builder.tagForChildDirectedTreatment() | [RequestConfiguration.Builder.setTagForChildDirectedTreatment()](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/RequestConfiguration.Builder.md.txt#setTagForChildDirectedTreatment(int)) |
| AdRequest.Builder.setIsDesignedForFamilies() | [RequestConfiguration.Builder.setMaxAdContentRating()](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/RequestConfiguration.Builder.md.txt#setMaxAdContentRating(java.lang.String)) |
| AdFormat.UNKNOWN | No replacement |
| AdLoader.Builder.forUnifiedNativeAd() | [AdLoader.Builder.forNativeAd()](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/AdLoader.Builder.md.txt#forNativeAd(com.google.android.gms.ads.nativead.NativeAd.OnNativeAdLoadedListener)) |
| AdLoader.Builder.forCustomTemplateAd() | [AdLoader.Builder.forCustomFormatAd()](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/AdLoader.Builder.md.txt#forCustomFormatAd(java.lang.String,com.google.android.gms.ads.nativead.NativeCustomFormatAd.OnCustomFormatAdLoadedListener,com.google.android.gms.ads.nativead.NativeCustomFormatAd.OnCustomClickListener)) |
| AdLoader.Builder.withNativeAdOptions(com.google.android.gms.ads.`formats`.NativeAdOptions) | [AdLoader.Builder.withNativeAdOptions(com.google.android.gms.ads.`nativead`.NativeAdOptions)](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/AdLoader.Builder.md.txt#withNativeAdOptions(com.google.android.gms.ads.nativead.NativeAdOptions)) |
| void MobileAds.setSameAppKeyEnabled() | [boolean MobileAds.putPublisherFirstPartyIdEnabled()](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/MobileAds.md.txt#putPublisherFirstPartyIdEnabled(boolean)) |

## Migrate from v21 to v22

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

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

The `MobileAds.getVersionString()` method is removed in version 22.0.0 in favor
of
[`MobileAds.getVersion()`](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/MobileAds.md.txt#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](https://ads-developers.googleblog.com/2022/07/use-new-google-mobile-ads-sdk.html).

### Removal of deprecated NativeCustomFormatAd.getVideoMediaView()

In version 21, Google Mobile Ads SDK (Legacy) provided you the
`NativeCustomFormatAd.getVideoMediaView()` method to get the media asset for a
native custom ad format.

Starting in **version 22** , you create your own `MediaView` and set its media
content, and use
[`MediaContent.getVideoController()`](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/MediaContent.md.txt#getVideoController())
to get the video controls.

### v22

```
// Called when a custom native ad loads.
@Override
public void onCustomFormatAdLoaded(NativeCustomFormatAd ad) {
    // Assumes you have a FrameLayout in your view hierarchy with the ID media_placeholder.
    FrameLayout mediaPlaceholder = (FrameLayout) findViewById(R.id.media_placeholder);

    MediaContent mediaContent = ad.getMediaContent();
    if (mediaContent != null && mediaContent.hasVideoContent()) {
        // Create a MediaView and set its media content.
        MediaView mediaView = new MediaView(mediaPlaceholder.getContext());
        mediaView.setMediaContent(mediaContent);
        mediaPlaceholder.addView(mediaView);
    }
}
```

### v21

```
// Called when a custom native ad loads.
@Override
public void onCustomFormatAdLoaded(NativeCustomFormatAd ad) {
    // Assumes you have a FrameLayout in your view hierarchy with the ID media_placeholder.
    FrameLayout mediaPlaceholder = (FrameLayout) findViewById(R.id.media_placeholder);

    VideoController videoController = ad.getVideoController();
    if (videoController.hasVideoContent()) {
        // Add the media view provided by the native ad.
        mediaPlaceholder.addView(ad.getVideoMediaView());
    }
}
```

See the [custom native
ad](https://developers.google.com/ad-manager/mobile-ads-sdk/android/native/custom-formats#native_video_for_custom_native_ad_formats)
guide for more information.

### Removed or replaced methods

The following table lists the specific changes in version 22.0.0:

| v21.0.0 | v22.0.0 |
|---|---|
| MobileAds.getVersionString() | [MobileAds.getVersion()](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/MobileAds.md.txt#getVersion()) |
| NativeCustomFormatAd.getVideoMediaView() | [NativeCustomFormatAd.getMediaContent()](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/nativead/NativeCustomFormatAd.md.txt#getMediaContent()) |
| NativeCustomFormatAd.getVideoController() | [NativeCustomFormatAd.getMediaContent().getVideoController()](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/MediaContent.md.txt#getVideoController()) |
| AdRequest.Builder.setAdInfo() | [AdRequest.Builder.setAdString()](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/AbstractAdRequestBuilder.md.txt#setAdString(java.lang.String)) |
| MediationRewardedVideoAdAdapter | [Adapter](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/mediation/Adapter.md.txt) |
| MediationRewardedVideoAdListener | [Adapter](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/mediation/Adapter.md.txt) |
| com.google.android.gms.ads.mediation.VersionInfo | [com.google.android.gms.ads.VersionInfo](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/VersionInfo.md.txt) |
| com.google.android.gms.ads.doubleclick.AppEventListener | [com.google.android.gms.ads.admanager.AppEventListener](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/admanager/AppEventListener.md.txt) |

## Migrate from v20 to v21

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

### Update minSdkVersion to 19 or higher

Starting from version 21.0.0, Google Mobile Ads SDK (Legacy) 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](https://kotlinlang.org/docs/java-interop.html#null-safety-and-platform-types)
).

### Removal of addNetworkExtras() method

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()`](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/AbstractAdRequestBuilder.md.txt#addNetworkExtrasBundle(java.lang.Class%3C?%20extends%20com.google.android.gms.ads.mediation.MediationExtrasReceiver%3E,android.os.Bundle))
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 `setLocation(Location location)` method in the `AdRequest.Builder` class that sets the user's location for mediation targeting purposes.
- The `getLocation()` method in the `AdRequest` class that returns the user's location targeting information previously passed to the `setLocation(Location
  location)` method.
- The `getLocation()` method in the `MediationAdConfiguration` class that returns the location of the user, if defined by the `AdRequest`.

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 mediation to set up a
waterfall ad source that isn't one of the Ad Manager
[supported ad sources](https://developers.google.com/ad-manager/mobile-ads-sdk/android/choose-networks.md.txt).

All the [custom
event](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/mediation/customevent/package-summary)
interfaces are deprecated in favor of the
[`Adapter`](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/mediation/Adapter.md.txt)
class and
[`MediationAdLoadCallback`](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/mediation/MediationAdLoadCallback.md.txt)
interface.

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

| v20.0.0 Interfaces | v21.0.0 Class/ Interface |
|---|---|
| [CustomEvent](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/mediation/customevent/CustomEvent.md.txt) | [Adapter](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/mediation/Adapter.md.txt) |
| [CustomEventBanner](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/mediation/customevent/CustomEventBanner.md.txt) | [Adapter](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/mediation/Adapter.md.txt) |
| [CustomEventInterstitial](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/mediation/customevent/CustomEventInterstitial.md.txt) | [Adapter](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/mediation/Adapter.md.txt) |
| [CustomEventNative](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/mediation/customevent/CustomEventNative.md.txt) | [Adapter](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/mediation/Adapter.md.txt) |
| [CustomEventBannerListener](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/mediation/customevent/CustomEventBannerListener.md.txt) | [Adapter](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/mediation/Adapter.md.txt), [MediationAdLoadCallback](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/mediation/MediationAdLoadCallback.md.txt) |
| [CustomEventInterstitialListener](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/mediation/customevent/CustomEventInterstitialListener.md.txt) | [Adapter](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/mediation/Adapter.md.txt), [MediationAdLoadCallback](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/mediation/MediationAdLoadCallback.md.txt) |
| [CustomEventListener](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/mediation/customevent/CustomEventListener.md.txt) | [Adapter](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/mediation/Adapter.md.txt), [MediationAdLoadCallback](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/mediation/MediationAdLoadCallback.md.txt) |
| [CustomEventNativeListener](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/mediation/customevent/CustomEventNativeListener.md.txt) | [Adapter](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/mediation/Adapter.md.txt), [MediationAdLoadCallback](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/mediation/MediationAdLoadCallback.md.txt) |

## 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:

- A static load method
- A similar load callback or handler mechanism
- Reliance on the [`FullScreenContentCallback`](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/FullScreenContentCallback.md.txt) class for presentation callbacks

### Legacy RewardedVideoAd API removal

The newer
[`RewardedAd`](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/rewarded/RewardedAd.md.txt)
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 deprecation in favor of adaptive banner

[Smart banner](https://developers.google.com/ad-manager/mobile-ads-sdk/android/banner/smart.md.txt) ads are deprecated
in favor of [adaptive banner](https://developers.google.com/ad-manager/mobile-ads-sdk/android/banner/adaptive)
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

```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

```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`](https://developer.android.com/reference/androidx/lifecycle/ProcessLifecycleOwner.html).
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:

- Most classes related to `UnifiedNativeAd` have been renamed to `NativeAd`.
- The `MobileAds.Settings`, `NativeExpressAdView`, `NativeAppInstallAd`, `NativeContentAd`, and `InstreamAd` classes and views have been removed.
- All classes with the `Publisher` prefix have been replaced with an `AdManager` prefix.
- The `InterstitialAd` package name has changed.

| 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:

- Outdated initialization methods have been removed from the MobileAds class.
- Some methods from the `AdRequest.Builder()` class have either been removed or moved to the `RequestConfiguration` class.
- RewardedAd and InterstitialAd APIs have been updated to align with all full-screen formats.
- Correlator features have been removed.

| Class | v19.5.0 API | v20.0.0 API | Notes |
|---|---|---|---|
| AdSize | getPortraitBannerAdSizeWithWidth() | getPortraitAnchoredAdaptiveBannerAdSize() |   |
| AdSize | getLandscapeBannerAdSizeWithWidth() | getLandscapeAnchoredAdaptiveBannerAdSize() |   |
| AdSize | getCurrentOrientationBannerAdSizeWithWidth() | getCurrentOrientationAnchoredAdaptiveBannerAdSize() |   |
| MobileAds | initialize(Context, String) | MobileAds.initialize(Context, OnInitializationCompleteListener) | The app ID is now set in the AndroidManifest.xml. |
| MobileAds | initialize(Context, String, MobileAds.Settings) | initialize(Context, OnInitializationCompleteListener) | The Settings class has been deprecated. |
| MobileAds | getRewardedVideoAdInstance() | Removed | Use the RewardedAd API instead. |
| AdListener | onAdFailedToLoad(int) | onAdFailedToLoad(LoadAdError) |   |
| AdListener | 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() |   |
| PublisherAdRequest | getGender() | Removed |   |
| PublisherAdRequest | getBirthday() | Removed |   |
| PublisherAdRequest | getNetworkExtras() | Removed |   |
| PublisherAdRequest | setManualImpressionsEnabled() | Removed |   |
| PublisherAdRequest | updateCorrelator() | Removed | See [Ad content filtering](https://developers.google.com/ad-manager/mobile-ads-sdk/android/targeting.md.txt#ad_content_filtering). |
| PublisherAdRequest.Builder | setBirthday() | Removed |   |
| PublisherAdRequest.Builder | setGender() | Removed |   |
| PublisherAdRequest.Builder | setIsDesignedForFamilies() | Removed | See [guide](https://developer.android.com/google-play/guides/families). |
| PublisherAdRequest.Builder | addTestDevice() | RequestConfiguration.Builder.setTestDeviceIds() | See [Enable test ads](https://developers.google.com/ad-manager/mobile-ads-sdk/android/test-ads.md.txt). |
| PublisherAdRequest.Builder | tagForChildDirectedTreatment() | RequestConfiguration.Builder.setTagForChildDirectedTreatment() | See [Ad content filtering](https://developers.google.com/ad-manager/mobile-ads-sdk/android/}targeting#ad_content_filtering). |
| PublisherAdRequest.Builder | setTagForUnderAgeOfConsent() | RequestConfiguration.Builder.setTagForUnderAgeOfConsent() | See [Ad content filtering](https://developers.google.com/ad-manager/mobile-ads-sdk/android/}targeting#ad_content_filtering). |
| PublisherAdRequest.Builder | setMaxAdContentRating() | RequestConfiguration.Builder.setMaxAdContentRating() | See [Ad content filtering](https://developers.google.com/ad-manager/mobile-ads-sdk/android/}targeting#ad_content_filtering). |
| AdView | getMediationAdapterClassName() | ResponseInfo.getMediationAdapterClassName() | A `ResponseInfo` object is available using the `AdView` method, `getResponseInfo()`. |
| NativeAdOptions | setImageOrientation() | setMediaAspectRatio() |   |
| NativeAdOptions | 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. |
| RewardedAd | loadAd(PublisherAdRequest, RewardedAdLoadCallback) | RewardedAd.load(Context, String, AdManagerAdRequest, RewardedAdLoadCallback) | RewardedAd now uses the same static load approach as other full-screen formats. |
| RewardedAd | isLoaded() | Removed | The callback from the static load method provides an ad that is already loaded. |
| RewardedAd | show(Activity, RewardedAdCallback) | show(Activity, OnUserEarnedRewardListener) | This show method adheres to the broader full-screen format approach. |
| RewardedAdLoadCallback | onRewardedAdFailedToLoad(int) | onAdFailedToLoad(LoadAdError) |   |
| RewardedAdLoadCallback | onRewardedAdFailedToLoad(LoadAdError) | onAdFailedToLoad(LoadAdError) |   |
| RewardedAdLoadCallback | onRewardedAdLoaded() | onAdLoaded(RewardedAd) |   |
| AppOpenAdLoadCallback | onAppOpenAdFailedToLoad(int) | onAdFailedToLoad(LoadAdError) |   |
| AppOpenAdLoadCallback | onAppOpenAdFailedToLoad(LoadAdError) | onAdFailedToLoad(LoadAdError) |   |
| AppOpenAdLoadCallback | onAppOpenAdLoaded(AppOpenAd) | onAdLoaded(AppOpenAd) |   |
| RewardedInterstitialAdLoadCallback | onRewardedInterstitialAdFailedToLoad(int) | onAdFailedToLoad(LoadAdError) |   |
| RewardedInterstitialAdLoadCallback | onRewardedInterstitialAdFailedToLoad(LoadAdError) | onAdFailedToLoad(LoadAdError) |   |
| RewardedInterstitialAdLoadCallback | onRewardedInterstitialAdLoaded(RewardedInterstitialAd) | onAdLoaded(RewardedInterstitialAd) |   |
| PublisherInterstitialAd | new PublisherInterstitialAd() | InterstitialAd.load(Context, String, AdRequest, InterstitialAdLoadCallback) | InterstitialAd now uses the same static load approach as other full-screen formats. |
| PublisherInterstitialAd | setAdListener() | InterstitialAd.load(Context, String, AdRequest, InterstitialAdLoadCallback) | InterstitialAd now uses the same static load approach as other full-screen formats. |
| DynamicHeightSearchAdRequest | getNetworkExtras() | Removed | The NetworkExtras class has been deprecated. |
| AdLoader | forContentAd() | Removed |   |
| AdLoader | forAppInstallAd() | Removed |   |
| AdLoader | withCorrelator() | Removed |   |
| AdLoader | getMediationAdapterClassName() | Removed |   |