设置 Android 15 SDK
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
如需使用 Android 15 API 进行开发并在您的应用中测试 Android 15 行为变更,您需要设置 Android 15 SDK。请按照此页面中的说明在 Android Studio 中设置 Android 15 SDK,并在 Android 15 上构建和运行您的应用。
获取 Android Studio
Android 15 SDK 包含与某些较低版本的 Android Studio 不兼容的变更。为了获得 Android 15 SDK 的最佳开发体验,请使用 Android Studio Koala 功能更新 | 2024.1.2 或更高版本。
获取 Android Studio
试用 Android 15
如果您尚未准备好完全支持 Android 15,您仍然可以使用可调试的应用、Android 15 设备(包括虚拟设备)和兼容性框架来执行应用兼容性测试,而无需更改应用以使其与 SDK 兼容或以此为目标平台。
更新应用的 build 配置
如需访问 Android 15 API,请打开应用的 build.gradle
或 build.gradle.kts
文件,并按如下方式更新 Android 15 的 compileSdk
:
Groovy
android {
compileSdk = 35
}
Kotlin
android {
compileSdk = 35
}
Android Studio 可以通过 Android SDK 升级助理提供有关行为变更的情境信息。准备好选择启用 Android 15 的新运行时行为后,请按如下方式更新应用的 targetSdk
:
Groovy
android {
defaultConfig {
targetSdk = 35
}
}
Kotlin
android {
defaultConfig {
targetSdk = 35
}
}
手动安装 SDK
在 Android Studio 中,您可以按如下方式安装 Android 15 SDK:
- 依次点击 Tools > SDK Manager,然后点击 Show Package Details。
- 在 SDK Platforms 标签页中,展开 Android API 35 部分,然后选择 Android SDK Platform 35 软件包。
- 在 SDK Tools 标签页中,展开 Android SDK Build-Tools 35 部分,然后选择最新的
35.x.x
版本。
- 点击 OK 安装 SDK。
后续步骤
如需了解可能影响您的应用的变更,以及如何在应用中测试这些变更,请参阅以下主题:
如需详细了解 Android 15 中提供的新 API 和功能,请参阅 Android 15 功能。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Set up the Android 15 SDK\n\nTo develop with Android 15 APIs and test your app with the Android 15 behavior\nchanges, you need to set up the Android 15 SDK. Follow the instructions on this\npage to set up the Android 15 SDK in Android Studio and build and run your app\non Android 15.\n\nGet Android Studio\n------------------\n\nThe Android 15 SDK includes changes that are not compatible with some lower\nversions of Android Studio. For the best development experience with the Android\n15 SDK, use Android Studio Koala Feature Drop \\| 2024.1.2 or higher.\n\n\u003cbr /\u003e\n\n[Get Android Studio](/studio)\n\nTry out Android 15\n------------------\n\nIf you aren't quite ready to fully support Android 15, you can still\nperform app compatibility testing by using a debuggable app, an Android 15\ndevice (including [virtual devices](/studio/run/managing-avds)), and the [compatibility framework](/about/versions/15/reference/compat-framework-changes),\nwithout changing your app to compile with or target the SDK.\n\nUpdate your app's build configuration\n-------------------------------------\n\n| **Warning:** If your project does not use Android Gradle plugin 8.6.1 or higher, first run the [Android Gradle plugin Upgrade Assistant](/r/tools/upgrade-assistant/agp-upgrade-assistant) to upgrade to at least AGP 8.6.1.\n\nTo access Android 15 APIs, open your app's `build.gradle` or `build.gradle.kts`\nfile and update the `compileSdk` for Android 15 as follows: \n\n### Groovy\n\n```groovy\nandroid {\n compileSdk = 35\n}\n```\n\n### Kotlin\n\n```kotlin\nandroid {\n compileSdk = 35\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 15,\nupdate your app's `targetSdk` as follows: \n\n### Groovy\n\n```groovy\nandroid {\n defaultConfig {\n targetSdk = 35\n }\n}\n```\n\n### Kotlin\n\n```kotlin\nandroid {\n defaultConfig {\n targetSdk = 35\n }\n}\n```\n\nManually install the SDK\n------------------------\n\nWithin Android Studio, you can install the Android 15 SDK as follows:\n\n1. Click **Tools \\\u003e SDK Manager** , then click **Show Package Details**.\n2. In the **SDK Platforms tab** , expand the **Android API 35** section and select the **Android SDK Platform 35** package.\n3. In the **SDK Tools** tab, expand the **Android SDK Build-Tools 35** section and select the latest `35.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/15/behavior-changes-all)\n- [Behavior changes that affect only apps that target Android 15](/about/versions/15/behavior-changes-15)\n\nTo learn more about new APIs and features available in Android 15, read [Android\n15 features](/about/versions/15/features)."]]