Android Studio 3.0 中的 Gradle 构建错误 [英] Gradle build error in Android Studio 3.0
问题描述
你能帮我解决 Android 3.0 中的 Gradle 构建问题吗?
Can you please help me to resolve the Gradle build issue in Android 3.0 ?
我是 Android Studio 的新手.这是我在 AS 3.0 中的配置:
I am new with Android Studio. Here are my configurations in the AS 3.0:
gradle->wrapper->gradle-wrapper.properties:
gradle->wrapper->gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip
build.gradle 依赖项(Android 插件 Gradle):
build.gradle dependencies (Android Plugin for Gradle):
dependencies {classpath 'com.android.tools.build:gradle:3.0.0'}
设置">
来自 Android Studio 的 Stacktrace:
Stacktrace from Android Studio:
D:\AppiumAutomation\MobileTest>gradlew assemble --stacktrace
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'MobileTest'.
> Could not resolve all files for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:3.0.0.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:3.0.0.
> Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom'.
> Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification pat
h to requested target
> Could not resolve com.android.tools.build:gradle:3.0.0.
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom'.
> Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification pat
h to requested target
推荐答案
这是一个与 Android Studio 3.0 和企业网络相关的问题.我遇到了同样的问题.
It's a problem related to Android Studio 3.0 and the corporate networks. I had the same problem.
Error:Could not resolve all files for configuration ':app:debugAndroidTestRuntimeClasspath'.
> Could not resolve com.android.support.test:runner:1.0.1.
Required by:
project :app
> Could not resolve com.android.support.test:runner:1.0.1.
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/support/test/runner/1.0.1/runner-1.0.1.pom'.
> Could not GET 'https://dl.google.com/dl/android/maven2/com/android/support/test/runner/1.0.1/runner-1.0.1.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
> Could not resolve com.android.support.test.espresso:espresso-core:3.0.1.
Required by:
project :app
> Could not resolve com.android.support.test.espresso:espresso-core:3.0.1.
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/support/test/espresso/espresso-core/3.0.1/espresso-core-3.0.1.pom'.
> Could not GET 'https://dl.google.com/dl/android/maven2/com/android/support/test/espresso/espresso-core/3.0.1/espresso-core-3.0.1.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
我给你留下了两个解决方案:
I leave you 2 solutions:
第一个:您必须手动将证书添加到您的 Java 安全证书(由 Android 使用):
1rst: You must add certificates manually to your java security certs (used by Android):
C:\Program Files\Android\Android Studio\jre\jre\lib\security\cacerts
C:\Program Files\Android\Android Studio\jre\jre\lib\security\cacerts
前往:
C:\Program Files\Android\Android Studio\jre\jre\bin
下载您需要的证书(只需复制带有问题的 URL 并将其粘贴到 <remote_host_name>
):
Download the Certificate you need (just copy the URL with the problem and paste it into <remote_host_name>
):
keytool -J-Dhttps.proxyHost=<proxy_hostname> -J-Dhttps.proxyPort=<proxy_port> -printcert -rfc -sslserver <remote_host_name:remote_ssl_port> > <name.cer>
Example:
C:\Program Files\Android\Android Studio\jre\jre\bin>keytool -J-Dhttps.proxyHost= proxy.mycompany.com -J-Dhttps.proxyPort=80 -printcert -rfc -sslserver https://dl.google.com/dl/android/maven2/com/android/support/test/runner/1.0.1/runner-1.0.1.pom > maven2.cer
并运行命令:
keytool -import -noprompt -trustcacerts -keystore ..\lib\security\cacerts -importcert -alias <AliasName> -file <name.cer> -storepass <cacertsPassword>
如果您从未更改过 cacerts 的密码,则默认密码为 changeit
:
If you never changed the password of cacerts the default one is changeit
:
Example:
C:\Program Files\Android\Android Studio\jre\jre\bin>keytool -import -noprompt -trustcacerts -keystore ..\lib\security\cacerts -importcert -alias Maven -file maven2.cer -storepass changeit
解决方案 02(对我有用):
下载进入 URL 站点的 pom 并将其存储在您的本地存储库中:
SOLUTION 02 (Worked for me):
Download the pom entering to the URL site and store it in your local repo:
Ex:
If your missing resoruce is:
https://dl.google.com/dl/android/maven2/com/android/support/test/espresso/espresso-core/3.0.1/espresso-core-3.0.1.pom
Download it and put it in:
C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/support/test/espresso/espresso-core/3.0.1/espresso-core-3.0.1.pom
这篇关于Android Studio 3.0 中的 Gradle 构建错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!