Android Studio配置中“Gradle sync failed: SSL peer shut down incorrectly”或者“Read timed out”解决办法

  • 原因
    gradle同步过程中网络问题容易导致中断,挂了梯子也可能出现问题
  • 解决
    使用阿里云镜像


    工程目录.png

    修改build.gradle文件成如下:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        //google()
        //jcenter()
        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 {
        //google()
        //jcenter()
        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
}

参考来源:
Gradle sync failed: Read timed out

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。