在給Android Studio 配置代理后,發(fā)現(xiàn)無(wú)法構(gòu)建項(xiàng)目了凹嘲,后來(lái)去掉代理也不行师倔,一直報(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: 如果必須使用代理周蹭,則將代理的證書(shū)文件添加到j(luò)re中
可以通過(guò)瀏覽器去對(duì)應(yīng)的網(wǎng)站下載對(duì)應(yīng)的證書(shū)趋艘,如果使用的XX-Net則可以直接使用xxnet文件目錄下**data/gae_proxy/CA.crt **證書(shū)文件
-
找到j(luò)re中的security文件目錄,在Mac系統(tǒng)中,Android Studio包里會(huì)自帶jre環(huán)境凶朗,所以應(yīng)該使用Android Studio中的jre目錄瓷胧,找到后打開(kāi)終端,使用cd 命令進(jìn)入security文件目錄下
cd /Applications/Android\ Studio2.2.app/Contents/jre/jdk/Contents/Home/jre/lib/security
-
進(jìn)入security目錄后棚愤,使用keytool命令導(dǎo)入證書(shū)
keytool -import -alias abc -keystore cacerts -file /Applications/XX-Net-3.13.1/data/gae_proxy/CA.crt
-alias 指定別名(證書(shū)同名即可)
-keystore 指定存儲(chǔ)文件
注意: cacerts 是因?yàn)楫?dāng)前目錄就是cacerts文件所在的目錄搓萧,才可指定 -keystore cacerts, 否則應(yīng)該指定全路徑;
-file 指定證書(shū)文件全路徑(證書(shū)文件所在的目錄)
注意: 此時(shí)命令行會(huì)提示你輸入cacerts證書(shū)庫(kù)的密碼,敲入changeit即可,這是java中cacerts證書(shū)庫(kù)的默認(rèn)密碼,當(dāng)然也可自行修改杂数。庫(kù)密鑰口令輸入:changeit
是否信任:Y
證書(shū)導(dǎo)入成!