Android Studio配置中“Gradle sync failed: SSL peer shut down incorrectly”或者“Read timed out”解决办法
出现SSL peer shut down incorrectly或者Read timed out的问题
解决方法:使用阿里镜像或者gradle离线build
解决方式1:
打开工程目录下的build.gradle文件,不是app下的build.gradle
修改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
}
添加如下代码即可解决问题
maven { url 'https://maven.aliyun.com/repository/public/' }
maven { url 'https://maven.aliyun.com/repository/google/'}
maven { url 'https://maven.aliyun.com/repository/jcenter/'}
解决方式2:
将Android Studio的gradle的方式改成离线即可。
已经运行过的项目或者是将包放到相应的位置后,就可以用离线的方式。
参考: