Unity Ads Android integration requirements
Review the integration requirements for Unity Ads SDK to ensure your Android app meets the necessary prerequisites to implement ad formats.
Read time 2 minutesLast updated 8 days ago
Review the requirements and supported tools to complete the Unity Ads integration with your Android app before installing, initializing, and implementing interstitial, rewarded, or banner ads to earn revenue.
App prerequisites
Before you integrate the Unity Ads SDK, confirm your app meets the following Android Gradle Plugin (AGP) version and build configuration requirements. Each one affects whether the SDK builds and delivers events correctly.
Android Gradle Plugin versions
Your Android Gradle Plugin (AGP) version must be at least 4.2.0, supporting up to AGP version 9.
If you use AGP 9 with , the steps you need to follow depend on your Unity Ads SDK version.
isMinifyEnabled = trueUnity Ads SDK 4.20.0 or later
If you’re upgrading or plan to upgrade to AGP 9 with , install the Unity Ads SDK 4.20.0. This is the recommended path because the required R8 keep rules ship with the SDK, so no action is required from you.
isMinifyEnabled = trueUnity Ads SDK earlier than 4.20.0
If you’re using a Unity Ads SDK version earlier than 4.20.0 with Android Gradle Plugin 9 with , you must add the required keep rules to your own ProGuard configuration. Without them, Unity Ads diagnostic and operative events are silently dropped under R8.
isMinifyEnabled = trueDo the following steps to add the required keep rules to your Proguard configuration.
- Add the following three rules to your app’s .
proguard-rules.pro
# Keep WorkManager components that are instantiated via reflection, # which R8 full mode (AGP 9+) can otherwise strip. Fixes Unity Ads # diagnostic/operative event delivery and a potential WorkDatabase # startup crash. -keep class androidx.work.impl.WorkDatabase_Impl { *; } -keep class * extends androidx.work.ListenableWorker { <init>(android.content.Context, androidx.work.WorkerParameters); } -keep class * extends androidx.work.InputMerger { <init>(); }
- Rebuild your minified release variant.
- Confirm the logcat errors are gone and events arrive as expected.
Build configuration
Ensure your file specifies the following:
build.gradle-
Kotlin version to 2.1.x.
-
to be
minSDKversionor higher19 -
to be
compileSdkVersionor higher33 -
Java 8 targeting for the Unity Ads SDK version 4.7.0 and higher
-
or
Protobuf-kotlin-liteand the version usedprotobuf-java-lite