設定 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 編譯或將 SDK 版本指定為目標版本。
更新應用程式的建構設定
如要存取 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 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[null,null,["上次更新時間: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)."]]