Installing the Unity Ads SDK for Android

You can use Gradle dependencies to integrate the Unity Ads SDK. Unity supports Android 4.4 "KitKat" (API level 19) and later.

Note: Unity Ads has new dependencies from SDK version 4.5.0. Manually including the linked aar file (which contains all metadata, Android manifest, classes.jar, proguard rules, and so on) will lead to runtime errors if dependencies are not properly resolved. It's recommended to use a package management system such as Gradle to handle dependency management. Refer to the Android SDK integration steps for details.

Add the Unity Ads SDK to your project

Warning: Java 8+ targeting will be required from the Unity Ads SDK version 4.7.0 and higher.

  1. Add the following code to your app-level build.gradle file inside the repositories section:
    repositories {
        mavenCentral()
    }
  2. Add the following code to the dependencies section:
    dependencies {
        implementation 'com.unity3d.ads:unity-ads:4.7.0'
    }
  3. If your project is not already using Java 8+, set your Java version to 8 in build.gradle in the compileOptions section:
    android { 
       compileOptions {
                sourceCompatibility = JavaVersion.VERSION_1_8
                targetCompatibility = JavaVersion.VERSION_1_8
        }
    }

Advertising ID

Note: If your app uses the Unity Ads SDK version 4.1 or later, you can skip this step because the SDK automatically declares the permission and can access the Advertising ID whenever it is available. Apps using the Unity Ads SDK version 4.0.1 or earlier must include the declaration manually.

When an Android user opts out of interest-based advertising or ads personalization, the advertising identifier will not be available. Publishers will receive a string of zeros in place of the identifier.

Additionally, when apps update their target to Android 13 or later, they need to declare a Google Play services normal permission in the manifest file as follows:

<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>

Important: Google will enforce this declaration beginning April 1, 2022. For more information, see the Google Play Console Help documentation on Advertising ID.

Next steps: To continue your integration, refer to the Initializing the SDK in Android documentation.