55

I have the latest Android Studio IDE installed on my Windows 10 laptop, and it was working fine until my windows operating system made a huge automatic update.

Now, when start my Android Studio IDE, I get the following error and it doesn't build.

Gradle sync failed: Read timed out Consult IDE log for more details (Help | Show Log) (3m 34s 195ms)

I need help on this.

26 Answers 26

48

I encounter this error "Read Time Out", and I simply choose menu item: File -> Invalidate Caches / Restart... to fixed it.

[UPDATE]

I just encounter this error for second time, this time Invalidate Caches / Restart... not able to fix it, but then I try close the android Studio, killall -9 java to ensure all java process has been terminated, then relaunch Android Studio, no more error.

[UPDATE 2] I just encounter this error and I fixed it by replug the phone cable and rerun.

Sign up to request clarification or add additional context in comments.

2 Comments

@samuelowino I think this error message causes by vary reasons, so no universal solution.
That's true, I had the same error about an hour ago, even without invalidating cache just a simple close and open fixed it. :)
31

I got around this issue by turning on Offline Mode in the Gradle tool window.

Turn on Offline Mode in Android Studio

2 Comments

Do you mean this is a gradle sync problem
Thank you, It means one or more links you are trying to access during build is offline or you have an internet problem.
17

I have just synced the Project with Gradle files and it worked

File -> Sync Project

2 Comments

Hey so it is a gradle sync issue?
2022 -still working
13

For Chinese users who often use a proxy to download dependency jars, the cause is often proxy settings.

We should check multiple places if the proxy is correctly configured.

  • Android Studio Settings - Appearance & Behavior - System Settings - HTTP Proxy
  • ${project_root}/gradle.properties
  • ~/.gradle/gradle.properties

In my case, I somehow once configured an HTTP proxy in ~/.gradle/gradle.properties, which was forgotten later. Then when I dealt with a SOCKS5 proxy in IDE Settings and project-level gradle.properties, things always run into trouble. Finally, deleting invalid proxy settings in ~/.gradle/gradle.properties save my day.

1 Comment

Well tbh every single country that's its people are dealing with internet restrictions.
12

Editing global gradle.properties with the following line was the fix for me:

org.gradle.jvmargs=-Dorg.gradle.internal.http.connectionTimeout=120000 -Dorg.gradle.internal.http.socketTimeout=120000

2 Comments

was searching this answer too long. Thanks. but can you please say what this value means? Xmx1536m
-Xmxn specifies the maximum size, in bytes, of the memory allocation pool. This value must a multiple of 1024 greater than 2 MB. More about it can be found here - docs.oracle.com/javase/7/docs/technotes/tools/solaris/java.html
10

I fixed the error by inserting following lines in gradle.properties:

systemProp.org.gradle.internal.http.connectionTimeout=180000
systemProp.org.gradle.internal.http.socketTimeout=180000

This sets the Gradle's connection timeout from the default 30s to 180s (3m).

In my case the read timeout occurred because my computer is behind a HTTP proxy, and it failed to timely connect to http://jcenter.bintray.com.

For more info about the Gradle options, you can refer to https://github.com/gradle/gradle/issues/3370

Comments

5

Simple Answer:

  1. Check the Internet Connection - it should not fluctuate while building the project
  2. File-->>Sync Project with Gradle File
  3. Build>> Clean Project Or Rebuild Project.

Comments

2

I just removed

include ':app'

from setting.gradle and then sync project

it will fails again

then write it back an re-sync and then error gone and will start downloading.

Comments

2

Here's what worked for me (on Windows):

From C:\Users\{$user}\.gradle Delete these 3 folders:

  • caches
  • daemon
  • wrapper

Then restart Android Studio and Gradle should start downloading automatically

2 Comments

Solved the problem for me on Mac as well, thanks!
After following hundreds of other solutions finally this one worked for me.
2

Above fixes didn't work for me on MacOS Big Sur 11.5.1 after updating to the new version of Arctic Fox 2020.3.1 Patch 3. My issue with this was resolved by doing the following:

  1. Close your Android project
  2. Navigate to the root folder of you project
  3. Remove the '.gradle' and '.idea' folders
  4. Start your Android project, which will start the build process. Let this finish
  5. Now the build should succeed. If not, also do an 'Invalidate caches/restart'

1 Comment

