# Android deprecated APIs

> Identify deprecated Unity Ads SDK classes for Android, as well as the replacement and removal versions.

## Android deprecated classes

The following API classes are deprecated or obsolete for the Android SDK for the Unity Ads SDK version 4.19.0.

### Initialization

| **API to be removed**                                                                                                                      | **Deprecated in version** | **What to use instead**                                                                                                                      | **Removed in version** | **Deprecation reason**                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `UnityAds.initialize(context, gameId, isTesting, IUnityAdsInitializationListener)`                                                         | 4.19.0                    | `UnityAds.initialize(InitializationConfiguration, InitializationListener)` built via `InitializationConfiguration.Builder(gameId)`           | 5.0.0                  | Replaced by a builder-based configuration API with a unified single-method listener. Mediation info is now passed at initialization time via the builder. |
| `IUnityAdsInitializationListener` interface (`onInitializationComplete()` / `onInitializationFailed(UnityAdsInitializationError, String)`) | 4.19.0                    | `InitializationListener` with a single `onInitializationComplete(@Nullable UnityAdsError)` — `null` means success                            | 5.0.0                  | Two-method delegate replaced by a single nullable-error callback, consistent with the unified `UnityAdsError` model.                                      |
| `MediationMetaData` class                                                                                                                  | 4.19.0                    | `MediationInfo` — constructed as `new MediationInfo(name, sdkVersion, adapterVersion)` and passed via `.withMediationInfo()` on each builder | 5.0.0                  | Mutable key-value metadata object replaced by an immutable typed value object passed directly into the builder API.                                       |
| `MetaData` class (used for privacy and mediation key-value pairs)                                                                          | 4.19.0                    | Use `MediationInfo` for mediation data; use `UnityAds.setUserConsent()`, `setUserOptOut()`, and `setNonBehavioral()` for privacy             | 5.0.0                  | Generic string key-value metadata replaced by typed, purpose-specific APIs.                                                                               |
| `UnityAds.UnityAdsInitializationError` enum                                                                                                | 4.19.0                    | Unified `UnityAdsError` — use `error.getCode()` (int) and `error.getMessage()` (String)                                                      | 5.0.0                  | Per-operation error enums replaced by a unified error type with standardized numeric codes across all operations.                                         |

### Interstitial ads

| **API to be removed**                                                                                                                              | **Deprecated in version** | **What to use instead**                                                                                                                                                          | **Removed in version** | **Deprecation reason**                                                                                                                             |
| -------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `UnityAds.load(placementId, UnityAdsLoadOptions, IUnityAdsLoadListener)`                                                                           | 4.19.0                    | `InterstitialAd.load(LoadConfiguration, LoadListener<InterstitialAd>)` built via `LoadConfiguration.Builder(placementId)`                                                        | 5.0.0                  | Static generic load replaced by a type-specific instance-based load API.                                                                           |
| `IUnityAdsLoadListener` interface (`onUnityAdsAdLoaded` / `onUnityAdsFailedToLoad`)                                                                | 4.19.0                    | `LoadListener<InterstitialAd>` with a single `onAdLoaded(@Nullable InterstitialAd, @Nullable UnityAdsError)`                                                                     | 5.0.0                  | Two-method listener replaced by a single nullable-error callback that also delivers the typed ad instance.                                         |
| `UnityAdsLoadOptions`                                                                                                                              | 4.19.0                    | `LoadConfiguration.Builder(placementId)` with `.withMediationInfo()` and `.withAdMarkup()`                                                                                       | 5.0.0                  | Mutable options object replaced by an immutable builder-pattern configuration.                                                                     |
| `UnityAdsLoadOptions.setObjectId(UUID)`                                                                                                            | 4.19.0                    | No replacement — object ID is now managed internally by the SDK                                                                                                                  | 5.0.0                  | Manual correlation IDs are no longer required; the SDK handles ad instance tracking internally.                                                    |
| `UnityAds.show(activity, placementId, UnityAdsShowOptions, IUnityAdsShowListener)`                                                                 | 4.19.0                    | `interstitialAd.show(activity, ShowConfiguration, InterstitialShowListener)` called on the retained `InterstitialAd` instance                                                    | 5.0.0                  | Static show on the global class replaced by an instance method on the loaded ad object.                                                            |
| `IUnityAdsShowListener` interface (interstitial) — `onUnityAdsShowStart`, `onUnityAdsShowClick`, `onUnityAdsShowComplete`, `onUnityAdsShowFailure` | 4.19.0                    | `InterstitialShowListener` — `onStarted(InterstitialAd)`, `onClicked(InterstitialAd)`, `onCompleted(InterstitialAd, ShowFinishState)`, `onFailed(InterstitialAd, UnityAdsError)` | 5.0.0                  | String-keyed, generic show listener replaced by a typed ad-specific listener. Callbacks receive the ad instance rather than a placement ID string. |
| `UnityAdsShowOptions`                                                                                                                              | 4.19.0                    | `ShowConfiguration.Builder().build()`                                                                                                                                            | 5.0.0                  | Mutable options object replaced by an immutable builder-pattern show configuration.                                                                |
| `UnityAdsShowOptions.setObjectId()`                                                                                                                | 4.19.0                    | No replacement — object ID is managed internally                                                                                                                                 | 5.0.0                  | Manual correlation IDs are no longer required.                                                                                                     |
| `UnityAds.UnityAdsLoadError` enum                                                                                                                  | 4.19.0                    | Unified `UnityAdsError` with `getCode()` and `getMessage()`                                                                                                                      | 5.0.0                  | Per-operation error enum replaced by the unified error type.                                                                                       |
| `UnityAds.UnityAdsShowError` enum                                                                                                                  | 4.19.0                    | Unified `UnityAdsError` with `getCode()` and `getMessage()`                                                                                                                      | 5.0.0                  | Per-operation error enum replaced by the unified error type.                                                                                       |

