简体   繁体   English

Android Studio项目的Gradle版本不正确

[英]Incorrect Gradle version for Android Studio project

I am using the latest version of Android Studio and have installed the latest version of Gradle from Gradle's website. 我正在使用最新版本的Android Studio,并已从Gradle的网站上安装了最新版本的Gradle。 I then imported some Android sample apps but the build generates an error that reads: 然后,我导入了一些Android示例应用程序,但是该构建生成了一个错误消息,内容为:

Gradle version 1.10 is required. 需要Gradle 1.10版。 Current version is 2.1. 当前版本是2.1。

I have no idea where it is getting the version 1.10 from. 我不知道它从哪里获得版本1.10。 If I open the gradle-wrapper.properties file, I have: 如果我打开gradle-wrapper.properties文件,则有:

distributionUrl=https://services.gradle.org/distributions/gradle-2.1-bin.zip distributionUrl = HTTPS://services.gradle.org/distributions/gradle-2.1-bin.zip

I have this problem with every sample I open. 我打开的每个样品都有这个问题。 Why isn't Gradle using the version I installed? 为什么Gradle不使用我安装的版本? The GRADLE_HOME environment variable is set to the path of the latest version of Gradle. GRADLE_HOME环境变量设置为最新版本的Gradle的路径。

Even if I run gradlew to force a download of the version of Gradle needed, I still get this error. 即使我运行gradlew来强制下载所需的Gradle版本,我仍然会收到此错误。 One post here in SO is: SO中的一篇文章是:

https://stackoverflow.com/a/23466323/753632 https://stackoverflow.com/a/23466323/753632

meaning that a specific version of Gradle is required for a specific version of the Android Gradle Plugin, but this was posted some time ago and it isn't clear whether this is an issue anymore. 这意味着特定版本的Android Gradle插件需要特定版本的Gradle,但这是在一段时间之前发布的,目前尚不清楚这是否已成为问题。

尝试卸载gradle并删除.gradle文件夹,然后让android studio下载gradle而不是从gradle网站手动安装。

Try clean and rebuild it will ok most of time. 尝试清理并重建大多数时间都可以。

And if you want to update the version to the latest. 并且如果您想将版本更新到最新。

You can try andle 您可以尝试andle

Simple three step to update all project at once. 简单的三步即可一次更新所有项目。

1. install: 1.安装:

    $ sudo pip install andle

2. set sdk: 2.设置sdk:

    $ andle setsdk -p <sdk_path>

3. update depedency: 3.更新权限:

    $ andle update -p <project_path> [--dryrun] [--remote] [--gradle]

--dryrun: only print result in console --dryrun:仅在控制台中打印结果

--remote: check version in jcenter and mavenCentral --remote:在jcenter和mavenCentral中检查版本

--gradle: check gradle version --gradle:检查gradle版本

See https://github.com/Jintin/andle for more information 参见https://github.com/Jintin/andle了解更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM