47

When I try to build a project on Android Studio, I get this error:

Compilation completed with 1 error and 0 warnings in 9 sec
1 error
0 warnings
org.gradle.tooling.GradleConnectionException: Could not install Gradle distribution from 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.: Could not install Gradle distribution from 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.

What can I do to fix it?

UPDATE:

When I look at the Error Log, I saw this:

org.jetbrains.plugins.gradle.settings.GradleSettings cannot be cast to org.jetbrains.plugins.gradle.settings.GradleSettings:
org.jetbrains.plugins.gradle.settings.GradleSettings cannot be cast to org.jetbrains.plugins.gradle.settings.GradleSettings
2
  • I was getting the same compilation error using Android Studio 0.2.10 but only when my device was plugged in. Updating to 0.2.11 fixed my problem.
    – Kerem
    Oct 4, 2013 at 0:21
  • What does your build.gradle look like? What does your settings.gradle look like? Are you putting classpath 'com.android.tools.build:gradle:0.6.+' Dec 16, 2013 at 22:17

14 Answers 14

67

Please read the log from:

  • On Microsoft Windows: [Windwos Drive]\Documents and Settings\[your username]\.AndroidStudioPreview\system\log
  • On Mac and Linux: ~/.AndroidStudioPreview/system/log/

And you will find the tmp download path of gradle-1.6-bin.zip. For example, mine is:

2013-05-17 09:42:16,934 [ 283002]   INFO - ution.rmi.RemoteProcessSupport - Unzipping C:\Documents and Settings\Kiki.J.Hu\.gradle\wrapper\dists\gradle-1.6-bin\72srdo3a5eb3bic159kar72vok\gradle-1.6-bin.zip to C:\Documents and Settings\Kiki.J.Hu\.gradle\wrapper\dists\gradle-1.6-bin\72srdo3a5eb3bic159kar72vok 
...
Caused by: com.intellij.openapi.externalSystem.model.ExternalSystemException: Could not install Gradle distribution from 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.
java.util.zip.ZipException: error in opening zip file

So I know the cause: I downloaded an incomplete ZIP package.
Then I downloaded the full ZIP package from http://services.gradle.org/distributions/gradle-1.6-bin.zip manually and copied this ZIP package to:

  • Windows: C:\Documents and Settings\Kiki.J.Hu\.gradle\wrapper\dists\gradle-1.6-bin\72srdo3a5eb3bic159kar72vok\
  • Mac OS X: ~/.gradle/wrapper/dists/gradle-1.10-all/6vpvhqu0efs1fqmqr2decq1v12/

Everything is OK now.

5
  • 1
    I met the same err“org.jetbrains.plugins.gradle.settings.GradleSettings cannot be cast to org.jetbrains.plugins.gradle.settings.GradleSettings”, so I had to re-install Android Studio, and this err log disappeared. But I can't output logcat from the IDE, damn!
    – Kiki Hu
    May 20, 2013 at 8:22
  • 2
    For me, reinstalling indeed did the trick. Replacing the gradle zip file with the one downloaded from the internet did not solve the issue though.
    – Xilconic
    Jun 2, 2013 at 12:49
  • Was stuck with this since yesterday. YOU'RE THE BOSS!! Jun 8, 2013 at 8:27
  • 1
    in OSX the logs are located at ~/Library/Logs/AndroidStudioPreview for me. The stuck and locked zip was located at ~/.gradle/wrapper/dists
    – hoss
    Jun 19, 2013 at 13:48
  • Worked like charm.. although i didnt found the ;log
    – Aexyn
    Jul 3, 2013 at 18:31
8

For OS X:

Install Homebrew as a package manager. Then on Terminal, run:

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"

Install Gradle:

brew install gradle

It is the easiest way to get Gradle.

2

Before you click to new project, go to configure and set your proxy. I recommend set host name and port number, since I had problems with auto-detect proxy settings. Check your connection in settings.

3
  • 2
    Did that, from settings 'check connection' works fine but Gradle is not downloaded anyway during make.
    – Marcin Gil
    May 16, 2013 at 12:33
  • Weird thing is I didn't need Gradle to build the project on Eclipse. Can Gradle be disabled in Android Studio? May 16, 2013 at 13:02
  • Moreover 'check for updates' doesn't work. Even if proxy is set in Settings.
    – Marcin Gil
    May 16, 2013 at 13:21
2

I also had issues downloading Gradle through Android Studio.

This was my workaround:

  1. Download Gradle directly from http://services.gradle.org/distributions/gradle-1.6-bin.zip
  2. Copy the contents of gradle-1.6 to \Android\android-studio\plugins\gradle
  3. Copy gradle.jar to \Android\android-studio\lib\
  4. Restart Android Studio

Hope this helps!

