เวอร์ชัน AGP, D8 และ R8 ที่จำเป็นสำหรับเวอร์ชัน Kotlin
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ปลั๊กอิน Android Gradle (AGP) และผู้คอมไพล์ D8 และ R8 เข้ากันได้กับไฟล์คลาสจาก Kotlin เวอร์ชัน 1.3 ขึ้นไป
คอมไพเลอร์ D8 และ R8 รองรับไฟล์คลาสจาก Kotlin เวอร์ชัน 1.3 ขึ้นไปตั้งแต่เวอร์ชัน 2.1.86 (รวมอยู่ใน AGP 4.1)
สำหรับไฟล์คลาสจาก Kotlin เวอร์ชัน 1.4 ขึ้นไป จะต้องมีเวอร์ชัน AGP, D8 และ R8 ขั้นต่ำสำหรับ Kotlin แต่ละเวอร์ชัน
ตารางต่อไปนี้แสดงเวอร์ชันขั้นต่ำที่จำเป็นของ AGP, D8 และ R8 สำหรับ Kotlin แต่ละเวอร์ชัน โปรดทราบว่า AGP จะมาพร้อมกับ D8 และ R8 ดังนั้นเวอร์ชัน D8 และ R8 ที่จําเป็นจะมีผลเฉพาะเมื่อใช้ D8 และ R8 นอก AGP หรือหากลบล้างเวอร์ชันที่รวมอยู่
เวอร์ชัน 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 |
8.10.21 |
เวอร์ชัน AGP ที่แสดงในตารางจะใช้คอมไพเลอร์ D8 และ R8 เวอร์ชันที่ระบุโดยอัตโนมัติ
เมื่อใช้การแปลงโค้ด Java 8 ขึ้นไปให้เป็นรูปแบบทั่วไป คุณต้องใช้ AGP เวอร์ชัน 7.0 (และ D8 และ R8 เวอร์ชัน 3.0.76)
R8 จะแสดงข้อมูลเมตา Kotlin ได้เฉพาะเวอร์ชัน 1.4 ขึ้นไป เมื่อใช้ R8 เพื่อลดขนาดไลบรารี Kotlin ที่มีข้อมูลเมตาจาก Kotlin เวอร์ชัน 1.3 ระบบจะแปลงข้อมูลเมตาเป็นรูปแบบ Kotlin 1.4 สำหรับ Kotlin เวอร์ชัน 1.4 ขึ้นไป R8 จะเก็บเวอร์ชันไว้
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 UTC
[[["เข้าใจง่าย","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 UTC"],[],[],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."]]