c# - Unity gradle 构建失败

标签 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
  • 最佳答案

    在构建工具更新后,我的 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.

  • Install Android studio在您的 PC 上(如果您还没有的话)
  • 运行其 SDK 管理器(配置 > SDK 管理器 > SDK 工具)
  • 如果 Android SDK 构建工具显示“未安装”,请单击它旁边的复选框进行安装。
  • 如果显示“更新可用”,请单击旁边带有“-”的复选框,以显示“✓”
  • 点击申请,并接受协议(protocol)。

  • 这就是为我解决的问题,希望这也对你有用!

    关于c# - Unity gradle 构建失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49987126/

    相关文章:

    android - 在Android中编译facebook sdk时`[4,5)表示法是什么意思?

    c# - 在 c# httpclient 上设置超时不起作用

    unity3d - 如何在Unity中让角色面对相反的方向?

    c# - 相机与物体矢量相交的角度

    gradle - 如何发布在 gradle 中实际更改的模块而不是全部(未更改)以设置 CI?

    java - 迁移到 AndroidX 后如何更新所有库?

    c# - 获取通用列表项的计数

    c# - 模拟用户代理

    c# - 使用 LINQ 在 C# 中合并字典

    ios - 使用为 iOS 和 android 增强的 Vuforia 在纸上显示动态文本