Unity gradle构建失败

时间:2018-04-23 17:49:50

标签: c# unity3d gradle build apk

我无法在Unity中构建另一个APK。总是一样的错误。

CommandInvokationFailure: Gradle build failed. 
C:/Program Files/Java/jdk1.8.0_171\bin\java.exe -classpath "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.0.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx2048m" "assembleRelease"

stderr[

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'gradleOut'.
> You have not accepted the license agreements of the following SDK components:
  [Android SDK Build-Tools 27.0.1].
  Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
  Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED in 1s
]
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 C:\Users\m-pro\AppData\Local\Android\Sdk\ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

Checking the license for package Android SDK Build-Tools 27.0.1 in C:\Users\m-pro\AppData\Local\Android\Sdk\licenses
Warning: License for package Android SDK Build-Tools 27.0.1 not accepted.
]
exit 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.Action`1 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)

我的设置和我尝试过的事情:

  • JDK版本1.8

  • SDK构建工具版本25

  • 我试图复制" -dontwarn com.google.vr.ndk.base.DaydreamApi"进入一个proguard文件(在某处看到这种类型的解决方案)

  • 从gradle构建交换到内部构建(因为内部构建会出现不同的错误)

  • 重新安装并重新启动计算机:D

1 个答案:

答案 0 :(得分:0)

在构建工具获得更新后,我的Unity版本遇到了同样的问题,因此您可能只需更新它们。

正如它在错误消息中所说,你需要使用android studio接受TOS

You have not accepted the license agreements of the following SDK components: [Android SDK Build-Tools 27.0.1]. Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.

    在您的PC上
  • Install Android studio(如果您已经没有)
  • 运行其SDK管理器(配置> SDK管理器> SDK工具)
  • 如果Android SDK构建工具显示"未安装",请点击其旁边的复选框进行安装。

  • 如果它说"更新可用"单击带有" - "的复选框旁边就是它显示了一个"✓"

  • 点击申请,并接受协议。

这就是为我解决的问题,希望这也适合你!

相关问题