My Android Studio was working fine till morning, but since tonight I get error saying \"Gradle sync failed: Connection timed out: connect. If you are behind an HTTP proxy, p
Clear proxy setting at gradle.properties (Global properties)
What worked for me was removing the port settings from the Gradle.properties file. I wasn't using any proxy and that resulted in the mismatch. I commented out the following lines
systemProp.https.proxyPort=your_port
systemProp.http.proxyHost=your_proxy
If your Proxy settings is set to No Proxy
[Based on how i solved this issue in my case] check out gradle.properties (Global properties)
and clear proxy lines.
#systemProp.https.proxyPort=port
#systemProp.http.proxyHost=proxy
org.gradle.jvmargs=-Xmx2048m -XX\:MaxPermSize\=512m -XX\:+HeapDumpOnOutOfMemoryError -Dfile.encoding\=UTF-8 -Djava.net.preferIPv4Stack\=true
org.gradle.daemon=true
#systemProp.https.proxyHost=proxy
org.gradle.configureondemand=false
#systemProp.http.proxyPort=port
android.enableBuildCache=true
For me it was the firewall. Definitely, only that. After adding Android Studio to it's whitelist everything is working like a charm.
I copied a project that was created else where. After removing these proxy credentials:
systemProp.http.proxyPassword=your_password
systemProp.http.proxyHost=host_Ip_address
systemProp.http.proxyUser=your_username
systemProp.http.proxyPort=port_number
in the gradle.properties, it worked like a charm.
If proxy settings are correct then go to file and click on "Invalidate Caches/Restart..." to invalidate the cache and restart android studio.