Installing the Unity Ads SDK for Android
Download the Unity Ads framework, specifically unity-ads.aar
.
Using Android Studio
-
Create or open your existing Android project in Android Studio.
-
Add a new module and import the
unity-ads.aar
file. Name the module "unity-ads", for example. -
Right-click on the module in the project view, then select Open Module Settings > app, and add the "unity-ads" module as a dependency.
-
Add the following import to your java
Activity
file:
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:
-
Include
classes.jar
in your build. -
Manually merge the manifest from
AndroidManifest.xml
. Make sure you include bothAdUnitActivity
andAdUnitSoftwareActivity
activities. You also need to add theINTERNET
andACCESS_NETWORK_STATE
permissions. -
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:
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
Please see Google’s Advertising ID documentation for more information.