You can use Gradle dependencies to integrate the Unity Ads SDK. Unity supports Android 4.4 "KitKat" (API level 19) and later.
Add the Unity Ads SDK to your project
- Add the following code to your app-level build.gradle file inside the
repositories
section:
repositories { mavenCentral() }
- Add the following code to the
dependencies
section:
dependencies { implementation 'com.unity3d.ads:unity-ads:4.7.0' }
- 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
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"/>
Next steps: To continue your integration, refer to the Initialize the SDK in Android documentation.