Android 需要 Gradle 1.10 版。当前版本是 2.0
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24289410/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Gradle version 1.10 is required. Current version is 2.0
提问by Nabdreas
I am trying to use latest Gradle version (2.0), however I keep getting this message when hitting gradle buildin terminal. Why is it asking for 1.10 version? I am new to Gradle, so I'm trying to get my head around it.
我正在尝试使用最新的 Gradle 版本 (2.0),但是在终端中点击gradle build时我不断收到此消息。为什么要求 1.10 版本?我是 Gradle 的新手,所以我正在努力了解它。
Gradle version 1.10 is required. Current version is 2.0
需要 Gradle 1.10 版。当前版本是 2.0
Here are my dependencies (module build.gradle file):
这是我的依赖项(模块 build.gradle 文件):
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
classpath fileTree(dir: 'build-libs', include: '*.jar')
}
...and wrapper task:
...和包装任务:
task wrapper(type: Wrapper) {
gradleVersion = "2.0"
}
Also, I have set the distribution URL as follows (in the local.properties file):
此外,我已按如下方式设置分发 URL(在 local.properties 文件中):
distributionUrl=https\://services.gradle.org/distributions/gradle-2.0-all.zip
The final thing is that in File->Settings->Gradle
, I selected "Use customizable gradle wrapper"
最后一件事是File->Settings->Gradle
,我选择了“使用可自定义的 gradle 包装器”
GRADLE_HOME
is set to C:\Program Files (x86)\Gradle\gradle-2.0
GRADLE_HOME
设置为 C:\Program Files (x86)\Gradle\gradle-2.0
The build.gradle file:
build.gradle 文件:
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
classpath fileTree(dir: 'build-libs', include: '*.jar')
}
}
task wrapper(type: Wrapper) {
gradleVersion = "2.0"
}
UPDATE1
更新1
As it stands i am using this Android Studio 1.1.0 with 1.1.0-rc1 plugin version
就目前而言,我使用的是带有 1.1.0-rc1 插件版本的 Android Studio 1.1.0
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0-rc1'
}
Gradle version is 2.3 in gradle-wrapper.properties
gradle-wrapper.properties 中的 Gradle 版本为 2.3
distributionUrl=http\://services.gradle.org/distributions/gradle-2.3-all.zip
I have tried plugin version 1.1.0, but then it complains about com.android.application
我试过插件版本 1.1.0,但后来它抱怨com.android.application
UPDATE 01/2016
更新 01/2016
As it stands, i am using gradle 2.9 distribution in gradle - > wrapper -> gradle-wrapper.properties
就目前而言,我在 gradle -> wrapper -> gradle-wrapper.properties 中使用 gradle 2.9 发行版
distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-all.zip
and plugin is
和插件是
classpath 'com.android.tools.build:gradle:1.5.0'
采纳答案by lucas
The version of Android gradle plugin needs to be compatible with the version of Gradle. Checkout the version compatibility mapping table.
Android gradle 插件版本需要与Gradle 版本兼容。查看版本兼容性映射表。
回答by wono
Message:"Gradle version 1.10 is required. Current version is 2.0"
消息:“需要 Gradle 1.10 版。当前版本为 2.0”
Occurs when:Attempting to build an Android project that requires 1.10 version of Gradle while using 2.0 version of it as native.
发生时间:尝试构建需要 1.10 版本 Gradle 的 Android 项目,同时使用 2.0 版本作为本机。
Solution:Using Gradle Wrapper
解决方案:使用 Gradle Wrapper
Steps:
脚步:
Make sure the distributionUrlis specified as gradle-1.10-all.zipat the Gradle-wrapper properties file within the Android project. The file path would be like this:
MyAndroidProject/gradle/wrapper/gradle-wrapper.properties
Run Gradle Wrapper command at the very top level of the project where the executable scripts (i.e. gradlewand gradlew.bat) are located.
For Unix-likeOS:
./gradlew wrapper
For WindowsOS:
gradlew.bat wrapper
Run build command with Gradle Wrapper.
For Unix-likeOS:
./gradlew build
For WindowsOS:
gradlew.bat build
确保在 Android 项目中的 Gradle-wrapper 属性文件中将distributionUrl指定为gradle-1.10-all.zip。文件路径将是这样的:
MyAndroidProject/gradle/wrapper/gradle-wrapper.properties
在可执行脚本(即gradlew和gradlew.bat)所在的项目的最顶层运行 Gradle Wrapper 命令。
对于类 Unix操作系统:
./gradlew 包装器
对于Windows操作系统:
gradlew.bat 包装器
使用 Gradle Wrapper 运行构建命令。
对于类 Unix操作系统:
./gradlew 构建
对于Windows操作系统:
gradlew.bat 构建
回答by Mr.Moustard
I fix the problem updating the gradle version within build.gradle file:
我修复了在 build.gradle 文件中更新 gradle 版本的问题:
dependencies {
classpath 'com.android.tools.build:gradle:0.12.2'
}
}
This solve my problem. I hope this would help.
这解决了我的问题。我希望这会有所帮助。
回答by Alexey Dmitriev
Looks like the current version of Android Gradle plugin (0.12.2) works with Gradle of version not later than 1.12.
看起来当前版本的 Android Gradle 插件(0.12.2)适用于版本不晚于 1.12 的 Gradle。
I haven't found a direct statement for that on the Tools site, there is this phrase only:
我在工具网站上没有找到直接声明,只有这句话:
Gradle 1.10 or 1.11 or 1.12 with the plugin 0.11.1.
Gradle 1.10 或 1.11 或 1.12 与插件 0.11.1。
But I manually tested with Gradle 2.0 and 1.2 and it does not work, so I believe this restriction from the Tools site still applies for Android Gradle plugin 0.12.2.
但是我用 Gradle 2.0 和 1.2 手动测试,它不起作用,所以我相信来自工具站点的这个限制仍然适用于 Android Gradle 插件 0.12.2。
I would suggest to fail back to Gradle 1.12 by setting distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-bin.zip
in your gradle-wrapper.properties
file.
我建议通过distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-bin.zip
在您的gradle-wrapper.properties
文件中进行设置来故障回退到 Gradle 1.12 。
Then just use gradlew
as usual.
然后gradlew
照常使用。
回答by Peter Niederwieser
The Android plugin requires a particular version of Gradle. The latest Android plugin version requires 1.12, the Android plugin version declared in your build requires 1.10.
Android 插件需要特定版本的 Gradle。最新的 Android 插件版本需要 1.12,您构建中声明的 Android 插件版本需要 1.10。
回答by Raheel
I was following wono's method on mac and I was getting "gradlew command not found" error. Fixed issue by changing mod of gradlew file
我在 mac 上遵循了 wono 的方法,但出现“找不到 gradlew 命令”错误。通过更改 gradlew 文件的 mod 解决了问题
chmod +x gradlew
chmod +x gradlew
I hope this will help others
我希望这会帮助其他人
回答by kumar kundan
IF ABOVE FIX DO NOT WORK TRY THIS
如果以上修复不工作试试这个
You have to change this line in build.gradle
你必须改变这一行 build.gradle
classpath 'com.android.tools.build:gradle:0.9.+'
in
在
classpath 'com.android.tools.build:gradle:1.1.+'
you have to change this line in your build.gradle
你必须在你的 build.gradle
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
In
在
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
回答by Praveena
If you are getting this problem because you moved project developed using old Android studio to new Android Studio, then just create new project in new Android Studio and cross check your gradle related files with newly create project.
如果您遇到此问题是因为您将使用旧 Android Studio 开发的项目移至新 Android Studio,那么只需在新 Android Studio 中创建新项目,并使用新创建的项目交叉检查与 gradle 相关的文件。