33

Just updated Android-Studio to version 0.2.7 an now I get the error message from the title:

error message

In the log window there is link to the grade setup:

configuration dialogue

No matter which option I use the error message stays the same.

I deleted my ~/.gradle directory and projects **/.gradle directories.

It seems that nothing helps.

Nitpick: compile on the command-line using \opt\gradle\1.6\bin\gradle.bat build works fine.

Martin
  • 11,577
  • 16
  • 80
  • 110
  • I get the same error after upgrading from Gradle 1.7 to 1.8 after having already been on Android Studio 0.2.7 – withoutclass Oct 01 '13 at 17:23
  • As [suggested by jfsso](http://stackoverflow.com/a/18689803/356895): Run `gradle wrapper` in the root directory of your project to generate an updated version of the wrapper files: `gradle-wrapper.jar` and `gradle-wrapper.properties`. – JJD Oct 05 '13 at 22:03

7 Answers7

12
  1. Go to Preferences > Project Settings > Gradle and choose "Use gradle wrapper" instead of the bundled option
  2. Open your gradle-wrapper.properties and change the distributionUrl to use 1.7 if it is not already (mine was 1.6), i.e. distributionUrl=http\://services.gradle.org/distributions/gradle-1.7-bin.zip
Derek Shockey
  • 1,837
  • 17
  • 15
  • I got the same **Gradle version 1.6 is required. Current version is 1.8.** error. I tried changing the distribuitionUrl from `distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-bin.zip` to `distributionUrl=http\://services.gradle.org/distributions/gradle-1.7-bin.zip` am getting a different error **Gradle version 1.8 is required. Current version is 1.7. If using the gradle wrapper, try editing the distributionUrl in /Users/upandian/Library/Caches/AndroidStudioPreview/compile-server/gradle/wrapper/gradle-wrapper.properties to gradle-1.8-all.zip** – LoveMeSomeFood Nov 07 '13 at 15:57
11

I managed to fix my project through some combination of invalidating Android Studio cache, deleting .idea and .gradle directories and .iml files, restarting Studio, and reimporting the project:

Invalidate Cache confirm

on Mac OSX using Homebrew, brew install gradle then pick local gradle distribution and point to /usr/local/Cellar/gradle/1.7/libexec for gradle home: local distribution

vinc3m1
  • 4,075
  • 1
  • 26
  • 23
  • As of now brew will install version 1.8 by default, which also causes the Askers error. – withoutclass Oct 01 '13 at 17:37
  • I paste /usr/local/Cellar/gradle/2.0/ to gradle home and it is wrong, yes need paste /usr/local/Cellar/gradle/2.0/libexec! Thanks @vinc3m1! to best answer! – SBotirov Aug 18 '14 at 04:48
8

You do not want to manage gradle at a system level, it is better handled per project. Android Studio projects already setup gradle wrapper handling when creating new projects but if you have an older one you can add the same file that Android Studio does. Think of this as an gradle bootstrap file that will download the correct gradle version per project. You can also read up on Gradle Wrapper and generate a shell script called gradlew that will provide gradle-free bootstrapping.

In gradle/wrapper/gradle-wrapper.properties in your project directory make sure you have:

#
#Tue Oct 08 13:40:54 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

Then when you go into Gradle you can set it to use the gradle wrapper. This is the default when creating new projects in Android Studio.

There are at least three approaches to migration or adding Gradle properly and using the new project structure Google and Android Studio has introduced.

  • Create a new project and copy over the code
  • Export from Eclipse to Gradle (deprecated)
  • Import code into Android Studio (recommended)
  • Try to manually get everything in order by creating the correct gradle files and reorganizing the project.

For now I'm copying the files over to a new project until the tools get a bit better.

Cameron Lowell Palmer
  • 21,528
  • 7
  • 125
  • 126
2

We have two computers, one of which gave that same message after upgrading to Android Studio 0.2.7. We noticed that the computer which could still build had Gradle installed independently of Android Studio.

Installing Gradle 1.6 downloaded from the Gradle web site fixed this issue on the computer that wouldn't build.

Abe
  • 29
  • 1
2

My fix was basically what Abe did but I wanted to give a bit more explanation:

Download gradle 1.6 from the gradle website

Extract somewhere on your pc/mac

Open up android studio, go to Preferences -> Gradle (left panel) -> and chooose Local gradle distribution. Point Gradle home to the location where you extracted gradle.

This fixed the issue for me. Using the gradle wrapper and the bundled gradle distribution both failed

Matt Wolfe
  • 8,924
  • 8
  • 60
  • 77
2

In my case, i updated gradle to the latest version (1.8) and then changed the gradle.build files (for my project and for the libraries i was using) like these:

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

The Synchronize files and Refresh/Invalidate cache. This seems to solve the problem. I think that Gradle in order to determine the minimum required version just reads the above value.

netcyrax
  • 1,079
  • 1
  • 13
  • 27
1

Here's what I did to get my project working:

  1. Installed Gradle 1.7 on my OS (OS X users can use brew for this)
  2. Added this to my local.properties file: sdk.dir=/Applications/Android\ Studio.app/sdk
  3. Created gradle wrappers with gradle wrapper command.
  4. Chose "Use gradle wrapper (recommended)" option in Android Studio.
jfsso
  • 25
  • 4