This worked for me, in MacOS 15.2 and Android Studio Ladybug | 2024.2.1 Patch 3 for a project created with the wizard jetbrains.com/help/kotlin-multiplatform-dev/…
2

In my case, Android Studio Arctic Fox | 2020.3.1 Patch 4 (Windows)

I have try 3 step/solution;

  1. Delete 2 root folder .gradle & .idea but still give 'Read timeout'
  2. Invalid Caches/Restart also resulted 'Read timeout'
  3. Close Android Studio, repeat solution 1, monitor 'Build Output' log, then choose 'Disable gradle offline..." , wait and let Android Studio do its thing, then on the log Build showed "BUILD SUCCESSFUL in 28s". Then, I try to run the app just to check and my apps still work as usual.

*Remark: This case happened might be because of my Android Studio IDE Version outdated. As for now, latest version is Android Studio Dolphin | 2021.3.1 Patch 1 .

Comments

1

None of the answer worked for me.

I solved it by

  1. Delete project>.gradle directory
  2. File>Sync Project with Gradle Files

Comments

1

In my case it was due to Jitpack.io server down, causing my project unable to build. So I just enabled the Offline Mode for gradle to continue developing my project while Jitpack.io is resolving their server issue.

Comments

1

You will see more info when you click "build" on top of the "read time out" message in build output. In my case, it was a facebook dependency issue so I just had to upgrade it to a newer version.

Comments

1

This error got due to the internet connection during gradles files connection interrupts.

I tried the following techniques but unfortunately, didn't get any solution.

  1. File->Invalidate Cache.
  2. File->Sync Project with .gradle files
  3. Delete Project .gradle and .idea files.

I got the solution to update gradle-wrapper.properties 6.8 to 7.1 after successfully sync revert back from 7.1 to 6.8

#distributionUrl=https://services.gradle.org/distributions/gradle-7.1-bin.zip distributionUrl=https://services.gradle.org/distributions/gradle-6.8-bin.zip

Comments

1

In my case it was work VPN issue. Turned it off and it start working.

Comments

0

In my case, it was a firewall issue. After adding Android Studio to its whitelist everything is working fine.

2 Comments

I just opened my windows firewall configuration, but when I start to locate android studio from program files directory I could not decide which file to choose, can you give me a hint?
Whitelist Android Studio by referring this buffered.com/tutorials/…
0

A simple Clean Project + Rebuild Project worked for me

Comments

0

I resumed working on my project after a long time and I was using an Old version of navigation dependency.

after updating version to versions.navigation = "2.3.0" from versions.navigation = "2.3.0-aplha01" my issue was resolved.

so in short make sure you are using latest version of gradle and all libraries (compatible with your gradle version).

Comments

0

In my case, this error was showing up while I am trying to create a new project, and the default Kotlin Gradle plugin API version was the culprit,

While building/Gradle sync I noticed that the sync process is always getting stuck at the downloading kotlin.gradle.plugin.api:1.5.21, So I searched for 1.5.21 in the build.gradle and updated it to the latest version, and it worked.

Comments

0

Just Simple Step and you Got Solution.

Android Studio -> FILE -> Invalid Caches / Restart -> Invalidate and Restart

Comments

0

Encountered this issues so many time, just make sure you have a good internet (Not a poor network) to be able to download gradle from android studio.

Comments

0

Here's how the problem happened for me in the UK (although this may affect people in many countries). I replaced my wireless router with a new one, and signed up to a new contract with my provider. In the UK all new router contracts have parental guidance turned on by default, which means a lot of web sites are blocked. For some reason that includes the sites from which the Android SDK and other components are downloaded.

The fix is to log on to your wireless broadband provider's user portal and turn parental guidance off, then restart the router.

Comments

0

Sometimes, it's maybe one of the 3rd-party repositories having a downtime. My project has some jitpack.io libraries, and jitpack was down so the project couldn't build.

Comments

0

I see multiple options, but in my case due to proxy I was facing this issue, most of company needs proxy, as per your org setup here:
File>>Settings>>Search for "HTTP Proxy"
enter image description here

Comments

-2

Use the following code in gradle.properties :

systemProp.http.proxyHost=www.somehost.org
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=userid
systemProp.http.proxyPassword=password
systemProp.http.nonProxyHosts=*.nonproxyrepos.com|localhost
org.gradle.daemon=false

2 Comments

please explain your answer
Delete the gradle.properties file codes and enter the above codes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.