java Android Studio 3.0.1 gradle build pkix 路径构建失败

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47678240/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 09:44:33  来源:igfitidea点击:

Android Studio 3.0.1 gradle build pkix pathbuilding failed

javaandroid

提问by ninjaxelite

I have created a new project in android studio 3.0.1 setup the proxy settings of company and added the self sighned certificate unser server sertificates. When I try to build the following error is listed and the build fails.

我在 android studio 3.0.1 中创建了一个新项目,设置了公司的代理设置,并添加了自签名证书 unser 服务器证书。当我尝试构建时,会列出以下错误并且构建失败。

Error:

错误:

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0.

Could not resolve com.android.support:appcompat-v7:26.1.0.
Required by:
    project :app
 > Could not resolve com.android.support:appcompat-v7:26.1.0.
    > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.pom'.
          > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.pom'.
                   > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
                               > PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
                                              > unable to find valid certification path to requested target

Could somebody help me?

有人可以帮助我吗?

回答by ninjaxelite

Solved this by adding the self signed certificate of my company to the cacerts file of Android Studio. The cacerts file is located here: C:\Program Files\Android\Android Studio\jre\jre\lib\security\cacerts

通过将我公司的自签名证书添加到Android Studio的cacerts文件中解决了这个问题。cacerts 文件位于此处:C:\Program Files\Android\Android Studio\jre\jre\lib\security\cacerts

I have also added the proxy details for http/https to gradle.properties.

我还将 http/https 的代理详细信息添加到 gradle.properties。

回答by Naresh Palle

Yeah, I have resolved the issue by changing the WiFi network connection. do any of the following step 1. connect to other or Mobile network(use hotspot) and reconnect to WiFi network 2. Reset your wifi network in laptop

是的,我已经通过更改 WiFi 网络连接解决了这个问题。执行以下任一步骤 1. 连接到其他或移动网络(使用热点)并重新连接到 WiFi 网络 2. 在笔记本电脑中重置您的 wifi 网络

回答by Vitalii Obideiko

lol, I have fixed this issue just by opening second link from error info https://dl.google.com/dl/android/maven2/com/android...in the Google Chrome. Then it has worked just like always ˉ\ _ (ツ)_/ˉ

大声笑,我只是通过在谷歌浏览器中打开错误信息https://dl.google.com/dl/android/maven2/com/android...中的第二个链接来解决这个问题。然后它就像往常一样工作ˉ\ _ (ツ)_/ˉ

回答by D. C. Christopher

Sometimes it helps to just upgrade to the latest gradle wrapper (gradle-wrapper.properties) and gradle plugin (main build.gradle -> buildscript -> dependencies -> com.android.tools.build:gradle). This is especially true if you're loading multiple projects and you've updated one of them. I did that and suddenly my "other" projects wouldn't sync/build. Updating them as well resolved that issue.

有时只需升级到最新的 gradle 包装器(gradle-wrapper.properties)和 gradle 插件(主 build.gradle -> buildscript -> 依赖项 -> com.android.tools.build:gradle)会有所帮助。如果您正在加载多个项目并且更新了其中一个项目,则尤其如此。我这样做了,突然间我的“其他”项目无法同步/构建。更新它们也解决了这个问题。

It bears noting that our company does have a very locked down network with tons of traffic sniffing and cert rewriting so that's likely the initial cause of the issue. Even with adding the self-signed certs into Android Studio's "approved" certificate list, I was still having issues until I did the above. Previously, I've even seen a difference between building in the terminal (./gradlew assembleDebug, which worked more often) and building in Android studio (which worked less often).

值得注意的是,我们公司确实有一个非常锁定的网络,其中包含大量流量嗅探和证书重写,因此这可能是问题的最初原因。即使将自签名证书添加到 Android Studio 的“已批准”证书列表中,在执行上述操作之前我仍然遇到问题。以前,我什至看到在终端中构建(./gradlew assembleDebug,工作更频繁)和在 Android Studio 中构建(工作较少)之间的区别。