我已经安装了新的Android Studio。一切都工作得很好,但当我试图创建一个新项目时,它在下载Gradle时卡住了。

有没有办法手动安装Android Studio所需的Gradle ?或者有其他方法可以解决这个问题吗?


当前回答

使缓存无效并重新启动

这对我很管用。

其他回答

Android Studio自带Gradle,但它没有命令行Gradle功能。

Android Studio中包含的gradle位于/Applications/Android Studio.app/plugins/gradle/lib中

进入Android Studio。应用目录,cd, Android studio。app

或者你可以直接cd /Applications/Android\ Studio.app/plugins/gradle/lib

If you're using OS X, and it continues to hang indefinitely, I'd recommend shutting down Android Studio (may have to force kill), then going to your ~/.gradle directory on the console. You'll see a wrapper/dists directory there and whatever version of gradle AS is trying to download. Check the timestamp of the download underneath the randomly named subdirectory. If you see that it is never changing, most likely your download was interrupted and AS wasn't able to restart it properly and will not unless you delete everything below the dists directory and start over.

因此,当AS关闭时,删除~/下面的所有内容。gradle/wrapper/dist,然后在AS中重新尝试一个新项目。您可以检查gradle下载文件的进度(它将以.part结尾),以确保它正在增长。给它足够的时间,因为它是一个大文件。

这就是最后对我有用的方法。

使缓存无效并重新启动

这对我很管用。

这对我来说也花了很长时间(连接慢)。

在Ubuntu(16.04)上,我可以通过查看以下内容来监控下载进度:

~/.gradle/wrapper/dists/gradle-3.3-all/55gk2rcmfc6p2dg9u9ohc3hw9/ 

在此目录下运行ls -al会显示gradle-3.3-all.zip文件。部分文件继续增长。

文件最终是88M。

请注意55gk2rcmfc6p2dg9u9ohc3hw9(和gradle版本)可能不同,请相应地更改您的命令。