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
WarrenFaith
  • 57,492
  • 25
  • 134
  • 150
Charlie-Blake
  • 10,832
  • 13
  • 55
  • 90
  • 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 04 '13 at 00: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.+' – IgorGanapolsky Dec 16 '13 at 22:17

14 Answers14

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.

Guillaume
  • 21,685
  • 6
  • 63
  • 95
Kiki Hu
  • 686
  • 5
  • 2
  • 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 '13 at 08: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 02 '13 at 12:49
  • Was stuck with this since yesterday. YOU'RE THE BOSS!! – a_rahmanshah Jun 08 '13 at 08: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 '13 at 13:48
  • Worked like charm.. although i didnt found the ;log – Aexyn Jul 03 '13 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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
João M
  • 1,939
  • 21
  • 14
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.

Milutin
  • 195
  • 1
  • 5
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!

Nick P
  • 758
  • 7
  • 13
  • No luck. Did it all, same message at build. – Charlie-Blake May 16 '13 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 '13 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 '13 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 '13 at 00: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. http://stackoverflow.com/a/16600297/1524067 – Nick P Jul 24 '13 at 19:26
2

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

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Ivan Ičin
  • 9,672
  • 5
  • 36
  • 57
  • 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 – Jakub Czaplicki Mar 21 '14 at 16:15
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.

Binoy Babu
  • 16,699
  • 17
  • 91
  • 134
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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
GaryAmundson
  • 199
  • 9
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
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
John Cass
  • 11
  • 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 '13 at 06: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.

Will Madden
  • 6,477
  • 5
  • 28
  • 20
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.

Community
  • 1
  • 1
rudy s
  • 3,400
  • 1
  • 15
  • 6
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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
JimsJump
  • 31
  • 4
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 :)

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
einverne
  • 6,454
  • 6
  • 45
  • 91
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 ...

marcinj
  • 48,511
  • 9
  • 79
  • 100