打包失败问题良心解决,看完这个一定让你轻松
问题
CommandInvokationFailure: Gradle build failed.
C:\Program Files\Java\jdk1.8.0_171\bin\java.exe -classpath “C:\Program Files\Unity2017.4.2.0\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.6.jar” org.gradle.launcher.GradleMain “-Dorg.gradle.jvmargs=-Xmx1024m” “assembleRelease”
stderr[
FAILURE: Build failed with an exception.
- What went wrong:
A problem occurred configuring root project ‘gradleOut’.
Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;28.0.2 Android SDK Build-Tools 28.0.2
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
Using Android SDK: C:\android-sdk_r24.4.1-windows\android-sdk-windows
-
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 10s
]
stdout[
Starting a Gradle Daemon, 2 incompatible Daemons could not be reused, use --status for details
WARNING: Configuration ‘compile’ is obsolete and has been replaced with ‘implementation’ and ‘api’.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: The specified Android SDK Build Tools version (28.0.0) is ignored, as it is below the minimum supported version (28.0.2) for Android Gradle Plugin 3.2.0.
Android SDK Build Tools 28.0.2 will be used.
To suppress this warning, remove “buildToolsVersion ‘28.0.0’” from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
Checking the license for package Android SDK Build-Tools 28.0.2 in C:\android-sdk_r24.4.1-windows\android-sdk-windows\licenses
Warning: License for package Android SDK Build-Tools 28.0.2 not accepted.
]
stdout[
NDK is missing a “platforms” directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to D:\sdk\android-sdk-windows\ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.
Observed package id ‘build-tools;28.0.0-rc1’ in inconsistent location ‘D:\sdk\android-sdk-windows\build-tools\28.0.0-preview’ (Expected ‘D:\sdk\android-sdk-windows\build-tools\28.0.0-rc1’)
code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action1 progress, System.String error) UnityEditor.Android.GradleWrapper.Run (System.String workingdir, System.String task, System.Action
1 progress)
Rethrow as GradleInvokationException: Gradle build failed
UnityEditor.Android.GradleWrapper.Run (System.String workingdir, System.String task, System.Action`1 progress)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
为什么会发生
打包的时候出现失败,因为我遇见这个问题三次了 在百度上搜的答案是让我把打包选项的 Gradle换成Internal 这无非是高校
解决之策
你的错误肯定与我不同,找原因
无非是 JDK SDK NDK 版本问题
如果你看不懂报错 就复制到翻译软件上
从图中可以看出 我的错误是因为SDk版本低 让我尝试28.0.2 索性我就升级了一下SDK
升级方法:图箭头所示选择需要的版本
如果是SDK问题就会解决
如果是JDK问题呢
将JDK版本降低至jdk 8及以下即可(这里以Java SE Development Kit 8u161为例:)
可以是jdk1.8.0_171
如果你电脑上已经安装其他版本的JDK 怎么再换JDK呢
之前一直使用的是JDK1.8版本,现在要换成JDK1.7的!看见网上有很多不知道如何切换的。所以写出来,供大家分享!
我现在电脑上安装了JDK1.7和JDK1.8。接下来就是配置环境变量了!
Path配置
%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;
JAVA_HOME配置
C:\Program Files\Java\jdk1.8.0_66
CLASSPATH配置
.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar
java命令
java -version
下面切换成JDK1.7的只需要该下环境变量就可以了
更改JDK版本方式:(举例1.7)
步骤一:
将JAVA_HOME变量中写入现在的JDK1.7路径。
C:\Program Files\Java\jdk1.7.0_80
步骤二:
在PATH变量中写入JDK1.7的jre下得bin路径,(写在最前面)
C:\Program Files\Java\jre7\bin
再cmd中输入 java -version 回车 就发现JDK已经换了
这样,我们就将JDK切换了!还不用卸载原来的JDK。如果还想改回原来的JDK,只需将JDK的配置删除就可以了!
如果你没有NDK 就下载一个NDK
到此 这个问题一定解决 记录下来 以后轻松面对