在给Android Studio 配置代理后,发现无法构建项目了,后来去掉代理也不行,一直报错:
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: 去掉代理,去掉掉项目中的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: 如果必须使用代理,则将代理的证书文件添加到jre中
可以通过浏览器去对应的网站下载对应的证书,如果使用的XX-Net则可以直接使用xxnet文件目录下**data/gae_proxy/CA.crt **证书文件
-
找到jre中的security文件目录,在Mac系统中,Android Studio包里会自带jre环境,所以应该使用Android Studio中的jre目录,找到后打开终端,使用cd 命令进入security文件目录下
cd /Applications/Android\ Studio2.2.app/Contents/jre/jdk/Contents/Home/jre/lib/security
-
进入security目录后,使用keytool命令导入证书
keytool -import -alias abc -keystore cacerts -file /Applications/XX-Net-3.13.1/data/gae_proxy/CA.crt
-alias 指定别名(证书同名即可)
-keystore 指定存储文件
注意: cacerts 是因为当前目录就是cacerts文件所在的目录,才可指定 -keystore cacerts, 否则应该指定全路径;
-file 指定证书文件全路径(证书文件所在的目录)
注意: 此时命令行会提示你输入cacerts证书库的密码,敲入changeit即可,这是java中cacerts证书库的默认密码,当然也可自行修改。库密钥口令输入:changeit
是否信任:Y
证书导入成!