5
  • No luck. Did it all, same message at build. May 16, 2013 at 14:27
  • Nick: Could you elaborate your instructions a bit more in details. The zip-file you pointed to and which I downloaded is not excactly the same as the Android-Studio structure. Many thanks in advance.
    – moster67
    May 16, 2013 at 14:32
  • The gradle-1.6-bin.zip has a folder gradle-1.6. I copied the contents of that folder (bin, init.d, lib, media) to the plugins\gradle folder in the Android Studio folder. Then I copied the plugins\gradle\lib\gradle.jar file to the \lib folder in the android-studio folder.
    – Nick P
    May 16, 2013 at 20:18
  • 1
    Worked for me BUT Android Studio crashed on first open after I copied the gradle files. I closed it again, second open it worked by my project was lost so I re-imported the project and now all appears to be working
    – Kevin
    May 19, 2013 at 0:26
  • Thanks for the feedback. Look to the accepted answer in this thread. Kiki Hu had a simpler approach that involves manually downloading the zip and placing it in a particular directory and restarting Android Studio. stackoverflow.com/a/16600297/1524067
    – Nick P
    Jul 24, 2013 at 19:26
2

Edit the gradle wrapper settings in gradle/wrapper/gradle-wrapper.properties and change gradle-1.6-bin.zip to gradle-1.8-bin.zip.

./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.8-bin.zip

It should compile without any error now.

2

In my case this was because the system had low memory. When I closed some applications, the error disappeared.

1
  • 1
    Same here. I discovered that the Gradle fatal exception error was misleading error caused by the fact that Java VM was not loading due to "Could not reserve enough space for object heap". It all worked OK after setting the following parameters : * File -> Settings -> Compiler -> Java Compiler -> Additional command line.. -> -Xms256m -Xmx512m * File -> Settings -> Compiler -> Gradle -> VM Options -> -XX:MaxHeapSize=256m -Xmx256m Mar 21, 2014 at 16:15
1

For me it turned out to be my firewall, which is VIPRE, was blocking the Gradle.org site and quietly causing a bad gradle-1.7-bin.zip to be created under .gradle\wrapper\dists\.

I had to open VIPRE and add gradle.org to "Bad Web Site Exceptions" (menu File -> Settings -> Firewall).

Then I downloaded http://services.gradle.org/distributions/gradle-1.7-bin.zip using a browser and overwrote the bad version. I restarted Android Studio, and all is good.

1

FYI, on my Mac, it was downloading Gradle into the ~/.gradle directory. You can see how it's progressing by looking there:

du ~/.gradle
1
  • It downloads gradle (in my case 1.7) and then downloads maven too. Total after download was 94M in ~/.gradle directory
    – John Cass
    Sep 12, 2013 at 6:30
1

I noticed that my MyProject/gradle/wrapper/gradle-wrapper.properties file was completely empty, so I deleted it and Android Studio proceeded to download whatever it needed.

After that it worked.

0

I tried Kiki Hu's solution, and it worked. After that, there will be more downloads from the Maven repository which includes Dalvik Debug Monitor Server (DDMS), Guava, etc., which again is not required if you are exporting from Eclipse into Android Studio.

0

If you're like me, you tried to start a version prior to 0.2.0. Following Google's notes in Getting Started with Android Studio, you'll need to remove and re-install Android Studio.

"Note: There is not a patch update available from 0.1.9 to 0.2. To update from Android Studio 0.1.x to 0.2.x, you must install a new Android Studio bundle from this page. The reason for that is that we have made changes to the bundled SDK such that it includes a pre-configured local Maven repository which can serve up the v4 support library and which is required for creating new projects."

Also be aware that if you have your Android SDK files stored in C:\Program Files (x86)\Android\android-studio\sdk you should move them before the uninstall, or you'll need to download the SDK files again.

After the un-install and re-install, it is now working on my Windows 7 64-bit system.

0

Remove all files from C:\Documents and Settings\[User]\.gradle\wrapper\dists\, rebuild the project and rebuild your project on Android Studio. It works for me :)

0

I have noticed one thing: When my Android Studio is build 130.737825, it automatic downloads Gradle 1.6 to C:\Users\yourname\.gradle/wrapper/dists/gradle-1.6-bin/72srdo3a5eb3bic159kar72vok/.

However, when I update my Android Studio to build 132.821530, it automatically downloads Gradle 1.7 to C:\Users\Administrator\.gradle\wrapper\dists\gradle-1.7-bin\2g3i7gan25uopmtc0lnjb1l9ff.

I don't know if it matters.

0

I had this error under fresh installation of IntelliJ (14.0), the problem was that I had not specified JDK. Fix: press ctrl + A + S (project structure), and check if SDK is correct.

my error looked like this:

Error:Android Gradle Build Target: org.gradle.tooling.GradleConnectionException: Could not execute build using Gradle installation ...

Not the answer you're looking for? Browse other questions tagged or ask your own question.