Kotlin 版本需要搭配的 AGP、D8 和 R8 版本
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Android Gradle 外掛程式 (AGP) 以及 D8 和 R8 編譯器與 Kotlin 1.3 以上版本的類別檔案相容。
D8 和 R8 編譯器從 2.1.86 版 (隨附於 AGP 4.1) 開始支援 Kotlin 1.3 版的類別檔案。如果是 Kotlin 1.4 以上版本的類別檔案,每個 Kotlin 版本都有需要搭配的最低 AGP、D8 和 R8 版本。
下表列出每個 Kotlin 版本所需的最低 AGP、D8 和 R8 版本。請注意,AGP 會隨附 D8 和 R8,因此只有在 AGP 以外使用 D8 和 R8,或是覆寫隨附版本時,才需要指定 D8 和 R8 版本。
Kotlin 版本 |
所需的 AGP 版本 |
必要的 D8 和 R8 版本 |
1.3 |
4.1 |
2.1.86 |
1.4 |
7.0 |
3.0.76 |
1.5 |
7.0 |
3.0.77 |
1.6 |
7.1 |
3.1.51 |
1.7 |
7.2 |
3.2.47 |
1.8 |
7.4 |
4.0.48 |
1.9 |
8.0 |
8.0.27 |
2.0 |
8.5 |
8.5.10 |
2.1 |
8.6 |
8.6.17 |
2.2 |
8.10 |
2021 年 10 月 8 日 |
表中列出的 AGP 版本會自動使用指定的 D8 和 R8 編譯器版本。
使用 Java 8 以上的 API 脫糖程序時,需要使用 AGP 7.0 版 (以及 D8 和 R8 3.0.76 版)。R8 只能輸出 Kotlin 1.4 以上版本的中繼資料。使用 R8 縮減內含 Kotlin 1.3 版本中繼資料的 Kotlin 程式庫時,中繼資料會轉換為 Kotlin 1.4 格式。如果是 Kotlin 1.4 以上版本,R8 會保留該版本。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# AGP, D8, and R8 versions required for Kotlin versions\n\nThe Android Gradle plugin (AGP) and the D8 and R8 compilers are compatible with\nclass files from Kotlin version 1.3 and higher.\n\nThe D8 and R8 compilers support class files from Kotlin version 1.3 starting\nfrom version 2.1.86 (included in AGP 4.1).\nFor class files from Kotlin version 1.4 and higher there is a minimum required\nAGP, D8, and R8 version for each Kotlin version.\n\nThe following table shows the minimum required versions of AGP, D8 and R8 for\neach Kotlin version. Note that AGP comes bundled with D8 and R8, so the\nrequired D8 and R8 version is only relevant when using D8 and R8 outside of AGP\nor if overriding the bundled version.\n\n| Kotlin version | Required AGP version | Required D8 and R8 version |\n|----------------|----------------------|----------------------------|\n| 1.3 | 4.1 | 2.1.86 |\n| 1.4 | 7.0 | 3.0.76 |\n| 1.5 | 7.0 | 3.0.77 |\n| 1.6 | 7.1 | 3.1.51 |\n| 1.7 | 7.2 | 3.2.47 |\n| 1.8 | 7.4 | 4.0.48 |\n| 1.9 | 8.0 | 8.0.27 |\n| 2.0 | 8.5 | 8.5.10 |\n| 2.1 | 8.6 | 8.6.17 |\n| 2.2 | 8.10 | 8.10.21 |\n\n\u003cbr /\u003e\n\nThe AGP versions listed in the table automatically use the\nspecified D8 and R8 compiler versions.\n\nWhen using [Java 8+ API desugaring](/studio/build/library-desugaring)\nAGP version 7.0 (and D8 and R8 version 3.0.76) is required.\nR8 can only emit Kotlin metadata of version 1.4 and newer. When using R8 to\nshrink a Kotlin library with metadata from Kotlin version 1.3 the metadata\nis converted to the Kotlin 1.4 format. For Kotlin version 1.4 and newer R8\npreserves the version."]]