设置 Android 10 SDK
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Android 10 是一个主要版本,包含各种功能和
扩展应用所需的功能。
Android 10 还包含一些行为变更(针对以 Android 为目标平台的应用)
10 和全部
应用)和隐私权
有助于延长电池续航时间的
安全性。
如需使用 Android 10 API 进行开发并根据 Android 10 行为变更测试应用,请按照本页中的说明在 Android Studio 中设置 Android 10 SDK,并在 Android 10 上构建和运行应用。
获取最新的 Android Studio
Android 10 SDK 包含一些与一些较低版本不兼容的变更
Android Studio 版本。因此,为了获得最佳的开发体验,我们建议您安装最新版的 Android Studio。
获取 Android Studio
您可以使用 Android Studio 3.3 及更高版本编译和测试 Android 10 应用,
但部分 Android 10 SDK 用户可能会遇到 Gradle 同步失败问题,并且
有关过时依赖项的警告。
获取 Android 10 SDK
安装并打开 Android Studio 后,请按以下步骤安装 Android 10 SDK:
- 点击工具 >SDK 管理器,然后点击 Show Package Details。
- 在 SDK Platforms 标签页中,展开 Android 10.0(“Q”)部分,然后选择 Android SDK Platform 29 软件包。
- 在 SDK Tools 标签页中,展开 Android SDK Build-Tools 34 部分,然后选择最新的
29.x.x
版本。
- 依次点击应用 > 确定,下载并安装所选软件包。
更新构建配置
如需全面测试应用的 Android 10 兼容性并开始使用此版平台中引入的 API,请打开您的模块级 build.gradle
文件并更新 compileSdkVersion
和 targetSdkVersion
,如下所示:
Groovy
android {
compileSdkVersion 29
defaultConfig {
targetSdkVersion 29
}
...
}
Kotlin
android {
compileSdkVersion(29)
defaultConfig {
targetSdkVersion(29)
}
...
}
如需了解 Android 10 中可能影响您的应用的变更并开始测试它们,请参阅影响所有应用的 Android 10 行为变更、影响以 Android 10 为目标平台的应用的 Android 10 行为变更和 Android 10 隐私权变更。
如需详细了解从 Android 10 开始可用的 API,请参阅 Android 10 功能和 API。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Set up the Android 10 SDK\n\nAndroid 10 is a major release and includes a variety of [features and\ncapabilities](/about/versions/10/features) you can use to extend your app.\nAndroid 10 also includes behavior changes (for [apps targeting Android\n10](/about/versions/10/behavior-changes-10) and for [all\napps](/about/versions/10/behavior-changes-all)) and [privacy\nchanges](/about/versions/10/privacy) that help improve battery life and\nsecurity.\n\nTo develop with Android 10 APIs and test your app with the Android 10 behavior\nchanges, follow the instructions on this page to set up the Android 10 SDK in\nAndroid Studio and build and run your app on Android 10.\n\nGet the latest Android Studio\n-----------------------------\n\nThe Android 10 SDK includes changes that are not compatible with some lower\nversions of Android Studio. So, for the best development experience, we\nrecommend that you install the latest version of [Android Studio](/studio).\n\n[Get Android Studio](/studio)\n\nYou can compile and test Android 10 apps using Android Studio 3.3 and higher,\nbut some users of the Android 10 SDK may encounter Gradle sync failures and\nwarnings about outdated dependencies.\n\nGet the Android 10 SDK\n----------------------\n\nAfter you install and open Android Studio, install the Android 10 SDK as\nfollows:\n\n1. Click **Tools \\\u003e SDK Manager** , then click **Show Package Details**.\n2. In the **SDK Platforms** tab, expand the **Android 10.0 (\"Q\")** section and select the **Android SDK Platform 29** package.\n3. In the **SDK Tools** tab, expand the **Android SDK Build-Tools 34** section and select the latest `29.x.x` version.\n4. Click **Apply \\\u003e OK** to download and install the selected packages.\n\nUpdate your build configuration\n-------------------------------\n\nTo fully test your app's compatibility with Android 10 and begin using the APIs\nintroduced in this version of the platform, open your module-level\n`build.gradle` file and update the `compileSdkVersion` and `targetSdkVersion` as\nshown here: \n\n### Groovy\n\n```groovy\nandroid {\n compileSdkVersion 29\n\n defaultConfig {\n targetSdkVersion 29\n }\n ...\n}\n```\n\n### Kotlin\n\n```kotlin\nandroid {\n compileSdkVersion(29)\n\n defaultConfig {\n targetSdkVersion(29)\n }\n ...\n}\n```\n\nTo learn about the changes in Android 10 that might affect your app and begin\ntesting them, read [Android 10 behavior changes affecting all\napps](/about/versions/10/behavior-changes-all), [Android 10 behavior changes\naffecting apps targeting Android 10](/about/versions/10/behavior-changes-10),\nand [Android 10 privacy changes](/about/versions/10/privacy).\n\nTo learn more about the APIs available starting in Android 10, read [Android 10\nfeatures and APIs](/about/versions/10/features)."]]