AndroidStudio構(gòu)建項(xiàng)目異常:PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderE...

在給Android Studio 配置代理后,發(fā)現(xiàn)無法構(gòu)建項(xiàng)目了,后來去掉代理也不行,一直報(bào)錯(cuò):

Error:A problem occurred configuring root project 'xxx'.
Could not resolve all dependencies for configuration ':classpath'.
Could not resolve com.tencent.bugly:symtabfileuploader:latest.release.
Required by:
project :
> Could not resolve com.tencent.bugly:symtabfileuploader:latest.release.
> Failed to list versions for com.tencent.bugly:symtabfileuploader.
> Unable to load Maven meta-data from https://jcenter.bintray.com/com/tencent/bugly/symtabfileuploader/maven-metadata.xml.
> Could not GET 'https://jcenter.bintray.com/com/tencent/bugly/symtabfileuploader/maven-metadata.xml'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
> Could not resolve com.tencent.bugly:symtabfileuploader:latest.release.
> Failed to list versions for com.tencent.bugly:symtabfileuploader.
> Unable to load Maven meta-data from https://dl.bintray.com/thelasterstar/maven/com/tencent/bugly/symtabfileuploader/maven-metadata.xml.
> Could not GET 'https://dl.bintray.com/thelasterstar/maven/com/tencent/bugly/symtabfileuploader/maven-metadata.xml'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

解決方案:

方案1: 去掉代理,去掉掉項(xiàng)目中的gradle.properties代理配置

#systemProp.https.proxyPort=8087
#systemProp.http.proxyHost=127.0.0.1
org.gradle.jvmargs=-Xmx4096M
org.gradle.daemon=true
android.useDeprecatedNdk=true

方案2: 如果必須使用代理,則將代理的證書文件添加到j(luò)re中
  1. 可以通過瀏覽器去對(duì)應(yīng)的網(wǎng)站下載對(duì)應(yīng)的證書,如果使用的XX-Net則可以直接使用xxnet文件目錄下**data/gae_proxy/CA.crt **證書文件

  2. 找到j(luò)re中的security文件目錄,在Mac系統(tǒng)中,Android Studio包里會(huì)自帶jre環(huán)境,所以應(yīng)該使用Android Studio中的jre目錄,找到后打開終端,使用cd 命令進(jìn)入security文件目錄下

    cd /Applications/Android\ Studio2.2.app/Contents/jre/jdk/Contents/Home/jre/lib/security
    
  3. 進(jìn)入security目錄后,使用keytool命令導(dǎo)入證書

    keytool -import -alias abc -keystore cacerts -file /Applications/XX-Net-3.13.1/data/gae_proxy/CA.crt
    

-alias 指定別名(證書同名即可)

-keystore 指定存儲(chǔ)文件

注意: cacerts 是因?yàn)楫?dāng)前目錄就是cacerts文件所在的目錄,才可指定 -keystore cacerts, 否則應(yīng)該指定全路徑;

-file 指定證書文件全路徑(證書文件所在的目錄)
注意: 此時(shí)命令行會(huì)提示你輸入cacerts證書庫的密碼,敲入changeit即可,這是java中cacerts證書庫的默認(rèn)密碼,當(dāng)然也可自行修改。

庫密鑰口令輸入:changeit

是否信任:Y

證書導(dǎo)入成!

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容