文档

​
​

Development

User Acquisition

Monetization

工业

Unity Ads Monetization

SDK 4.20.0

受支持
​

Android API reference

Unity Ads Monetization

SDK 4.20.0

受支持
​

此页面不支持所选语言。
Android developer guides
​
​
Android developer guides
  • Android SDK integration guide
  • Unity Ads privacy guide
  • Unity Ads SDK troubleshooting guide
  • Android developer API references
  1. Unity Ads SDK Android developer monetization
  2. Unity Ads SDK integration guide for Android developers

Install the Unity Ads SDK for Android

Install the Unity Ads SDK in your Android project. Add the required dependencies to your build.gradle files and sync the build to apply the changes.
阅读时间2 分钟
最后更新于 1 个月前

You can use Gradle dependencies to integrate the Unity Ads SDK. Unity supports Android 4.4 "KitKat" (API level 19) and later.
注意
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. The recommended best practice is 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

重要
Java 8+ targeting will be required from the Unity Ads SDK version 4.7.0 and higher.
  1. Add the following code to the
    dependencies
    section to your app-level build.gradle file:
dependencies { implementation 'com.unity3d.ads:unity-ads:4.20.0'}
dependencies { implementation("com.unity3d.ads:unity-ads:4.20.0")}
  1. 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 }}
android { compileOptions { sourceCompatibility(JavaVersion.VERSION_1_8) targetCompatibility(JavaVersion.VERSION_1_8) }}

Advertising ID

注意
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"/>
重要
Google will enforce this declaration beginning April 1, 2022. For more information, refer to the Google Play Console Help documentation on Advertising ID.
Next steps: To continue your integration, refer to the Initialize the SDK in Android documentation.

Copyright © 2026 Unity Technologies
法律信息隐私政策CookiesDocumentation Terms of Use请勿出售或分享我的个人信息您的隐私选择(Cookie 设置)

“Unity”、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属公司在美国和其他地方的商标或注册商标(此处查看更多信息)。其他名称或品牌是其各自所有者的商标。

为方便起见,一些页面是机器翻译的,可能包含不准确的内容。如有信息不一致的情况,以英文版本为准。

  • 在本页上
    • Add the Unity Ads SDK to your project

    • Advertising ID


报告此页面的问题