今天在新项目新引入了path_provider,就一直报错,内容如下:
* What went wrong:
A problem occurred configuring project ':path_provider'.
> Could not resolve all artifacts for configuration ':path_provider:classpath'.
> Could not download guava.jar (com.google.guava:guava:26.0-jre)
> Could not get resource 'https://jcenter.bintray.com/com/google/guava/guava/26.0-jre/guava-26.0-jre.jar'.
> Could not GET 'https://jcenter.bintray.com/com/google/guava/guava/26.0-jre/guava-26.0-jre.jar'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid
certification path to requested target
> Could not download kotlin-reflect.jar (org.jetbrains.kotlin:kotlin-reflect:1.3.11)
> Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-reflect/1.3.11/kotlin-reflect-1.3.11.jar'.
> Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-reflect/1.3.11/kotlin-reflect-1.3.11.jar'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid
certification path to requested target
看内容应该是引入新包的时候gradle没有更新下来新的依赖,或者是依赖冲突。网上找了一些方法,有说更改环境变量的,有说改yaml代码,删除一些包的。试了都不好用,然后无意中看到了这个方法:
cd android
gradle initial // 多运行几次
这个应该是更新gradle依赖的,运行时候提示我,gradle中一些资源已经init, 应该使用gradle init 运行了两次,再次运行项目,顺利✌️