Android Studio 编译时出现如下问题 SSL peer shut down incorrectly 或者某些jar包下载不下来,一般是因为墙的原因导致的。
这时候我们就需要配置镜像来解决这个问题。
遇到这个问题,先备份工作项目,新建无关紧要的项目。
1、用阿里的远程仓库,如下
(为了提高jar包的下载速度也可以配置)配置的方法就是在根build.gradle中添加镜像仓库,
一般我们选择阿里的 http://maven.aliyun.com/nexus/content/groups/public/完整的如下所示
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { google() maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.4.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } jcenter() } } task clean(type: Delete) { delete rootProject.buildDir }这里需要注意要将jcenter放到最后一个,因为他就是那个下载慢,或者报错的终极原因。
在项目的build.gradle中 repositories 和 allprojects添加 ... mavenCentral() maven { url 'https://maven.google.com' } ...
并将jcenter()放到这两个的下面
2、换用本地已下载好的gradle
http://services.gradle.org/distributions/
复制到浏览浏览器能打开下一步 打开Android studiogradle version 配置文件进行更改将选中内容 替换成 http://services.gradle.org/distributions/
3、换成本地已有的gradle版本
构建项目出现 SSL peer shut down incorrectly,File——> Setting——>搜索Gradle,使用Use Local gradle distribution Gradle Home 从Android Studio安装的根目录中(D:\Software\Java\android\Android Studio\gradle)寻找。从其他电脑拷贝当前版本的gradle,将build.gradle的classpath更新成你AS相对应的版本。同时建议更新需谨慎,了解更新了什么之后掌握工具等相对稳定再更新工具。
以上第一种方法是亲测有效的(新建无关项目),但是在搜索中 还发现其他方法,再做补充。
参考 文章:
https.protocols的检测与设置
书到用时方恨少,纸上得来终觉浅。欢迎指正,有什么更好的解决办法欢迎留言。共勉
