Gradle sync failed “read time out“
程序员文章站
2022-03-12 09:17:57
在使用Android Studio进行开发时,经常会碰到以下问题:在Gradle进行Project Sync时由于需要从国外网站下载jar包文件,当下载发生中断时就会导致Sync失败。解决方法之一是使用国内阿里云镜像,具体步骤如下:修改build.gradle文件:// Top-level build file where you can add configuration options common to all sub-projects/modules.buildscript { r...
在使用Android Studio进行开发时,经常会碰到以下问题:在Gradle进行Project Sync时由于需要从国外网站下载jar包文件,当下载发生中断时就会导致Sync失败。解决方法之一是使用国内阿里云镜像,具体步骤如下:
- 修改build.gradle文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
为
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven { url 'https://maven.aliyun.com/repository/public/' }
maven { url 'https://maven.aliyun.com/repository/google/'}
maven { url 'https://maven.aliyun.com/repository/jcenter/'}
mavenLocal()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url 'https://maven.aliyun.com/repository/public/' }
maven { url 'https://maven.aliyun.com/repository/google/'}
maven { url 'https://maven.aliyun.com/repository/jcenter/'}
mavenLocal()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
-
重新Sync工程
-
此外还可以通过修改文件gradle.properties中org.gradle.jvmargs来调整容许网络延时来提高Sync成功率
org.gradle.jvmargs=-Xmx1536m -Dorg.gradle.internal.http.connectionTimeout=120000 -Dorg.gradle.internal.http.socketTimeout=120000
- Gradle配置指南参考阿里云网站。1
-
https://help.aliyun.com/document_detail/102512.html?spm=a2c40.aliyun_maven_repo.0.0.36183054TojOuO ↩︎
本文地址:https://blog.csdn.net/eaglecoder/article/details/107142429
推荐阅读
-
Gradle sync failed “read time out“
-
Android Studio遇到Failed to sync Gradle project错误时的解决办法
-
详解PHP内置访问资源的超时时间 time_out file_get_contents read_file
-
【error】Gradle sync failed: Unable to start the daemon process.【已解决】
-
AndroidStudio 导入项目 出现“gradle project sync failed:”的错误
-
android studio 编译项目报错Gradle sync failed: Illegal char <:> at index 37:
-
hessian 500 read time out问题
-
hessian 500 read time out问题
-
Sync with Gradle for project ‘XXXX‘ failed: Connection timed out: connect
-
Gradle 'xxx' project refresh failed Error:Connection timed out: connect