34

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 :)

Community
  • 1
  • 1
nsvir
  • 8,781
  • 10
  • 32
  • 47

11 Answers11

83

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.

Paito
  • 1,553
  • 1
  • 15
  • 24
  • 1
    plugin 0.6.3 is just out. Also Android Studio 0.3.0 automatically fix the wrapper properties in this kind of issue. – Gabriele Mariotti Oct 19 '13 at 10:07
  • 5
    @GabrieleMariotti no it doesn't. This trick is still needed with latest versions of AS – ohcibi Nov 20 '13 at 18:33
  • Thank you so much for saving me a headache! – myforums Dec 19 '13 at 17:44
  • 2
    With Android Studio 0.4+, you must use Gradle 1.9 ([Gradle 1.10 *won't* work](https://sites.google.com/a/android.com/tools/knownissues)) and Android Gradle plugin 0.7+ (**[latest](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.android.tools.build%22%20a%3A%22gradle%22)** is currently 0.7.3). – Jonik Jan 10 '14 at 19:54
  • 1
    @Jonik I use Gradle plugin 0.8.+ in Android Studio 0.4.3 – IgorGanapolsky Jan 30 '14 at 20:53
  • Yeah. And Gradle plugin 0.8.0 [requires](http://tools.android.com/tech-docs/new-build-system) Gradle 1.10 and [Build Tools](http://developer.android.com/tools/revisions/build-tools.html) 19.0.0+. – Jonik Jan 30 '14 at 21:44
  • Looks like `2.4` is out. – theblang May 13 '15 at 03:06
15

I had same problem. Try to remove directory 'gradle' in project directory and then rebuild project. It helped me.

Volodymyr
  • 1,037
  • 1
  • 11
  • 27
  • 1
    I removed the gradle folder under my project folder, but now it's not back when I rebuild. – mraviator Oct 19 '13 at 12:18
  • 3
    When I was importing project again I chose "Use customizable gradle wrapper". Then Android Studio created 'gradle' directory. – Volodymyr Oct 19 '13 at 14:52
  • 1
    The same things happened today in my project since I updated my `Android Studio`. I downloaded `Gradle 1.8`, put it into `~/bin` folden and linked in project properties. Also set graddle plugin to `classpath 'com.android.tools.build:gradle:0.6.+'`. So it worked project have been compiling application launches. – sultan Oct 28 '13 at 16:06
12

The Android Studio ask you for download and install the Gradle version 1.8 for you.

Also the Android Gradle plugin version 0.6.2 has an issue and not works properly.
As said on the official page use the version 0.6.3:

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

More info: http://tools.android.com/knownissues

sabadow
  • 5,095
  • 3
  • 34
  • 51
6

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.

IgorGanapolsky
  • 26,189
  • 23
  • 116
  • 147
4

The Android Gradle 0.6.2 plugin that was published on Maven Central. Edit your build.gradle file and instead of depending on "0.6.+", depend on "0.6.1".

Allen
  • 350
  • 2
  • 13
3

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

Dheeraj Bhaskar
  • 18,633
  • 9
  • 63
  • 66
2

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.

Pang
  • 9,564
  • 146
  • 81
  • 122
johnw14
  • 21
  • 1
  • You said: "I used the 'Use customizable gradle wrapper' as suggested". But where is that suggested? – IgorGanapolsky Jan 10 '14 at 16:53
  • I believe every Android project in Android Studio should provide gradle wrapper files, so that you don't have to download the gradle distribution yourself and unzip it and set an environment variable (like you did). – IgorGanapolsky Jan 10 '14 at 17:28
1

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.

Bruce
  • 306
  • 2
  • 7
0

Similar Issue :

Just updated android studio :p

Help -> Check for Update...

Tobliug
  • 2,992
  • 30
  • 28
0

This is a late response, but in case anybody's run into a problem of the gradle version in their ionic project being overwritten by an older one by AS, just remove the android platform from your ionic project and then re-add it. Evidently, installing Gradle is part of that command, so you'll overwrite the overwrite, and get the version you need to run ionic build android from within your Ionic project's root directory.

Although, WARNING: Removing the Android platform, and then re-installing it, might wipe the splashscreens and icons that you'd had in your resources folder. And by "might," I mean that it's happened every time that I've done it (which makes sense, since the resources folder is inside of the android folder that you're removing/re-intalling). Perhaps a more eloquent command line input could reinstall the android platform while leaving the resources folder alone, but, in any case, make sure to copy the directory with your custom splashscreens and icons to a new one before running the re-install.

sparkholiday
  • 82
  • 10
0

You can download the latest Gradle file from This link

You can then add it to your File -> Settings -> Build, Execution, Deployment -> Gradle path and the sync the project

gunwin
  • 4,578
  • 5
  • 37
  • 59