设置 Android 16 SDK
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
如需使用 Android 16 API 进行开发并在您的应用中测试 Android 16 行为变更,您需要设置 Android 16 SDK。请按照此页面中的说明在 Android Studio 中设置 Android 16 SDK,并在 Android 16 上构建和运行您的应用。
获取 Android Studio
Android 16 SDK 包含与某些较低版本的 Android Studio 不兼容的变更。为了获得 Android 16 SDK 的最佳开发体验,请使用 Android Studio Meerkat | 2024.3.1 或更高版本。
获取 Android Studio
更新应用的 build 配置
如需访问 Android 16 API,请打开应用的 build.gradle
或 build.gradle.kts
文件,并按如下方式更新 Android 16 的 compileSdk
:
Groovy
android {
compileSdk = 36
}
Kotlin
android {
compileSdk = 36
}
Android Studio 可以通过 Android SDK 升级助理提供有关行为变更的上下文信息。
准备好选择启用 Android 16 的新运行时行为后,请按以下方式更新应用的 targetSdk
:
Groovy
android {
defaultConfig {
targetSdk = 36
}
}
Kotlin
android {
defaultConfig {
targetSdk = 36
}
}
手动安装 SDK
在 Android Studio 中,您可以按如下方式安装 Android 16 SDK:
- 依次点击 Tools > SDK Manager。
- 在 SDK Platforms 标签页中,展开 Android Baklava Preview 部分,然后选择 Android SDK Platform Baklava 软件包。
- 在 SDK Tools 标签页中,展开 Android SDK Build-Tools 36 部分,然后选择最新的
36.x.x
版本。
- 点击 OK 安装 SDK。
后续步骤
如需了解哪些变更可能会影响您的应用,以及如何在应用中测试这些变更,请参阅以下主题:
如需详细了解 Android 16 中提供的新 API 和功能,请参阅 Android 16 功能。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-20。
[null,null,["最后更新时间 (UTC):2025-08-20。"],[],[],null,["# Set up the Android 16 SDK\n\nTo develop with Android 16 APIs and test your app with the Android 16 behavior\nchanges, you need to set up the Android 16 SDK. Follow the instructions on this\npage to set up the Android 16 SDK in Android Studio and build and run your app\non Android 16.\n\nGet Android Studio\n------------------\n\nThe Android 16 SDK includes changes that are not compatible with some lower\nversions of Android Studio. For the best development experience with the Android\n16 SDK, use Android Studio Meerkat \\| 2024.3.1 or higher.\n\n\u003cbr /\u003e\n\n[Get Android Studio](/studio)\n\nUpdate your app's build configuration\n-------------------------------------\n\n| **Warning:** If your project does not use Android Gradle plugin 8.9.0-rc01 or higher, first run the [Android Gradle plugin Upgrade Assistant](/r/tools/upgrade-assistant/agp-upgrade-assistant) to upgrade to at least AGP 8.9.0-rc01.\n\nTo access Android 16 APIs, open your app's `build.gradle` or `build.gradle.kts`\nfile and update the `compileSdk` for Android 16 as follows: \n\n### Groovy\n\n```groovy\nandroid {\n compileSdk = 36\n}\n```\n\n### Kotlin\n\n```kotlin\nandroid {\n compileSdk = 36\n}\n```\n\nAndroid Studio can provide contextual information about the\nbehavior changes through the\n[Android SDK Upgrade Assistant](/r/studio-ui/ide/android-sdk-upgrade-assistant).\nOnce you're ready to opt in to the new runtime behaviours for Android 16,\nupdate your app's `targetSdk` as follows: \n\n### Groovy\n\n```groovy\nandroid {\n defaultConfig {\n targetSdk = 36\n }\n}\n```\n\n### Kotlin\n\n```kotlin\nandroid {\n defaultConfig {\n targetSdk = 36\n }\n}\n```\n\n### Manually install the SDK\n\nWithin Android Studio, you can install the Android 16 SDK as follows:\n\n1. Click **Tools \\\u003e SDK Manager**.\n2. In the **SDK Platforms tab** , expand the **Android Baklava Preview** section and select the **Android SDK Platform Baklava** package.\n3. In the **SDK Tools** tab, expand the **Android SDK Build-Tools 36** section and select the latest `36.x.x` version.\n4. Click **OK** to install the SDK.\n\nNext steps\n----------\n\nTo learn about the changes that might affect your app, and to learn how to test\nthese changes in your app, read the following topics:\n\n- [Behavior changes that affect all apps](/about/versions/16/behavior-changes-all)\n- [Behavior changes that affect only apps that target Android 16](/about/versions/16/behavior-changes-16)\n\nTo learn more about new APIs and features available in Android 16, read [Android\n16 features](/about/versions/16/features)."]]