问题
I just installed Android studio 2.3.1, but after starting it is telling me "Grade sync failed: connection time out: connect consult IDE log for more details". Pls I don't know what to do.
回答1:
Caused by: java.util.zip.ZipException: error in opening zip file This mean that a file that Gradle has downloaded has become corrupted due to somehow or some reason. This might be the download of Gradle itself (which the wrapper does) or any dependency that Gradle has downloaded to run your build.
Gradle doesn't attempt to detect or resolve the problem, so you need to fix it manually. The solution is often to purge Gradle's download caches and let it get fresh copies of what it needs.
To do that, delete the .gradle directories in both your home directory and in your project's root directory and try building again.
In window home directory of gradle is
C:\Users\User.gradle In Mac OSX home directory
/Users/User_name/.gradle
回答2:
If you still haven't figured out this problem yet, it's because you literally have no internet connection which is mandatory for gradle building since the platform checks for potential updates for say, sdk versions, from a server.
However, if you want to build and do your work offline, then go to File -> Settings -> Build, Execution, Deployment -> Gradle -> Check Offline work under Global Gradle settings
回答3:
With reference to @DaveNOTDavid's answer, i tried this: Go to File->Settings->Build,Execution,Deployment->Gradle-> and select "Use default gradle wrapper(recommended)". Then sync your project, everything will work fine. But you need an internet connection.
回答4:
I was facing the same issue while downloading the gradle zip from https://services.gradle.org/distributions/gradle-4.1-all.zip. My issue related to proxy settings, I disabled the proxy & click on Try Again button in build.gradle file.
回答5:
Click on the SDK Manager and click SDK Tools and check if NDK and CMAKE are checked or not. If they are not checked download and install them. And if the problem persists just try it with a stable internet connection with a fast or a moderate speed. It had happened with me also when I was doing it with mobile phone internet then I tried it with a broadband with fast internet.
回答6:
In my case i activated antivirus it blocks the downloading gradle files turn of your firewall settings
回答7:
connection timed out: solution: Just disable your anti-virus for an hour and restart the android studios, in my case my antivirus blocked the connection. while restarting the android studios firewall will ask you the permission, allow it and its all done. The gradle will build successfully
回答8:
These situations generally occur due to the problem in downloading Gradle components, to overcome this, check your internet proxy and connection properly.
来源:https://stackoverflow.com/questions/43414426/gradle-sync-failed-connection-time-out-consult-ide-log-for-more-details