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 failed build.

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 an image of the error message on the console:

enter image description here

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:


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


2 Answers 2


I'm not sure, but I would guess that the compiler error is caused by code that's nested between platform-specific compiler flags. Since you're building an Android APK, the first places I would look would be anywhere in your solution containing code within the compiler flags #if UNITY_ANDROID or #if ENABLE_IL2CPP.


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.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .