46

Whenever I try to import my Eclipse project to Android Studio I get the following error :

You are using an old, unsupported version of Gradle. Please use version 1.8 or greater. Please point to a supported Gradle version in the project's Gradle settings or in the project's Gradle wrapper (if applicable.)

Consult IDE log for more details (Help | Show Log)

Im using Android Studio 0.3 and Ubuntu, I also tried it on a Windows 8 box with fresh install but getting the same error. I'm using default gradle wrapper and I tried checking and unchecking auto import option. Is this a bug? How can I get around it. How do I update gradle to 1.8 or check the current gradle version?

Binoy Babu
  • 16,699
  • 17
  • 91
  • 134

3 Answers3

66

I had to edit the gradle wrapper settings in gradle/wrapper/gradle-wrapper.properties and change gradle version to 1.9.

./gradle/wrapper/gradle-wrapper.properties :

#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.9-all.zip

I had to change gradle-1.6-bin.zip to gradle-1.9-all.zip. I guess the old ADT plugin from eclipse which generates this file still uses the old URL.

Then I had to create a local.properties in project root and set correct SDK dir in it.

./local.properties

sdk.dir=/home/user/pathtosdk

Did that and imported using default gradle wrapper and voila! The project imported without any problem.

Notes: This also fixes the issue with org.gradle.tooling.GradleConnectionException: Could not execute build using Gradle distribution 'services.gradle.org/distributions/gradle-1.6-bin.zip';.: Could not execute build using Gradle distribution 'services.gradle.org/distributions/gradle-1.6-bin.zip'; You must also make sure that in the file ./build.gradle, com.android.tools.build:gradle:0.5.+ should be changed to com.android.tools.build:gradle:0.7.+.

If you are still experiencing problems with import, open up the project root in command line and run ./gradlew or gradlew.bat according to your os. You'll be getting errors with more debug info and maybe tips on how to solve them.

Binoy Babu
  • 16,699
  • 17
  • 91
  • 134
  • 1
    Could you specify which gradle-wrapper.properties file has to be modified ? I have 23 on my Mac ... – 2Dee Oct 22 '13 at 10:11
  • 4
    @Toodee The gradle wrapper will be in your *project folder/gradle/wrapper/gradle-wrapper.properties*. – Binoy Babu Oct 22 '13 at 10:17
  • 1
    Of course, so silly of me, thought this was a file used system wide, and not tied to the project. Should have looked closer. Thanks ! – 2Dee Oct 22 '13 at 10:31
  • 2
    Also want to point out this fixes the issue with org.gradle.tooling.GradleConnectionException: Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.: Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'. – Kalel Wade Oct 22 '13 at 15:38
  • 5
    But why do we have to go through all of this just to get it to work? I am using the latest of everything for Eclipse and Android studio. – noisygecko Oct 24 '13 at 20:28
  • 1
    You also have to edit build.gradle and set classpath to 'com.android.tools.build:gradle:0.6.+' – joycollector Oct 28 '13 at 16:45
  • 1
    @joycollecter better set to 0.6.3 specifically because 0.6.2 is buggy. – Binoy Babu Oct 28 '13 at 16:49
  • I don't have a gradle folder in my project. Am I supposed to? I just have one in my documents folder. Also there's no classpath in my build.gradle.. – Karl Nov 02 '13 at 16:47
  • Try recreating build.gradle using eclipse. – Binoy Babu Nov 03 '13 at 10:15
  • 1
    Also sdk path should look similar to this, with double slashes: C\:\\Android\\android-sdk-windows\\ – vortexwolf Nov 03 '13 at 19:19
  • If your sdk is in a custom location you will need to create a symbolic link inside Android Studio's SDK Path to point to your custom location as explained here: http://stackoverflow.com/a/18252791/1219971 – dwp4ge Dec 12 '13 at 02:53
  • Forgot to mention... the comment above would be a better alternative to the ./local.properties step. – dwp4ge Dec 12 '13 at 03:21
  • 2
    It amazes me that anyone is able to use this IDE. I have had nothing but problems for at least 2 days now. – Mgamerz Jan 05 '14 at 21:20
6

For me line in build.gradle file

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

to

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

Also needed to be updated to import correctly in Android Studio.

  • This fixes the slightly different error message `Project is using an old version of the Android Gradle plug-in. The minimum supported version is XXX. Please update the version of the dependency 'com.android.tools.build:gradle' in your build.gradle files.` – stemadsen Dec 28 '13 at 23:43
3

I had exactly the same problem. I solved this issue. Download latest Gradle manually and unpack it, then when you import gradle file in Android studio choose "Use local gradle distribution" and select the folder where you unpacked gradle. By doing this you will be able to import project to Android studio.

user1991679
  • 2,109
  • 1
  • 23
  • 19