Home > Software design >  Unity does not tell me the files that cause the build error. It only says "Error building Playe
Unity does not tell me the files that cause the build error. It only says "Error building Playe

Time:01-01

I am trying to build an APK in Unity 2019.4.39. Unity says that the build failed, but it does not tell me the files that caused the build to fail.

I can't fix the error because Unity does not tell which files or scripts are bad.

Can anyone please tell me how to figure out which files caused the build to fail ?


Here are the build errors:

Error building Player because scripts had compiler errors

UnityEditor.BuildPlayerWindow BuildMethodException: Error building Player because scripts had compiler errors
  at UnityEditor.BuildPlayerWindow DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002b3] in /Users/bokken/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:194 
  at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in /Users/bokken/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:95 
 #0 GetStacktrace(int)
 #1 DebugStringToFile(DebugStringToFileData const&)
 #2 DebugLogHandler_CUSTOM_Internal_Log(LogType, LogOption, ScriptingBackendNativeStringPtrOpaque*, ScriptingBackendNativeObjectPtrOpaque*)
 #3  (Mono JIT Code) (wrapper managed-to-native) UnityEngine.DebugLogHandler:Internal_Log (UnityEngine.LogType,UnityEngine.LogOption,string,UnityEngine.Object)
 #4  (Mono JIT Code) [BuildPlayerWindow.cs:964] UnityEditor.BuildPlayerWindow:GUIBuildButtons (UnityEditor.Modules.IBuildWindowExtension,bool,bool,bool,UnityEditor.Build.BuildPlatform)

Here is 1 image of the Unity console with the error message:

enter image description here

Note: I click on all 3 error messages, but still Unity does not show any filename that causes the build to fail.


PS: I know that there is an excellent answer to fix the build error "Error building Player because scripts had compiler errors" at this link on StackOverFlow:

Error when Building Project: Error building Player because scripts have compile errors in the editor

However, in my case, Unity does not even says which files are bad. So, I can't fix the error if I don't know which files cause errors.

CodePudding user response:

For UnityEditor issues, they don't show up in the console, but they should show up in the log. You could try opening up the log and searching for "error" to diagnose the problem there.

https://docs.unity3d.com/Manual/LogFiles.html

CodePudding user response:

I've found the solution to my own issue. Basically, the problem is that my project contains 2 versions of DOTween, and 2 versions of Lean. This causes the build errors.

But, if I only build the scene (without "Play" the scene first), then Unity won't tell me the files or packages that cause the build errors.

I have to "Play" the scene in Unity, and then it will tell me the files or packages that cause that are duplicated, and cause the build error.


Here are the details:

To find out what files or packages cause the build errors, I need to "Play" the scene in Unity. When the scene is played in Unity, it tells me that there are 2 conflicting versions of 2 different packages: DOTween and Lean.

The reason is that my old project already has 1 version of DOTween and Lean. When I install a new unity package (called Game_Menu), it also installs a new version of DOTween and a new version of Lean without deleting or overwriting the old versions. So, there are 2 versions of DOTween, and 2 versions of Lean in my project. This causes the build error.

My solution is to manually remove 1 version of DOTween and 1 version of Lean. Then, Unity builds the APK successfully.


In the future, whenever I install this Unity package (called Game_Menu), I will need to check to see if my project already contains DOTween or Lean. If it already does, then I don't need to install these 2 packages.

  • Related