unity2018.3.5版本及以上版本打包Android平台失败CommandInvokationFailure: Gradle build failed.
问题描述:
unity2018.3.5版本打包Android平台出现报错CommandInvokationFailure: Gradle build failed.
Console控制台显示错误:
CommandInvokationFailure: Gradle build failed.
C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\OpenJDK\Windows\bin\java.exe -classpath “C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.6.jar” org.gradle.launcher.GradleMain “-Dorg.gradle.jvmargs=-Xmx4096m” “assembleRelease”
stderr[
FAILURE: Build failed with an exception.
- What went wrong:
A problem occurred configuring root project ‘gradleOut’.
Could not resolve all artifacts for configuration ‘:classpath’.
Could not resolve org.jetbrains.kotlin:kotlin-stdlib-jre8:1.2.0.
Required by:
project : > com.android.tools.build:gradle:3.2.0
project : > com.android.tools.build:gradle:3.2.0 > com.android.tools.build:builder:3.2.0
project : > com.android.tools.build:gradle:3.2.0 > com.android.tools.lint:lint-gradle-api:26.2.0
project : > com.android.tools.build:gradle:3.2.0 > com.android.tools.build:gradle-api:3.2.0
project : > com.android.tools.build:gradle:3.2.0 > androidx.databinding:databinding-compiler-common:3.2.0
project : > com.android.tools.build:gradle:3.2.0 > com.android.tools.build:builder:3.2.0 > com.android.tools:sdk-common:26.2.0
project : > com.android.tools.build:gradle:3.2.0 > com.android.tools.build:builder:3.2.0 > com.android.tools:common:26.2.0
project : > com.android.tools.build:gradle:3.2.0 > com.android.tools.build:builder:3.2.0 > com.android.tools.build:manifest-merger:26.2.0
project : > com.android.tools.build:gradle:3.2.0 > com.android.tools.build:builder:3.2.0 > com.android.tools:sdklib:26.2.0 > com.android.tools:repository:26.2.0
Could not resolve org.jetbrains.kotlin:kotlin-stdlib-jre8:1.2.0.
Could not get resource ‘https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jre8/1.2.0/kotlin-stdlib-jre8-1.2.0.pom’.
Could not GET ‘https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jre8/1.2.0/kotlin-stdlib-jre8-1.2.0.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 org.jetbrains.kotlin:kotlin-stdlib-jre8:1.2.0.
Could not get resource ‘https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-stdlib-jre8/1.2.0/kotlin-stdlib-jre8-1.2.0.pom’.
Could not GET ‘https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-stdlib-jre8/1.2.0/kotlin-stdlib-jre8-1.2.0.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 org.ow2.asm:asm:6.0.
Required by:
project : > com.android.tools.build:gradle:3.2.0
project : > com.android.tools.build:gradle:3.2.0 > com.android.tools.build:builder:3.2.0
project : > com.android.tools.build:gradle:3.2.0 > com.android.tools.build.jetifier:jetifier-processor:1.0.0-alpha10
Could not resolve org.ow2.asm:asm:6.0.
Could not get resource ‘https://jcenter.bintray.com/org/ow2/asm/asm/6.0/asm-6.0.pom’.
Could not HEAD ‘https://jcenter.bintray.com/org/ow2/asm/asm/6.0/asm-6.0.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 org.ow2.asm:asm:6.0.
Could not get resource ‘https://dl.google.com/dl/android/maven2/org/ow2/asm/asm/6.0/asm-6.0.pom’.
Could not HEAD ‘https://dl.google.com/dl/android/maven2/org/ow2/asm/asm/6.0/asm-6.0.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 org.ow2.asm:asm-analysis:6.0.
Required by:
project : > com.android.tools.build:gradle:3.2.0
Could not resolve org.ow2.asm:asm-analysis:6.0.
Could not get resource ‘https://jcenter.bintray.com/org/ow2/asm/asm-analysis/6.0/asm-analysis-6.0.pom’.
Could not HEAD ‘https://jcenter.bintray.com/org/ow2/asm/asm-analysis/6.0/asm-analysis-6.0.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 org.ow2.asm:asm-analysis:6.0.
Could not get resource ‘https://dl.google.com/dl/android/maven2/org/ow2/asm/asm-analysis/6.0/asm-analysis-6.0.pom’.
Could not HEAD ‘https://dl.google.com/dl/android/maven2/org/ow2/asm/asm-analysis/6.0/asm-analysis-6.0.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 org.ow2.asm:asm-commons:6.0.
Required by:
project : > com.android.tools.build:gradle:3.2.0
project : > com.android.tools.build:gradle:3.2.0 > com.android.tools.build:builder:3.2.0
project : > com.android.tools.build:gradle:3.2.0 > com.android.tools.build.jetifier:jetifier-processor:1.0.0-alpha10
Could not resolve org.ow2.asm:asm-commons:6.0.
Could not get resource ‘https://jcenter.bintray.com/org/ow2/asm/asm-commons/6.0/asm-commons-6.0.pom’.
Could not HEAD ‘https://jcenter.bintray.com/org/ow2/asm/asm-commons/6.0/asm-commons-6.0.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 org.ow2.asm:asm-commons:6.0.
Could not get resource ‘https://dl.google.com/dl/android/maven2/org/ow2/asm/asm-commons/6.0/asm-commons-6.0.pom’.
Could not HEAD ‘https://dl.google.com/dl/android/maven2/org/ow2/asm/asm-commons/6.0/asm-commons-6.0.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 org.ow2.asm:asm-util:6.0.
Required by:
project : > com.android.tools.build:gradle:3.2.0
project : > com.android.tools.build:gradle:3.2.0 > com.android.tools.build:builder:3.2.0
project : > com.android.tools.build:gradle:3.2.0 > com.android.tools.build.jetifier:jetifier-processor:1.0.0-alpha10
Could not resolve org.ow2.asm:asm-util:6.0.
Could not get resource ‘https://jcenter.bintray.com/org/ow2/asm/asm-util/6.0/asm-util-6.0.pom’.
Could not HEAD ‘https://jcenter.bintray.com/org/ow2/asm/asm-util/6.0/asm-util-6.0.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 org.ow2.asm:asm-util:6.0.
Could not get resource ‘https://dl.google.com/dl/android/maven2/org/ow2/asm/asm-util/6.0/asm-util-6.0.pom’.
Could not HEAD ‘https://dl.google.com/dl/android/maven2/org/ow2/asm/asm-util/6.0/asm-util-6.0.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 net.sf.jopt-simple:jopt-simple:4.9.
Required by:
project : > com.android.tools.build:gradle:3.2.0
project : > com.android.tools.build:gradle:3.2.0 > com.android.tools.build:builder:3.2.0
Could not resolve net.sf.jopt-simple:jopt-simple:4.9.
Could not get resource ‘https://jcenter.bintray.com/net/sf/jopt-simple/jopt-simple/4.9/jopt-simple-4.9.pom’.
Could not HEAD ‘https://jcenter.bintray.com/net/sf/jopt-simple/jopt-simple/4.9/jopt-simple-4.9.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 net.sf.jopt-simple:jopt-simple:4.9.
Could not get resource ‘https://dl.google.com/dl/android/maven2/net/sf/jopt-simple/jopt-simple/4.9/jopt-simple-4.9.pom’.
Could not HEAD ‘https://dl.google.com/dl/android/maven2/net/sf/jopt-simple/jopt-simple/4.9/jopt-simple-4.9.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 net.sf.proguard:proguard-gradle:6.0.3.
Required by:
project : > com.android.tools.build:gradle:3.2.0
Could not resolve net.sf.proguard:proguard-gradle:6.0.3.
Could not get resource ‘https://jcenter.bintray.com/net/sf/proguard/proguard-gradle/6.0.3/proguard-gradle-6.0.3.pom’.
Could not HEAD ‘https://jcenter.bintray.com/net/sf/proguard/proguard-gradle/6.0.3/proguard-gradle-6.0.3.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 net.sf.proguard:proguard-gradle:6.0.3.
Could not get resource ‘https://dl.google.com/dl/android/maven2/net/sf/proguard/proguard-gradle/6.0.3/proguard-gradle-6.0.3.pom’.
Could not HEAD ‘https://dl.google.com/dl/android/maven2/net/sf/proguard/proguard-gradle/6.0.3/proguard-gradle-6.0.3.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.squareup:javawriter:2.5.0.
Required by:
project : > com.android.tools.build:gradle:3.2.0 > com.android.tools.build:builder:3.2.0
Could not resolve com.squareup:javawriter:2.5.0.
Could not get resource ‘https://jcenter.bintray.com/com/squareup/javawriter/2.5.0/javawriter-2.5.0.pom’.
Could not HEAD ‘https://jcenter.bintray.com/com/squareup/javawriter/2.5.0/javawriter-2.5.0.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.squareup:javawriter:2.5.0.
Could not get resource ‘https://dl.google.com/dl/android/maven2/com/squareup/javawriter/2.5.0/javawriter-2.5.0.pom’.
Could not HEAD ‘https://dl.google.com/dl/android/maven2/com/squareup/javawriter/2.5.0/javawriter-2.5.0.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 org.bouncycastle:bcpkix-jdk15on:1.56.
Required by:
project : > com.android.tools.build:gradle:3.2.0 > com.android.tools.build:builder:3.2.0
project : > com.android.tools.build:gradle:3.2.0 > com.android.tools.build:builder:3.2.0 > com.android.tools:sdk-common:26.2.0
project : > com.android.tools.build:gradle:3.2.0 > com.android.tools.build:builder:3.2.0 > com.android.tools.build:apkzlib:3.2.0
Could not resolve org.bouncycastle:bcpkix-jdk15on:1.56.
Could not get resource ‘https://jcenter.bintray.com/org/bouncycastle/bcpkix-jdk15on/1.56/bcpkix-jdk15on-1.56.pom’.
Could not HEAD ‘https://jcenter.bintray.com/org/bouncycastle/bcpkix-jdk15on/1.56/bcpkix-jdk15on-1.56.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 org.bouncycastle:bcpkix-jdk15on:1.56.
Could not get resource ‘https://dl.google.com/dl/android/maven2/org/bouncycastle/bcpkix-jdk15on/1.56/bcpkix-jdk15on-1.56.pom’.
Could not HEAD ‘https://dl.google.com/dl/android/maven2/org/bouncycastle/bcpkix-jdk15on/1.56/bcpkix-jdk15on-1.56.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 org.bouncycastle:bcprov-jdk15on:1.56.
Required by:
project : > com.android.tools.build:gradle:3.2.0 > com.android.tools.build:builder:3.2.0
project : > com.android.tools.build:gradle:3.2.0 > com.android.tools.build:builder:3.2.0 > com.android.tools:sdk-common:26.2.0
project : > com.android.tools.build:gradle:3.2.0 > com.android.tools.build:builder:3.2.0 > com.android.tools.build:apkzlib:3.2.0
Could not resolve org.bouncycastle:bcprov-jdk15on:1.56.
Could not get resource ‘https://jcenter.bintray.com/org/bouncycastle/bcprov-jdk15on/1.56/bcprov-jdk15on-1.56.pom’.
Could not HEAD ‘https://jcenter.bintray.com/org/bouncycastle/bcprov-jdk15on/1.56/bcprov-jdk15on-1.56.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 org.ow2.asm:asm-tree:6.0.
Required by:
project : > com.android.tools.build:gradle:3.2.0 > com.android.tools.build:builder:3.2.0
Could not resolve org.ow2.asm:asm-tree:6.0.
Could not get resource ‘https://jcenter.bintray.com/org/ow2/asm/asm-tree/6.0/asm-tree-6.0.pom’.
Could not HEAD ‘https://jcenter.bintray.com/org/ow2/asm/asm-tree/6.0/asm-tree-6.0.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 it.unimi.dsi:fastutil:7.2.0.
Required by:
project : > com.android.tools.build:gradle:3.2.0 > com.android.tools.build:builder:3.2.0
Could not resolve it.unimi.dsi:fastutil:7.2.0.
Could not get resource ‘https://jcenter.bintray.com/it/unimi/dsi/fastutil/7.2.0/fastutil-7.2.0.pom’.
Could not HEAD ‘https://jcenter.bintray.com/it/unimi/dsi/fastutil/7.2.0/fastutil-7.2.0.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 org.codehaus.mojo:animal-sniffer-annotations:1.14.
Required by:
project : > com.android.tools.build:gradle:3.2.0 > com.android.tools.analytics-library:shared:26.2.0 > com.google.guava:guava:23.0
Could not resolve org.codehaus.mojo:animal-sniffer-annotations:1.14.
Could not get resource ‘https://jcenter.bintray.com/org/codehaus/mojo/animal-sniffer-annotations/1.14/animal-sniffer-annotations-1.14.pom’.
Could not HEAD ‘https://jcenter.bintray.com/org/codehaus/mojo/animal-sniffer-annotations/1.14/animal-sniffer-annotations-1.14.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 commons-logging:commons-logging:1.2.
Required by:
project : > com.android.tools.build:gradle:3.2.0 > com.android.tools.analytics-library:crash:26.2.0 > org.apache.httpcomponen
起初以为是SDK的原因,便更新了SDK,使用AndroidStudio下载高版本的SDK均没有解决问题,查找网上资料发现解决的方案大多为:
将Build System设置为Internal,虽然可以正常打包出APK,但是这样是治标不治本的。
原因分析:
在网上查找了一些资料,发现上面的解决方案涉及到签名证书,只是绕开了签名证书,所以这可能跟Android签名证书有关,最终找到了解决方案。
解决方案:
在PlayerSettings找到publishing Settings,勾选Create a new Keystore…,输入Keystore password和Confirm Keystore password,点击Browse Keystore保存签名证书到本地。
然后就可以正常打包出来了。