Android Studio error installing Gradle

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

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.


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.


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.