Import and configure the Unity Mediation SDK
If you are using a Gradle version earlier than Gradle 6.8, import the Unity Mediation SDK in your project by adding the artifactory as a maven repository to your Gradle project and following these steps.
- Open the root level
build.gradle
file in your project. - Edit the repositories to add the maven artifactory location:
-
allprojects { repositories { google() mavenCentral() maven { url 'https://unity3ddist.jfrog.io/artifactory/unity-mediation-mvn-prod-local/' } } }
If you are using Gradle 6.8 and later, import the Unity Mediation SDK in your project by adding the repositories to settings.gradle
. Go to the repositories
section of dependencyResolutionManagement
and adding the following:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven {
url 'https://unity3ddist.jfrog.io/artifactory/unity-mediation-mvn-prod-local/'
}
}
}
After you import the Unity Mediation SDK, import the adapters in your app’s build.gradle
file. This step is the same regardless of which Gradle version you are using (prior to Gradle 6.8 or 6.8 and later).
- Open the
build.gradle
file in your project. - Add the following implementations in the
dependencies
section of the file, ensuring the dependencies of the adapters you intend to use in your project are declared. For example, if using Unity Advertisement with Mediation 1.0, the following code example shows what to add in your app'sbuild.gradle
file:
dependencies {
...
implementation "com.unity3d.mediation:mediation-sdk:1.0.0"
implementation "com.unity3d.mediation:unityads-adapter:1.0.1"
implementation "com.unity3d.mediation:admob-adapter:1.0.0"
implementation "com.unity3d.mediation:adcolony-adapter:1.0.0"
implementation "com.unity3d.mediation:applovin-adapter:1.0.0"
implementation "com.unity3d.mediation:facebook-adapter:1.0.0"
implementation "com.unity3d.mediation:ironsource-adapter:1.0.0"
implementation "com.unity3d.mediation:vungle-adapter:1.0.1"
}
Import ad network adapters
To implement a third-party ad network adapter, you need to configure third-party ad networks as sources in your mediation setup in the Unity Dashboard.
Note: If you use Unity Ads exclusively, then no additional configuration is needed.
The following adapters require additional steps to function correctly in your app. If these requirements are not fulfilled, your app will not open and your builds will crash:
- AdMob requires unique identifiers for each platform. You can locate these IDs in the AdMob dashboard, as detailed in the Ad Source Configuration guide
- Unity Ads requires that you remove any previous installations of the Unity Ads SDK.