SSL peer shut down incorrectly
报两个错误:
1、SSL peer shut down incorrectly
2、remote hosts closed connection during handshake
A problem occurred configuring root project 'i9bao_android'.
> Could not resolve all files for configuration ':classpath'.
> Could not download protobuf-java-util-3.10.0.jar (com.google.protobuf:protobuf-java-util:3.10.0)
> Could not get resource 'https://jcenter.bintray.com/com/google/protobuf/protobuf-java-util/3.10.0/protobuf-java-util-3.10.0.jar'.
> Could not GET 'https://jcenter.bintray.com/com/google/protobuf/protobuf-java-util/3.10.0/protobuf-java-util-3.10.0.jar'.
> The server may not support the client's requested TLS protocol versions: (TLSv1.2). You may need to configure the client to allow other protocols to be used. For more on this, please refer to https://docs.gradle.org/8.4/userguide/build_environment.html#sec:gradle_system_properties in the Gradle documentation.
> Remote host closed connection during handshake
AndroidStudio 编译时出现如下问题 SSL peer shut down incorrectly ,或者某些jar包下载不下来,一般是因为墙的原因导致的。这时候我们就需要配置镜像来解决这个问题。(为了提高jar包的下载速度也可以配置)配置的方法就是在根build.gradle中添加镜像仓库,一般我们选择阿里的 http://maven.aliyun.com/nexus/content/groups/public/ 完整的如下所示
buildscript {
repositories {
google()
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
allprojects {
repositories {
google()
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
一定要注意将jcenter放到最后一个,因为这就是导致下载慢,或报错的罪魁祸首!
附:build.gradle内容详解
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {//这里是gradle脚本执行所需依赖,分别是对应的maven库和插件
repositories {
google()//从Android Studio3.0后新增了google()配置,可以引用google上的开源项目
jcenter()//是一个类似于github的代码托管仓库,声明了jcenter()配置,可以轻松引用 jcenter上的开源项目
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'此处是android的插件gradle,gradle是一个强大的项目构建工具
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {//这里是项目本身需要的依赖,比如项目所需的maven库
repositories {
google()
jcenter()
}
}
// 运行gradle clean时,执行此处定义的task任务。
// 该任务继承自Delete,删除根目录中的build目录。
// 相当于执行Delete.delete(rootProject.buildDir)。
// gradle使用groovy语言,调用method时可以不用加()。
task clean(type: Delete) {
delete rootProject.buildDir
}
————————————————
原文链接:https://blog.csdn.net/irizhao/article/details/104250897