8

我安装了 Android Studio 4.1。我收到“构建失败”错误。

PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效证书路径

我曾尝试更改 Gradle 版本和 Gradle Plugin 版本,以及 Java(8 和 11),但它不起作用。

由于限制为 30000 个字符,所以我将其完全发布在 google doc 中。 谷歌文档中的完整错误

详细的错误是:

A problem occurred configuring root project 'First'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not resolve com.google.flatbuffers:flatbuffers-java:1.12.0.
     Required by:
         project : > com.android.tools.build:gradle:4.2.0-alpha14
      > Could not resolve com.google.flatbuffers:flatbuffers-java:1.12.0.
         > Could not get resource 'https://jcenter.bintray.com/com/google/flatbuffers/flatbuffers-java/1.12.0/flatbuffers-java-1.12.0.pom'.
            > Could not GET 'https://jcenter.bintray.com/com/google/flatbuffers/flatbuffers-java/1.12.0/flatbuffers-java-1.12.0.pom'.
               > PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
   > Could not resolve org.tensorflow:tensorflow-lite-metadata:0.1.0-rc2.
     Required by:
         project : > com.android.tools.build:gradle:4.2.0-alpha14
      > Could not resolve org.tensorflow:tensorflow-lite-metadata:0.1.0-rc2.
         > Could not get resource 'https://jcenter.bintray.com/org/tensorflow/tensorflow-lite-metadata/0.1.0-rc2/tensorflow-lite-metadata-0.1.0-rc2.pom'.
            > Could not GET 'https://jcenter.bintray.com/org/tensorflow/tensorflow-lite-metadata/0.1.0-rc2/tensorflow-lite-metadata-0.1.0-rc2.pom'.
               > PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
   > Could not resolve org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.10.
     Required by:
         project : > com.android.tools.build:gradle:4.2.0-alpha14
         project : > com.android.tools.build:gradle:4.2.0-alpha14 > com.android.tools.build:builder:4.2.0-alpha14
         project : > com.android.tools.build:gradle:4.2.0-alpha14 > com.android.tools.build:aaptcompiler:4.2.0-alpha14
         project : > com.android.tools.build:gradle:4.2.0-alpha14 > com.android.tools.lint:lint-gradle-api:27.2.0-alpha14
         project : > com.android.tools.build:gradle:4.2.0-alpha14 > com.android.tools.build:gradle-api:4.2.0-alpha14
         project : > com.android.tools.build:gradle:4.2.0-alpha14 > androidx.databinding:databinding-compiler-common:4.2.0-alpha14
         project : > com.android.tools.build:gradle:4.2.0-alpha14 > com.android.tools.build:builder:4.2.0-alpha14 > com.android.tools.build:builder-model:4.2.0-alpha14
         project : > com.android.tools.build:gradle:4.2.0-alpha14 > com.android.tools.build:builder:4.2.0-alpha14 > com.android.tools:sdk-common:27.2.0-alpha14
         project : > com.android.tools.build:gradle:4.2.0-alpha14 > com.android.tools.build:builder:4.2.0-alpha14 > com.android.tools:common:27.2.0-alpha14
         project : > com.android.tools.build:gradle:4.2.0-alpha14 > com.android.tools.build:builder:4.2.0-alpha14 > com.android.tools.build:manifest-merger:27.2.0-alpha14
         project : > com.android.tools.build:gradle:4.2.0-alpha14 > com.android.tools.build:builder:4.2.0-alpha14 > com.android.tools.analytics-library:tracker:27.2.0-alpha14
         project : > com.android.tools.build:gradle:4.2.0-alpha14 > com.android.tools.lint:lint-gradle-api:27.2.0-alpha14 > com.android.tools.lint:lint-model:27.2.0-alpha14
         project : > com.android.tools.build:gradle:4.2.0-alpha14 > com.android.tools.build:builder:4.2.0-alpha14 > com.android.tools:sdklib:27.2.0-alpha14 > com.android.tools:repository:27.2.0-alpha14
         project : > com.android.tools.build:gradle:4.2.0-alpha14 > com.android.tools.build:builder:4.2.0-alpha14 > com.android.tools:sdk-common:27.2.0-alpha14 > com.android.tools.analytics-library:shared:27.2.0-alpha14
      > Could not resolve org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.10.
         > Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.4.10/kotlin-stdlib-jdk8-1.4.10.pom'.
            > Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.4.10/kotlin-stdlib-jdk8-1.4.10.pom'.
               > PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

4

3 回答 3

16

就我而言,当我将 Android Studio 升级到 4.2 并在 build.gradle 中注释 jcenter maven 存储库时出现此错误,在取消注释存储库后得到解决。

例子:

repositories {
    google()
    mavenCentral()
    //jcenter()
    /*maven {
        url "https://maven.google.com"
    }*/
}
于 2021-05-06T14:40:37.363 回答
6

就我而言,我添加了 mavenCentral() 并在 build.gradle 中添加了如下注释“maven { ...”。

buildscript {
repositories {
    google()
    mavenCentral()
    /*maven {
        url "https://maven.google.com"
    }*/
    //jcenter()
}

...

于 2021-06-07T05:59:32.473 回答
0

如果你有同样的问题,它的问题来自 windows 10,那么唯一的解决方案是在 windows 10 firewal 的控制面板中更改网络配置,而不是让你访问这个下载的 gradle 文件或让连接到 wifi。以及win+r >> servics>dns restart 和restart pc

于 2021-06-23T06:13:29.010 回答