Gradle version 1.8 is required. Current version is

2019-01-17 14:13发布

There is a new Android Studio update: https://sites.google.com/a/android.com/tools/recent/androidstudio030released

The link says:

The improved performance is made possible by changes in Gradle 1.8 and Android Gradle plugin version 0.6.+

So I changed my dependencies like this:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
    }

But I don't know where I can change the Gradle 1.6 to 1.8 ...

And when I compile the app I've got this error:

Gradle: A problem occurred evaluating project.

Gradle version 1.8 is required. Current version is 1.6

Where can I change the version ?

Thanks in advance :)

10条回答
等我变得足够好
2楼-- · 2019-01-17 14:45

You should use the following in your build.gradle:

buildscript {
  repositories {
      mavenCentral()
  }
  dependencies {
      classpath 'com.android.tools.build:gradle:0.7.+'
  }
}

Edit: Nowadays 0.9.+ is the most up-to-date gradle plugin.

查看更多
何必那么认真
3楼-- · 2019-01-17 14:50

Similar Issue :

Just updated android studio :p

Help -> Check for Update...

查看更多
看我几分像从前
4楼-- · 2019-01-17 14:53

I am not sure if this will help you but here is what fixed it for me:

Open up this file in your project:

<Project>/gradle/wrapper/gradle-wrapper.properties

Edit the distributionUrl line and set it too:

distributionUrl=https\://services.gradle.org/distributions/gradle-1.8-all.zip

Rebuild your project.

Update: You might want to use gradle-2.8-all.zip now.

查看更多
太酷不给撩
5楼-- · 2019-01-17 14:54

All other solutions are incomplete and non-working. Here's a step-by-step that worked for me.

I updated the gradle plugin in build.gradle to 0.7.+

dependencies {
    classpath 'com.android.tools.build:gradle:0.7.+'

}

But when using the gradle plugin 0.7.+, Android Studio needs Gradle 1.8. So, you have to update Gradle from 1.7 to 1.8. This was done by going to Tools -> Android -> Sync Project with Gradle Files It forces Android Studio to give out Error message you see on http://tools.android.com/recent

In the error message you have to click the part "Fix Gradle wrapper and re-import project". I restarted, not sure if this make a difference.

So far everything seems to work. I can create new projects and it build fast, without errors, but the gradle has still 0.5+. Looks like, I had to change it manually for every new projects. This is what I thought, because I didn't get any error or information from this installation to fix it. (Mac).

Than I went to my Windows installation, which had still Android Studio version 0.2.13 and tried the same procedure, I used with the updated version, changed the build,gradle and used Synch Project with Gradle Files. This gave me a total different information:

Gradle version 1.8 is required. Current version is 1.7. If using the gradle wrapper, try editing the distributionUrl in C:\Documents and Settings\Owner\Start Menu\Programs\Android Studio\gradle\wrapper\gradle-wrapper.properties to gradle-1.8-all.zip

Turned out, I have a gradle-wrapper.properties file in every project (in gradle/) but I don't have any gradle-wrapper.properties file at the location Android Studio gave me.

When you open the gradle-wrapper.properties file from your project, it will properly look like this:

#Sun Oct 20 03:35:31 CEST 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.7-bin.zip

To change the gradle-1.7-bin.zip into gradle-1.8-rc-1-bin is possible but not the solution I was looking for.

Check out if Andoid Studio already downloaded the gradle plugin 1.8

Directory of C:\Documents and Settings\Owner.gradle\wrapper\dists

2013-10-13  06:24    <DIR>          .
2013-10-13  06:24    <DIR>          ..
2013-10-04  18:17    <DIR>          gradle-1.6-bin
2013-10-13  06:24    <DIR>          gradle-1.7-all
2013-10-04  12:23    <DIR>          gradle-1.7-bin
2013-10-04  18:26    <DIR>          gradle-1.8-rc-1-bin
           0 File(s)              0 bytes
           6 Dir(s)  81 945 972 736 bytes free

Now I create a new gradle-wrapper.properties file in *C:\Documents and Settings\Owner\Start Menu\Programs\Android Studio\gradle\wrapper*

#Tue Oct 20 06:35:40 CEST 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-all.zip

This did the Trick. Now, after updating to 0.3, every new project gets a build.gradle with

dependencies {
    classpath 'com.android.tools.build:gradle:0.7.+'
}

and a gradle-wrapper.properties file in gradle/ with

distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-bin.zip

Credits

查看更多
走好不送
6楼-- · 2019-01-17 14:56

I took several steps including: downloaded the gradle-1.8-all.zip file and placed it in a new directory off of my user home directory (Windows-7) and named the directory "gradle-1.8". For good measure, I also unzipped the download in this new directory. I also added a user environmental variable "GRADLE_HOME" with a pathway to this new directory.

I manually edited the "build.gradle" file in the project's top-level directory and entered:

dependencies {
    classpath 'com.android.tools.build:gradle:0.6.3'
}

When Android Studio opened the existing project and I did a build or tried to run it, I got the subject error. The final solution, as mentioned by others, was a several step process:

  1. I removed both the "gradle" and the ".gradle" directories.
  2. I rebuilt the project which recreated the ".gradle" directory but not the "gradle" directory. Then, I closed the project and used "File/Import Project" to load the project again. And, I used the "Use customizable gradle wrapper" as suggested.

This worked. The "gradle" directory was created again in the project's top-level directory. The project builds clean and runs. It would be nice to have step-by-step upgrade instructions for these updates.

查看更多
做自己的国王
7楼-- · 2019-01-17 14:56

Old question but just in case someone runs into the same issue I had with upgrading.

If you have setup gradle for offline mode, it doesn't update the wrapper properly. Turning off offline mode (Preferences->Gradle->Offline work) then clean/rebuild pulled in the new gradle version. This assumes that gradle-wrapper.properties file has been updated.

查看更多
登录 后发表回答