全部Gradle版本和Gradle插件版本匹配关系

本文概述了不同Gradle版本对特定Java版本的支持情况,以及Kotlin的兼容性,包括嵌入式Kotlin版本和最低要求的Gradle版本。同时提及了AndroidStudio的AGP插件版本对应关系。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

See the table below for the Java version supported by a specific Gradle release:

Table 1. Java Compatibility
Java versionSupport for toolchainsSupport for running Gradle

8

N/A

2.0

9

N/A

4.3

10

N/A

4.7

11

N/A

5.0

12

N/A

5.4

13

N/A

6.0

14

N/A

6.3

15

6.7

6.7

16

7.0

7.0

17

7.3

7.3

18

7.5

7.5

19

7.6

7.6

20

8.1

8.3

21

8.4

8.5

22

8.7

N/A

23

N/A

N/A

Kotlin

Gradle is tested with Kotlin 1.6.10 through 2.0.0-Beta3. Beta and RC versions may or may not work.

Table 2. Embedded Kotlin version
Minimum Gradle versionEmbedded Kotlin versionKotlin Language version

5.0

1.3.10

1.3

5.1

1.3.11

1.3

5.2

1.3.20

1.3

5.3

1.3.21

1.3

5.5

1.3.31

1.3

5.6

1.3.41

1.3

6.0

1.3.50

1.3

6.1

1.3.61

1.3

6.3

1.3.70

1.3

6.4

1.3.71

1.3

6.5

1.3.72

1.3

6.8

1.4.20

1.3

7.0

1.4.31

1.4

7.2

1.5.21

1.4

7.3

1.5.31

1.4

7.5

1.6.21

1.4

7.6

1.7.10

1.4

8.0

1.8.10

1.8

8.2

1.8.20

1.8

8.3

1.9.0

1.8

8.4

1.9.10

1.8

8.5

1.9.20

1.8

8.7

1.9.22

1.8

插件版本

所需的最低 Gradle 版本
8.4(Alpha 版)8.6-rc-1
8.38.4
8.28.2
8.18.0
8.08.0
7.47.5

参考下面网址可以看全部的。

Android Studio  |  Android Developers (google.cn)icon-default.png?t=N7T8https://developer.android.google.cn/build/releases/past-releases/agp-4-2-0-release-notes?hl=zh-cn

### 查找 Gradle 及其插件的兼容版本 当遇到 `The versions of the Android Gradle plugin and Gradle are not compatible` 错误时,这通常意味着所使用的 Gradle 版本 Android Gradle 插件版本匹配。为了确保两者之间的兼容性,可以参考官方文档中的兼容性表格。 #### 官方推荐的方法 Google 提供了一个详细的兼容性矩阵来帮助开发者找到合适的组合[^1]: | Android Studio Version | Recommended AGP (Android Gradle Plugin) Version | |------------------------|------------------------------------------------| | Arctic Fox | 7.0 | | Bumblebee | 7.1 | | Dolphin | 7.2 | | Electric Eel | 7.3 | | Flamingo | 7.4 | | Giraffe | 8.0 | 对于特定的 Gradle Java 版本兼容性问题,在实际测试中发现,如果使用了较新的 JDK(如 Java 21),可能会导致与旧版 Gradle 不兼容的情况。例如,配置文件 `gradle-wrapper.properties` 中指定了 `distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip` 并尝试切换到不同的 JDK 版本(JBR-17 或 JBR-21),则会触发错误提示 "Your build is currently configured to use incompatible Java 21.0.3 and Gradle 7.6." 这表明当前构建环境设置为使用不兼容的 Java 21.0.3 Gradle 7.6。建议升级至至少 Gradle 8.5,并且最大支持的 Gradle JVM 版本应不超过 19[^3]。 因此,要解决这个问题,应该更新项目的 Gradle 版本以及相应的 Android Gradle 插件版本以保持一致性最佳性能。具体操作可以通过修改项目根目录下的 `build.gradle` 文件内的依赖项部分实现。 ```groovy // Project-level build.gradle dependencies { classpath 'com.android.tools.build:gradle:<AGP_VERSION>' } ``` 同时也要调整 `gradle/wrapper/gradle-wrapper.properties` 文件里的 `distributionUrl` 属性指向所需的新版本 Gradle 发行包 URL。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值