unable to find valid certification path to requested target

unable to find valid certification path to requested target

前两天Android studio突然抽风,在build显示时一直下载不了google上的依赖库,同事的没问题。。
下面是具体错误log

    Caused by: org.gradle.api.resources.ResourceException: Unable to load Maven meta-data from https://dl.google.com/dl/android/maven2/com/mob/sdk/MobSDK/maven-metadata.xml.
	at org.gradle.api.internal.artifacts.repositories.resolver.MavenMetadataLoader.load(MavenMetadataLoader.java:57)
	at org.gradle.api.internal.artifacts.repositories.resolver.MavenVersionLister$1.visit(MavenVersionLister.java:48)
	at org.gradle.api.internal.artifacts.repositories.resolver.ChainedVersionLister$1.visit(ChainedVersionLister.java:47)
	... 137 more
Caused by: org.gradle.api.resources.ResourceException: Could not get resource 'https://dl.google.com/dl/android/maven2/com/mob/sdk/MobSDK/maven-metadata.xml'.
	at org.gradle.internal.resource.ResourceExceptions.failure(ResourceExceptions.java:74)
	at org.gradle.internal.resource.ResourceExceptions.getFailed(ResourceExceptions.java:57)
	at org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor.copyToCache(DefaultCacheAwareExternalResourceAccessor.java:198)
	at org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor.access$300(DefaultCacheAwareExternalResourceAccessor.java:55)
	at org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor$1.create(DefaultCacheAwareExternalResourceAccessor.java:88)
	at org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor$1.create(DefaultCacheAwareExternalResourceAccessor.java:80)
	at org.gradle.cache.internal.ProducerGuard$AdaptiveProducerGuard.guardByKey(ProducerGuard.java:97)
	at org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor.getResource(DefaultCacheAwareExternalResourceAccessor.java:80)
	at org.gradle.api.internal.artifacts.repositories.resolver.MavenMetadataLoader.parseMavenMetadataInfo(MavenMetadataLoader.java:63)
	at org.gradle.api.internal.artifacts.repositories.resolver.MavenMetadataLoader.load(MavenMetadataLoader.java:53)
	... 139 more
Caused by: org.gradle.internal.resource.transport.http.HttpRequestException: Could not GET 'https://dl.google.com/dl/android/maven2/com/mob/sdk/MobSDK/maven-metadata.xml'.
	at org.gradle.internal.resource.transport.http.HttpClientHelper.performRequest(HttpClientHelper.java:97)
	at org.gradle.internal.resource.transport.http.HttpClientHelper.performRawGet(HttpClientHelper.java:81)
	at org.gradle.internal.resource.transport.http.HttpClientHelper.performGet(HttpClientHelper.java:85)
	at org.gradle.internal.resource.transport.http.HttpResourceAccessor.openResource(HttpResourceAccessor.java:43)
	at org.gradle.internal.resource.transport.http.HttpResourceAccessor.openResource(HttpResourceAccessor.java:29)
	at org.gradle.internal.resource.transfer.DefaultExternalResourceConnector.openResource(DefaultExternalResourceConnector.java:56)
	at org.gradle.internal.resource.transfer.ProgressLoggingExternalResourceAccessor.openResource(ProgressLoggingExternalResourceAccessor.java:36)
	at org.gradle.internal.resource.transfer.AccessorBackedExternalResource.withContentIfPresent(AccessorBackedExternalResource.java:130)
	at org.gradle.internal.resource.BuildOperationFiringExternalResourceDecorator$11.call(BuildOperationFiringExternalResourceDecorator.java:237)
	at org.gradle.internal.resource.BuildOperationFiringExternalResourceDecorator$11.call(BuildOperationFiringExternalResourceDecorator.java:229)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:350)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:340)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:117)
	at org.gradle.internal.resource.BuildOperationFiringExternalResourceDecorator.withContentIfPresent(BuildOperationFiringExternalResourceDecorator.java:229)
	at org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor.copyToCache(DefaultCacheAwareExternalResourceAccessor.java:196)
	... 146 more
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
	at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
	at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1959)
	at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)
	at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296)
	at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1514)
	at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)
	at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1026)
	at sun.security.ssl.Handshaker.process_record(Handshaker.java:961)
	at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1072)

重点是PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
###问题:从字面意思是确实证书,无法请求
然后百度了很多,都没法解决。这里提供一个可能解决的,别人的,但是没解决我的问题
操作方式,去添加证书,理论上是可行,但我发现证书是添不完的…
博客地址https://blog.csdn.net/gabriel576282253/article/details/81531746
困扰了一天左右,既然不能从谷歌上下载依赖库,看国内有没有地方可以下载依赖库。
搜下有几个高校都提供镜像库,但是高校的一般更新都很晚,比如外面都用Android 9.0了,高校的还是6.0的。
导致很多项目的库,它没有。
最终采用的是阿里云的镜像仓库
###先说个知识点,根目录的build的repositories里面的配置,是由上往下的仓库中去获取依赖库的
下面提供下解决我问题的build文件

buildscript {

repositories {
    maven{ url 'http://maven.aliyun.com/repository/public/'}
    maven{ url 'http://maven.aliyun.com/repository/google/'}
    maven{ url 'http://maven.aliyun.com/repository/gradle-plugin/'}
    
    //jcenter仓库
    jcenter{
    	url 'http://jcenter.bintray.com'
    }
    
    google()
    
    }
    dependencies {
    classpath 'com.android.tools.build:gradle:3.0.0'
    
    }
}

allprojects {
    repositories {
	    maven{ url 'http://maven.aliyun.com/repository/public/'}
	    maven{ url 'http://maven.aliyun.com/repository/google/'}
	    maven{ url 'http://maven.aliyun.com/repository/gradle-plugin/'}
	    
	    //jcenter仓库
	    jcenter{
	    	url 'http://jcenter.bintray.com'
	    }
	    
	    google()
		//我项目有接华为的东西,没有的可删除
	    maven { url 'http://developer.huawei.com/repo/' }
    
    }
}

如果问题还是没解决,请加我QQ:893151960,有空帮你看看

你可能感兴趣的:(unable to find valid certification path to requested target)