Preparing Mediated Networks
This page shows you how to integrate MAX mediation network adapters in your app. Choose which mediated ad networks you want to integrate by checking the boxes below. Then this page will display instructions specific to those networks.
Android
Select the ad networks you want to integrate. Then follow the Android-specific instructions on this page.
Add Your Google Bidding and Google AdMob App IDs
- Open the Integration Manager (AppLovin > Integration Manager).
- Install the latest Google bidding and Google AdMob adapter:
- Click Install in the Actions column next to Google bidding and Google AdMob in the Mediated Networks section of the Integration Manager.
- Click Import in the Import Unity Package dialog.
- Two new fields for your App IDs will appear in the Mediated Networks section of the Integration Manager.
Enter the corresponding values there.
Gradle Errors
Google AdMob requires Android Gradle plugin version 4.2.0 or higher and Gradle version 6.7.1 or higher. If you see the following error, update your Android Gradle plugin and Gradle versions:
AAPT: error: unexpected element <property> found in <manifest><application>.
To update your Android Gradle plugin and Gradle versions, take the following steps:
- In Unity, open Project Settings > Player > Android > Publishing Settings > Build.
- Check Custom Base Gradle Template.
- Edit the
Assets/Plugins/Android/baseProjectTemplate.gradle
file.i Set the dependencies to use Gradle build tools version 4.2.0:allprojects {buildscript {dependencies {classpath 'com.android.tools.build:gradle:4.2.0'«build script dependencies»}}} - Download and install Gradle version 6.7.1 or higher.
- In Unity, open Unity Preferences > External Tools.
- Set the custom Gradle path so that it points to your newly-updated Gradle installation.
Meta Audience Network SDK Migration
If your project uses the Meta Audience Network Unity SDK, you must be on version 11.0 or later for the MAX Meta Audience Network adapter to function.
To migrate from an older version of Meta Audience Network Unity SDK, delete the Assets/FacebookSDK
directory, then download and re-import the latest version here.
Meta Audience Network Data Processing Options
If you aren’t using the Meta Audience Network Unity Plugin, follow the instructions here under “Unity SDK, v5.10+ (not using the Audience Network-supplied Unity wrapper)” to add a wrapper for the relevant methods.
If you do not want to enable Limited Data Use (LDU) mode, pass SetDataProcessingOptions()
an empty string array:
using AudienceNetwork;⋮AdSettings.SetDataProcessingOptions(new string[] { });⋮// Initialize MAX SDK
If you want to enable LDU for users and to specify user geography, call SetDataProcessingOptions()
like this:
using AudienceNetwork;⋮AdSettings.SetDataProcessingOptions(new string[] {"LDU"}, «country», «state»);⋮// Initialize MAX SDK
Using Google UMP
If you use Google UMP as your CMP, you can determine whether the user consented to Meta. To do so, use the following code:
bool? hasMetaConsent = MaxSdkUtils.GetAdditionalConsentStatus(89);if ( hasMetaConsent != null ){ // Set Meta Data Processing Options accordingly.}else{ // AC String is not available on disk. Please check for consent status after the user completes the CMP flow.}
Meta Audience Network Data Processing Options for Users in California
To learn how to implement Meta Audience Network’s “Limited Data Use” flag in California, read the Meta for Developers documentation.
Android Manifest Merging Errors
Several network SDKs use the <queries>
element in their bundled Android Manifest files.
If you use an incompatible version of the Android Gradle plugin, this causes one of the following build errors:
com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failederror: unexpected element <queries> found in <manifest>.
Missing 'package' key attribute on element package at [:com.my.target.mytarget-sdk-5.11.3:]AndroidManifest Validation failed
To fix this error, upgrade to one of the following versions of the Android Gradle plugin.
These versions support the <queries>
element:
Current Android Gradle Plugin Version | Version that Supports <queries> Element |
---|---|
4.1.* | All |
4.0.* | 4.0.1+ |
3.6.* | 3.6.4+ |
3.5.* | 3.5.4+ |
3.4.* | 3.4.3+ |
3.3.* | 3.3.3+ |
To update the Gradle Plugin version to a compatible one, enable the custom base Gradle template:
- Select Edit > Project Settings….
- Choose Player and select the tab labeled with the Android icon.
- Open Publisher Settings and check Custom Base Gradle Template.
The template is located at Assets/Plugins/Android/mainTemplate.gradle
for Unity 2019.2 or below, and at Assets/Plugins/Android/baseProjectTemplate.gradle
for Unity 2019.3 or above.
In that template, update the line below with the appropriate Gradle version:
classpath com.android.tools.build:gradle:«x».«x».«x»
compileSdkVersion
Google Mobile Ads SDK versions 23.1.0 and newer require a minimum compileSdkVersion
of 34.
Set the compileSdkVersion
to 34
or higher in your app’s build.gradle
.
Refer to the Google Mobile Ads SDK Release Notes for the latest compileSdkVersion
requirements.
iOS
Select the ad networks you want to integrate. Then follow the iOS-specific instructions on this page.
Add Your Google Bidding and Google AdMob App IDs
Open the Integration Manager (AppLovin > Integration Manager) and install the latest Google bidding and Google AdMob adapter:
- Click Install in the Actions column next to Google bidding and Google AdMob in the Mediated Networks section of the Integration Manager.
- Click Import in the Import Unity Package dialog.
- Two new fields for your App IDs will appear in the Mediated Networks section of the Integration Manager.
Enter the corresponding values there.
Meta Audience Network SDK Migration
If your project uses the Meta Audience Network Unity SDK, you must be on version 11.0 or later for the MAX Meta Audience Network adapter to function.
To migrate from an older version of Meta Audience Network Unity SDK, delete the Assets/FacebookSDK
directory, then download and re-import the latest version here.
Meta Audience Network Data Processing Options
If you aren’t using the Meta Audience Network Unity Plugin, you can follow the instructions here under “Unity SDK, v5.10+ (not using the Audience Network-supplied Unity wrapper)” to add a wrapper for the relevant methods.
If you do not want to enable Limited Data Use (LDU) mode, pass SetDataProcessingOptions()
an empty string array:
using AudienceNetwork;⋮AdSettings.SetDataProcessingOptions(new string[] { });⋮// Initialize MAX SDK
If you want to enable LDU for users and to specify user geography, call SetDataProcessingOptions()
like this:
using AudienceNetwork;⋮AdSettings.SetDataProcessingOptions(new string[] {"LDU"}, «country», «state»);⋮// Initialize MAX SDK
Using Google UMP
If you use Google UMP as your CMP, you can determine whether the user consented to Meta. To do so, use the following code:
bool? hasMetaConsent = MaxSdkUtils.GetAdditionalConsentStatus(89);if ( hasMetaConsent != null ){ // Set Meta Data Processing Options accordingly.}else{ // AC String is not available on disk. Please check for consent status after the user completes the CMP flow.}
Meta Audience Network Data Processing Options for Users in California
To learn how to implement Meta Audience Network’s “Limited Data Use” flag in California, read the Meta for Developers documentation.
Meta Preparing For iOS 14.5 and Above
Version 6.2.1 of Audience Network SDK introduced the following important requirement:
- Implement the
setAdvertiserTrackingEnabled
flag, irrespective of the use of mediation. This informs Meta whether to use the data to deliver personalized ads.
MaxSdkCallbacks.OnSdkInitializedEvent += (MaxSdkBase.SdkConfiguration sdkConfiguration) => {
#if UNITY_IOS || UNITY_IPHONE || UNITY_EDITOR if (MaxSdkUtils.CompareVersions(UnityEngine.iOS.Device.systemVersion, "14.5") != MaxSdkUtils.VersionComparisonResult.Lesser) { // Note that App transparency tracking authorization can be checked via `sdkConfiguration.AppTrackingStatus` for Unity Editor and iOS targets // 1. Set Meta ATE flag here, THEN }#endif
// 2. Load ads};
SKAdNetwork
The Integration Manager automatically integrates SKAdNetwork IDs of integrated networks on your behalf.
Integration Manager
You can access the AppLovin Integration Manager from your Unity IDE. It allows you to install or upgrade mediation adapters and the mediation plugin itself.
To launch the Integration Manager, select AppLovin > Integration Manager from the Unity menu bar.
This displays a pop up window with a list of available mediation networks. You can Install or Upgrade ad networks by clicking buttons in the Action column.