### Rewarded ads

| **API to be removed**                                                                                                                     | **Deprecated in version** | **What to use instead**                                                                                                                                                                     | **Removed in version** | **Deprecation reason**                                                                                                                        |
| ----------------------------------------------------------------------------------------------------------------------------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `UnityAds.load(placementId, UnityAdsLoadOptions, IUnityAdsLoadListener)`                                                                  | 4.19.0                    | `RewardedAd.load(LoadConfiguration, LoadListener<RewardedAd>)` built via `LoadConfiguration.Builder(placementId)`                                                                           | 5.0.0                  | Static generic load replaced by a type-specific instance-based load API.                                                                      |
| `IUnityAdsLoadListener` interface                                                                                                         | 4.19.0                    | `LoadListener<RewardedAd>` with a single `onAdLoaded(@Nullable RewardedAd, @Nullable UnityAdsError)`                                                                                        | 5.0.0                  | Two-method listener replaced by a single nullable-error callback that delivers the typed ad instance.                                         |
| `UnityAds.show(activity, placementId, UnityAdsShowOptions, IUnityAdsShowListener)`                                                        | 4.19.0                    | `rewardedAd.show(activity, ShowConfiguration, RewardedShowListener)` called on the retained `RewardedAd` instance                                                                           | 5.0.0                  | Static show on the global class replaced by an instance method on the loaded ad object.                                                       |
| `IUnityAdsShowListener` interface — reward determined by checking `UnityAdsShowCompletionState.COMPLETED` inside `onUnityAdsShowComplete` | 4.19.0                    | `RewardedShowListener` with a dedicated `onRewarded(RewardedAd)` callback, plus `onStarted`, `onClicked`, `onCompleted(RewardedAd, ShowFinishState)`, `onFailed(RewardedAd, UnityAdsError)` | 5.0.0                  | Checking completion state for reward eligibility replaced by a dedicated reward callback. Note: `onCompleted` still fires after `onRewarded`. |
| `UnityAds.UnityAdsShowCompletionState` enum (`COMPLETED`, `SKIPPED`)                                                                      | 4.19.0                    | `ShowFinishState` enum; reward logic moved to `RewardedShowListener.onRewarded()`                                                                                                           | 5.0.0                  | Enum renamed for consistency; reward grant logic should use the dedicated `onRewarded` callback rather than inspecting completion state.      |

### Banner ads

