设置 Android 16 QPR2 SDK
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
如需使用 Android 16 QPR2 API 进行开发并在您的应用中测试 Android 16 QPR2 行为变更,您需要设置 Android 16 QPR2 SDK。请按照本页中的说明在 Android Studio 中设置 Android 16 QPR2 SDK,并在 Android 16 QPR2 上构建和运行您的应用。
获取 Android Studio
Android 16 QPR2 SDK 包含与某些较低版本的 Android Studio 不兼容的变更。为了获得 Android 16 QPR2 SDK 的最佳开发体验,请使用最新预览版 Android Studio。请注意,您可以保留已安装的现有 Android Studio 版本,因为您可以并行安装多个版本。
获取 Android Studio
更新应用的 build 配置
如需访问 Android 16 QPR2 API,请打开应用的 build.gradle
或 build.gradle.kts
文件,并按如下方式更新 Android 16 QPR2 的 compileSdk
:
Groovy
android {
compileSdkPreview = "Baklava"
}
Kotlin
android {
compileSdkPreview = "Baklava"
}
Android Studio 可以通过 Android SDK 升级助理提供有关行为变更的上下文信息。
准备好选择启用 Android 16 QPR2 的新运行时行为后,请按如下方式更新应用的 targetSdk
:
Groovy
android {
defaultConfig {
targetSdkPreview = "Baklava"
}
}
Kotlin
android {
defaultConfig {
targetSdkPreview = "Baklava"
}
}
手动安装 SDK
在 Android Studio 中,您可以按如下方式安装 Android 16 QPR2 SDK:
- 依次点击 Tools > SDK Manager。
- 在 SDK Platforms 标签页中,展开 Android Baklava Preview 部分,然后选择 Android SDK Platform Baklava 软件包。
- 在 SDK Tools 标签页中,展开 Android SDK Build-Tools 36 部分,然后选择最新的
36.x.x
版本。
这些标签可能具有 rc1 或 rc2 等后缀。
- 点击 OK 安装 SDK。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-09-05。
[null,null,["最后更新时间 (UTC):2025-09-05。"],[],[],null,["To develop with Android 16 QPR2 APIs and test your app with the Android 16 QPR2\nbehavior changes, you need to set up the Android 16 QPR2 SDK. Follow the\ninstructions on this page to set up the Android 16 QPR2 SDK in Android Studio\nand build and run your app on Android 16 QPR2.\n\nGet Android Studio\n\nThe Android 16 QPR2 SDK includes changes that are not compatible with some lower\nversions of Android Studio. For the best\ndevelopment experience with the Android 16 QPR2 SDK, use the [latest preview\nversion](/studio/preview) of Android Studio. Remember that you can keep your existing version\nof Android Studio installed, as you can [install multiple versions\nside-by-side](/studio/preview/install-preview).\n\n\u003cbr /\u003e\n\n[Get Android Studio](/studio/preview)\n\nUpdate your app's build configuration **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 QPR2 APIs, open your app's `build.gradle` or\n`build.gradle.kts` file and update the `compileSdk` for Android 16 QPR2 as\nfollows: \n\nGroovy \n\n```groovy\nandroid {\n compileSdkPreview = \"Baklava\"\n}\n```\n\nKotlin \n\n```kotlin\nandroid {\n compileSdkPreview = \"Baklava\"\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 QPR2,\nupdate your app's `targetSdk` as follows: \n\nGroovy \n\n```groovy\nandroid {\n defaultConfig {\n targetSdkPreview = \"Baklava\"\n }\n}\n```\n\nKotlin \n\n```kotlin\nandroid {\n defaultConfig {\n targetSdkPreview = \"Baklava\"\n }\n}\n```\n\nManually install the SDK\n\nWithin Android Studio, you can install the Android 16 QPR2 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. These labels might have a suffix such as **rc1** or **rc2**.\n4. Click **OK** to install the SDK."]]