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依赖项(适用于Gradle的Android插件):
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
我给你2个解决方案:
1st: 您必须手动将证书添加到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(为我工作):
将输入的pom下载到URL站点并将其存储在本地仓库中
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屋!