3

I start a new project on android studio 3.1.2, but it sync failed. The error message is "read time out". I've tried multiple variations of this, but none of them seem to work. It seems that android studio is unable to download the project dependencies from the remote repository. I have tried several methods including setting a http proxy, adding other repositories in the build.gradle file. Here is some message.

click to view log message

click to view build message

click to view build.gradle file

Thanks in advance!

YPO
  • 31
  • 1
  • 5
  • https://stackoverflow.com/questions/32171524/how-to-configure-gradle-to-work-offline-using-cached-dependencies/32173577#32173577 Please follow this link. – Hitesh Manwani May 01 '18 at 08:47
  • https://stackoverflow.com/questions/32171524/how-to-configure-gradle-to-work-offline-using-cached-dependencies/32173577#32173577 please follow this link. – Hitesh Manwani May 01 '18 at 08:49
  • I try the way but it doesn't work for me. The error message is like "Unable to resolve dependency for ':app@debug/compileClasspath' Could not resolve xxx " . – YPO May 01 '18 at 10:10
  • 1
    I also faced the same problem. have you solved it ? – BinqiangSun May 25 '18 at 03:13

3 Answers3

2

i have faced the same issue, try this order it fixes the issue.

repositories {
    jcenter()
    mavenCentral()
    maven { url 'https://maven.google.com' }
    google()
}
Bebooo43
  • 21
  • 2
  • I have tried this before, however it didn't help. And I can find the dependencies needed in some directory. It's strange android studio doesn't detect these files but keeps downloading from internet. – YPO May 01 '18 at 13:36
0

When you build project for first time, gradle sync takes time also check the internet connectivity before starting gradle sync. From the attached screenshot, sockettimeoutexception appears due to internet connectivity failure or slow connection.

BNG Dev
  • 21
  • 1
  • 2
  • I check my internet connectivity and I think it works fine. Are there other reasons for the problem ? – YPO May 01 '18 at 10:00
0

The problem is related to the .gradle\caches, so if you can return to the last content of your caches folder, I did that and the problem disappeared. OR File-> Invalidate Caches/Restart...