Android Studio错误安装Gradle该怎么回事?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (2)
  • 关注 (0)
  • 查看 (18)

当我尝试在Android Studio上构建项目时,出现此错误:

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'.

我能做些什么来解决它?

当我查看错误日志时,我看到了这一点:

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
提问于
用户回答回答于

请阅读以下日志:

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

你会发现tmp的下载路径gradle-1.6-bin.zip。例如,我的是:

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

然后,我从http://services.gradle.org/distributions/gradle-1.6-bin.zip手动下载完整的ZIP包,并将此ZIP包复制到:

  • 视窗: 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/

用户回答回答于

对于OS X:

安装Homebrew作为包管理器。然后在终端上运行:

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

安装Gradle:

brew install gradle

扫码关注云+社区