一、Error:Cause: unable to find valid certification path to requested target
主要是在根目錄的build.gradle下配置的jcenter的地址:
buildscript {
repositories {
google()
jcenter{
url 'http://jcenter.bintray.com'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
}
}
allprojects {
repositories {
google()
jcenter{
url 'http://jcenter.bintray.com'
}
}
}
Android studio3.1在連接'http://jcenter.bintray.com'時沒有證書,報錯:Error:Cause: unable to find valid certification path to requested target,一般的操作方法是在jdk里面添加證書,如下:
https://blog.csdn.net/frankcheng5143/article/details/52164939
注意,是在Android Studio使用的jdk的目錄下,可以通過 File->Other Settings->Default Project Structure來查看。
在Android Studio3.1版本中,已經將cacerts集成在用戶的配置目錄下,比如我的:C:\Users\feng\.AndroidStudio3.1\system\tasks下,可以按照上述方法進行cacerts添加。
還有一個討巧的方法,出現Error:Cause: unable to find valid certification path to requested target的錯誤時,一般會給出一個網址,比如我的:http://jcenter.bintray.com/com/sun/activation/javax.activation/1.2.0/javax.activation-1.2.0.pom,表示下載這個組件時超時。先去瀏覽器中看一下,這個URL是否確實可以訪問到。再到Android Studio3.1的setting中搜索"Http",打開Http配置,下面有一個Check connection,點擊它,將報錯的網址輸進去測試鏈接。如果連接成功,AS會跳出權限添加,這樣就不用主動添加權限了。刷新,重編譯。
