将操作系统更改为Ubuntu-18.04并升级到v4.8后,我无法构建android项目。
作为比较,我可以使用gradle-v3.4.1。在Ubuntu-14.04上构建该项目。
有些错误消息。
Gradle构建失败,如下所示:
user@Ubuntu1804 ~/android/im/ocelot $ gradle build
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'ocelot'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:3.1.2.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:3.1.2.
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom'.
> Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.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.tools.build:gradle:3.1.2.
> Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom'.
> Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
这是build.gradle:
user@Ubuntu1804 ~/android/im/ocelot $ cat build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这是gradle版本:
user@Ubuntu1804 ~/android/im/ocelot $ gradle -version
------------------------------------------------------------
Gradle 4.8
------------------------------------------------------------
Build time: 2018-06-04 10:39:58 UTC
Revision: 9e1261240e412cbf61a5e3a5ab734f232b2f887d
Groovy: 2.4.12
Ant: Apache Ant(TM) version 1.9.11 compiled on March 23 2018
JVM: 1.8.0_171 (Oracle Corporation 25.171-b11)
OS: Linux 4.15.0-23-generic amd64
OpenJDK-1.8.0:
user@Ubuntu1804 ~/android/im/ocelot $ java -version
openjdk version "1.8.0_171"
OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-0ubuntu0.18.04.1-b11)
OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)
我已经导入了一些证书,并对其进行了如下验证:
user@Ubuntu1804 ~/android/im/ocelot $ keytool -list -keystore $JAVA_HOME/jre/lib/security/cacerts | grep google
Enter keystore password: changeit
google.com, Jun 21, 2018, trustedCertEntry,
debian:googlecom.pem, Jun 21, 2018, trustedCertEntry,
dl.google.com, Jun 21, 2018, trustedCertEntry,
maven.google.com, Jun 21, 2018, trustedCertEntry,
user@Ubuntu1804 ~/android/im/ocelot $ keytool -list -keystore $JAVA_HOME/jre/lib/security/cacerts | grep bintray
Enter keystore password: changeit
jcenter.bintray.com, Jun 21, 2018, trustedCertEntry,
我做了一些测试以验证Internet连接,因为有一个HTTPS_PROXY:
user@Ubuntu1804 ~/android/im/ocelot $ wget https://maven.google.com/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom
--2018-06-21 22:21:27-- https://maven.google.com/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom
Resolving proxy.COMPANY.net (proxy.COMPANY.net)... 10.x.x.x
Connecting to proxy.COMPANY.net (proxy.COMPANY.net)|10.x.x.x|:8080... connected.
Proxy request sent, awaiting response... 301 Moved Permanently
Location: https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom [following]
--2018-06-21 22:21:28-- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom
Connecting to proxy.COMPANY.net (proxy.COMPANY.net)|10.x.x.x|:8080... connected.
Proxy request sent, awaiting response... 200 OK
Length: 2391 (2.3K) [application/octet-stream]
Saving to: ‘gradle-3.1.2.pom.1’
gradle-3.1.2.pom.1 100%[====================================================>] 2.33K --.-KB/s in 0s
2018-06-21 22:21:29 (17.1 MB/s) - ‘gradle-3.1.2.pom.1’ saved [2391/2391]
user@Ubuntu1804 ~/android/im/ocelot $ curl https://maven.google.com/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom
curl: (35) error:1408F10B:SSL routines:ssl3_get_record:wrong version number
答案 0 :(得分:0)
这很可能是truststore
问题。
尝试通过以下方式运行您的构建:./gradlew --no-daemon -Djavax.net.debug=ssl:handshake:verbose build
通过查找第truststore
行,检查哪个adding as trusted cert:
被加载以及它包含哪些证书。