Installing the Unity Ads SDK for Android

Download the Unity Ads framework, specifically unity-ads.aar.

Using Android Studio

  1. Create or open your existing Android project in Android Studio.

  2. Add a new module and import the unity-ads.aar file. Name the module "unity-ads", for example.

  3. Right-click on the module in the project view, then select Open Module Settings > app, and add the "unity-ads" module as a dependency.

  4. Add the following import to your java Activity file:

Copy
import com.unity3d.ads.UnityAds;

Without Android Studio

If you can't use the .aar packages with your build system, Unity also provides the same resources in a ZIP file (unity-ads.zip in GitHub releases). Follow these steps to use Unity Ads:

  1. Include classes.jar in your build.

  2. Manually merge the manifest from AndroidManifest.xml. Make sure you include both AdUnitActivity and AdUnitSoftwareActivity activities. You also need to add the INTERNET and ACCESS_NETWORK_STATE permissions.

  3. If you are using ProGuard, add all lines from proguard.txt to your ProGuard configuration.

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 above they will need to declare a Google Play services normal permission in the manifest file as follows:

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

Important: Google will enforce this declaration beginning April 1, 2022.

See Google’s Advertising ID documentation for more information.

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

Next steps: See documentation on initializing the SDK in Android to continue your integration.