如何解决 Gradle 构建中的存储库证书错误

2024-02-12

我安装了最新版本的android studio。我已经安装了jdk 8。当我打开 android studio 时,出现以下错误。

Unable to resolve dependency for ':app@debugUnitTest/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  

所以我删除了JDK 8并安装了JDK 9,添加了环境变量(在Windows 10中)。然后我重新启动系统并启动 android studio,仍然出现上述错误。我什至添加了

repositories {
    maven { url "https://maven.google.com" }
}  

到 gradle 脚本。但我仍然遇到同样的错误。我该如何修复这个错误?


以下步骤可能会有所帮助:

1.将证书添加到密钥库-

从 Android Studio 的 cacerts 导入一些认证到 Android Studio JDK cacerts。

Android Studio 的 cacerts 可能位于

{your-home-directory}/.AndroidStudio3.0/system/tasks/cacerts

我使用了以下导入命令。

$ keytool -importkeystore -v -srckeystore {src cacerts} -destkeystore {dest cacerts}

2.将修改后的cacert路径添加到gradle.properties-

systemProp.javax.net.ssl.trustStore={your-android-studio-directory}\\jre\\jre\\lib\\security\\cacerts
systemProp.javax.net.ssl.trustStorePassword=changeit

Ref : https://www.cresco.co.jp/blog/entry/2014/ https://www.cresco.co.jp/blog/entry/2014//

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何解决 Gradle 构建中的存储库证书错误 的相关文章

随机推荐