| **API to be removed**                                                                                                                    | **Deprecated in version** | **What to use instead**                                                                                                                                                                         | **Removed in version** | **Deprecation reason**                                                                                                                        |
| ---------------------------------------------------------------------------------------------------------------------------------------- | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `BannerView` class (`com.unity3d.services.banners`)                                                                                      | 4.19.0                    | `BannerAd` class (`com.unity3d.ads`) — the Android `View` is retrieved via `ad.getView()`                                                                                                       | 5.0.0                  | Direct view class replaced by an ad instance object whose view is accessed via a getter, consistent with the new ad object model.             |
| `BannerView.IListener` interface — `onBannerLoaded`, `onBannerFailedToLoad`, `onBannerShown`, `onBannerClick`, `onBannerLeftApplication` | 4.19.0                    | Two separate listeners: `LoadListener<BannerAd>` for load result (`onAdLoaded`); `BannerShowListener` for impression (`onImpression`), click (`onClicked`), and show failure (`onFailedToShow`) | 5.0.0                  | Single combined listener split into distinct load and show listeners. `onBannerLeftApplication` is removed with no replacement.               |
| `BannerView.load(UnityAdsLoadOptions)`                                                                                                   | 4.19.0                    | `BannerAd.load(BannerConfiguration, LoadListener<BannerAd>)` built via `BannerConfiguration.Builder(placementId, BannerSize, BannerShowListener)`                                               | 5.0.0                  | Constructor + separate load method replaced by a unified static load with a builder configuration, consistent with interstitial and rewarded. |
| `UnityBannerSize` class                                                                                                                  | 4.19.0                    | `BannerSize` class — also supports adaptive sizing (anchored and inline)                                                                                                                        | 5.0.0                  | Renamed for namespace consistency; the new class also adds adaptive banner size support.                                                      |
| `BannerErrorCode` / `BannerErrorInfo`                                                                                                    | 4.19.0                    | Unified `UnityAdsError` with `getCode()` and `getMessage()`                                                                                                                                     | 5.0.0                  | Banner-specific error types replaced by the unified error type used across all ad formats.                                                    |
| `onBannerLeftApplication` callback on `BannerView.IListener`                                                                             | 4.19.0                    | No replacement                                                                                                                                                                                  | 5.0.0                  | Callback removed with no equivalent in the new `BannerShowListener`.                                                                          |

### Privacy

| **API to be removed**                                                   | **Deprecated in version** | **What to use instead**                                                                   | **Removed in version** | **Deprecation reason**                                                                                |
| ----------------------------------------------------------------------- | ------------------------- | ----------------------------------------------------------------------------------------- | ---------------------- | ----------------------------------------------------------------------------------------------------- |
| `MetaData` with key `"gdpr.consent"`                                    | 4.19.0                    | `UnityAds.setUserConsent(boolean)`                                                        | 5.0.0                  | String key-value privacy metadata replaced by a typed static method. `context` is no longer required. |
| `MetaData` with key `"privacy.consent"` (CCPA)                          | 4.19.0                    | `UnityAds.setUserOptOut(boolean)` — pass `true` when the user has opted out (Do not sell) | 5.0.0                  | String key-value privacy metadata replaced by a typed static method with explicit opt-out semantics.  |
| `MetaData` with key `"user.nonBehavioral"` (COPPA, child-directed laws) | 4.19.0                    | `UnityAds.setNonBehavioral(false)`                                                        | 5.0.0                  | Privacy mode string replaced by an explicit boolean API for non-behavioral/contextual ad control.     |

### Error handling

| **API to be removed**                                                                                                                                              | **Deprecated in version** | **What to use instead**                                                                                                                                                                   | **Removed in version** | **Deprecation reason**                                                                          |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | ----------------------------------------------------------------------------------------------- |
| `UnityAds.UnityAdsLoadError` enum (`NO_FILL`, `INTERNAL_ERROR`, `INVALID_ARGUMENT`, `TIMEOUT`, `INITIALIZE_FAILED`)                                                | 4.19.0                    | Unified `UnityAdsError` — use `error.getCode()` (int) and `error.getMessage()` (String). Code 52100 = no fill; 52101 = not initialized; 52102/52104 = invalid configuration; 2 = timeout. | 5.0.0                  | Per-operation load error enum replaced by a unified error type with standardized numeric codes. |
| `UnityAds.UnityAdsShowError` enum (`NOT_INITIALIZED`, `NOT_READY`, `VIDEO_PLAYER_ERROR`, `INVALID_ARGUMENT`, `NO_CONNECTION`, `ALREADY_SHOWING`, `INTERNAL_ERROR`) | 4.19.0                    | Unified `UnityAdsError` with `getCode()` and `getMessage()`                                                                                                                               | 5.0.0                  | Per-operation show error enum replaced by a unified error type with standardized numeric codes. |
| `BannerErrorCode` enum / `BannerErrorInfo` class                                                                                                                   | 4.19.0                    | Unified `UnityAdsError` with `getCode()` and `getMessage()`                                                                                                                               | 5.0.0                  | Banner-specific error type replaced by the same unified error used across all ad formats.       |
