Android studio3.5.2搭建第一個程序時出現(xiàn):
ERROR: Cause: unable to find valid certification path to requested target
解決方案:
第一步 換鏡像
這里用到的是阿里鏡像
(!?。〔皇亲罱K版本 ,build.gradle配置用第四步的)
// google()
// jcenter()
maven { url 'https://maven.aliyun.com/repository/google' }
maven{ url 'https://maven.aliyun.com/repository/jcenter'}
第二步 配置證書
-
https://blog.csdn.net/qq_17827627/article/details/99404177
此方法最方便
注意:上方“Accept non-trusted ceritificates automatically”(自動接受不受信任的證書)要勾選
證書配置后效果 - 該博客提供另一種配置證書方法
https://blog.csdn.net/frankcheng5143/article/details/52164939
第三步
出現(xiàn)新error
ERROR: SSL peer shut down incorrectly
更改gradle-wrapper.properties中的https為http解決問題
第四步
到這里sync project成功 run的時候再次出現(xiàn)和第一步一樣的error
ERROR: Cause: unable to find valid certification path to requested target
將build.gradle配置改為如下代碼解決:
buildscript {
repositories {
maven { url'https://maven.aliyun.com/repository/google/' }
maven { url'https://maven.aliyun.com/repository/jcenter/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
// 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/google/' }
maven { url'https://maven.aliyun.com/repository/jcenter/' }
mavenLocal()
mavenCentral()
}
}
第四步的問題baidu google找了一天,嘗試了各種方法無果。最后查找阿里云鏡像的官方文檔,直接解決。算是一個教訓(xùn)吧。
