【问题标题】:ERROR: Gradle version 2.2 is required. Current version is 5.1.1错误:需要 Gradle 版本 2.2。当前版本是 5.1.1
【发布时间】:2019-11-22 20:59:41
【问题描述】:
build.gradle如下
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
错误如下:
错误:需要 Gradle 版本 2.2。当前版本是 5.1.1。
请修复项目的 Gradle 设置。
修复 Gradle 包装器并重新导入项目
打开 Gradle 包装器属性
摇篮设置
【问题讨论】:
标签:
android
android-gradle-plugin
【解决方案1】:
您可以尝试将项目级 build.gradle 文件中的 gradle 插件版本更改为 2.2.0:
classpath 'com.android.tools.build:gradle:2.2.0'
然后使 Android Studio 失效并重新启动。
【解决方案2】:
在终端中检查 Gradle 的版本
gradle --version
如果这是 5.1.1 版,您必须将系统环境变量设置为 gradle 2.2.0
或检查
gradlew --version
如果这是 5.1.1 版本就足够了
classpath 'com.android.tools.build:gradle:2.2.0'
在您的项目级别 build.gradle
【解决方案3】:
android gradle 插件和 gradle 版本是链接的。
在这里你可以找到all info:
Plugin version Required Gradle version
1.0.0 - 1.1.3 2.2.1 - 2.3
1.2.0 - 1.3.1 2.2.1 - 2.9
1.5.0 2.2.1 - 2.13
2.0.0 - 2.1.2 2.10 - 2.13
2.1.3 - 2.2.3 2.14.1+
2.3.0+ 3.3+
3.0.0+ 4.1+
3.1.0+ 4.4+
3.2.0 - 3.2.1 4.6+
3.3.0 - 3.3.2 4.10.1+
3.4.0+ 5.1.1+
在你的build.gradle中使用
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
}
在gradle-wrapper.properties 文件中
distributionUrl = https\://services.gradle.org/distributions/gradle-5.1.1-all.zip