重新安装Android Studio,无法编译项目。无法升级Gradle?

时间:2016-09-22 00:26:21

标签: android android-studio gradle

我按照in-Android Studio的提示将我的gradle配置升级到2.2-all.zip。

我在终端中运行了sdk install gradle 2.2

我重启Android Studio。

" Gradle项目同步失败"

当我点击"再试一次"在gradle build failed提示符下,我收到有关jakewharton SDK manager的错误。在他们的github上他们说项目已被弃用,所以我在依赖项中评论

dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
//        classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+'
        classpath 'de.felixschulze.gradle:gradle-hockeyapp-plugin:3.2'
    }

注释掉了,我得到了

Error:Gradle version 2.2 is required. Current version is 2.14.1. If using the gradle wrapper, try editing the distributionUrl in /Users/quantum/pocket-android/gradle/wrapper/gradle-wrapper.properties to gradle-2.2-all.zip.

Please fix the project's Gradle settings.
<a href="fixGradleVersionInWrapper">Fix Gradle wrapper and re-import project</a><br><a href="openGradleSettings">Gradle settings</a>

我的gradle-wrapper.properties:

#Wed Sep 21 20:05:48 EDT 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-all.zip

事件日志:

```

Gradle sync failed: Gradle version 2.2 is required. Current version is 2.14.1. If using the gradle wrapper, try editing the distributionUrl in /Users/quantum/pocket-android/gradle/wrapper/gradle-wrapper.properties to gradle-2.2-all.zip.
         Please fix the project's Gradle settings.
         Consult IDE log for more details (Help | Show Log)

搜索&#34; 2.14&#34;在我的项目中没有结果。

如何升级Gradle?

1 个答案:

答案 0 :(得分:4)

我最近遇到过这种情况,发现以下错误有点误导:

Gradle sync failed: Gradle version 2.2 is required. Current version is 2.14.1. If using the gradle wrapper, try editing the distributionUrl in /Users/quantum/pocket-android/gradle/wrapper/gradle-wrapper.properties to gradle-2.2-all.zip.
         Please fix the project's Gradle settings.
         Consult IDE log for more details (Help | Show Log)

因为distributionUrl已经指向gradle-2.2-all.zip

事实证明,我们可以通过以下方式将gradle包装器设置为默认值来解决它:

Menu File -> Setings -> Build,Execution,Deployment -> Gradle

然后选择使用默认gradle包装器(推荐)