我安装了最新版本的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。将证书添加到 keystore -
从 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
关于java - 如何解决 Gradle 构建中的存储库证书错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47323909/