Build error, UnityEditor.BuildPlayerWindow+BuildMethodException. Any solution?

I’ve faced this common problem, and I’ve tried all common solutions but no success was reached.
Build with erros and output build folder totally empty (logs below).


Specs:

  • OS: Ubuntu 20.04
  • Script Editor: VS Code
  • Unity version: 2020.1.4f1
  • Unity Hub version: 2.4.0
  • Project type: WebGL
  • Computer with enough resources (RAM, SSD…)

Solutions that I’ve already tried but with no success:

  • Deleting solution (.sln) file.
  • Deleting “Library” folder.
  • Deleting “.vscode” file.
  • Applying “apt install libgconf-2-4” and autoremove.
  • When I tried to run Unity with “sudo ./UnityHub.AppImage --no-sandbox” I wasn’t able to load a proaject at UnityHub.
  • Reimporting all assets.
  • Swithing API compatibility between .NET Standard 2.0 para .NET 4.x.
  • I tried to use both buttons: “build” and “build and run”.
  • Changing stack_size from 8192 to 1024.
  • No special character or whitespace on project folder’s path.
  • Setting output build folder to a different folder from project folder.
  • Moving project to desktop folder.
  • Rebooting computer.
  • Using another Unity version: 2020.1.6f1 e 2020.2.0b2.

Build logs:

Log 1:

Win32Exception: ApplicationName='python', CommandLine='-E "/home/vinicius/Unity/Hub/Editor/2020.1.4f1/Editor/Data/PlaybackEngines/WebGLSupport/BuildTools/Emscripten/emcc" @"/home/vinicius/Documentos/Cursos/Alura Unity 1/Zumbi/Assets/../Temp/emcc_arguments.resp"', CurrentDirectory='/home/vinicius/Documentos/Cursos/Alura Unity 1/Zumbi/Temp/StagingArea/Data', Native error= mono-io-layer-error (2)
System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) (at <c8c8707b2adc41b09ae682df75fe1fd0>:0)
System.Diagnostics.Process.Start () (at <c8c8707b2adc41b09ae682df75fe1fd0>:0)
(wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
System.Diagnostics.Process.Start (System.Diagnostics.ProcessStartInfo startInfo) (at <c8c8707b2adc41b09ae682df75fe1fd0>:0)
UnityEditor.WebGL.ProgramUtils.StartProgramChecked (System.Diagnostics.ProcessStartInfo p) (at /Users/bokken/buildslave/unity/build/PlatformDependent/WebGL/Extensions/Unity.WebGL.extensions/ProgramUtils.cs:34)
UnityEditor.WebGL.WebGlBuildPostprocessor.EmscriptenLink (UnityEditor.Modules.BuildPostProcessArgs args, System.Boolean wasmBuild, System.String sourceFiles, System.String sourceFilesHash) (at /Users/bokken/buildslave/unity/build/PlatformDependent/WebGL/Extensions/Unity.WebGL.extensions/BuildPostprocessor.cs:431)
UnityEditor.WebGL.WebGlBuildPostprocessor.LinkBuild (UnityEditor.Modules.BuildPostProcessArgs args) (at /Users/bokken/buildslave/unity/build/PlatformDependent/WebGL/Extensions/Unity.WebGL.extensions/BuildPostprocessor.cs:473)
UnityEditor.WebGL.WebGlBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args) (at /Users/bokken/buildslave/unity/build/PlatformDependent/WebGL/Extensions/Unity.WebGL.extensions/BuildPostprocessor.cs:912)
UnityEditor.Modules.DefaultBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at /home/bokken/buildslave/unity/build/Editor/Mono/Modules/DefaultBuildPostprocessor.cs:27)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at /home/bokken/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:324)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) (at /home/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)    

Log 2:

	Build completed with a result of 'Failed'
	UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) (at /home/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)    

Log 3:

UnityEditor.BuildPlayerWindow+BuildMethodException: 2 errors
  at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x00270] in /home/bokken/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:187 
  at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in /home/bokken/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:95 
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) (at /home/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)

Hi Viniicus,
Hope you have found a solution, however here is a suggestion :

i had similar troubles with scripts using references to editor stuff. In my case, a script coming from other developper was using "using UnityEditor.SceneManagement; ". In my case, i simply commented that line and as the SceneManagement was not really usefull it compiles like a charm and everything goes well. Some time you may have to investigate why such Editor reference was made, and potentially isolate it with something like “#if UNITY_EDITOR” / “#endif” as suggested in the this forum :
https://forum.unity.com/threads/unity-build-errors.663364/

To help you find the responsible script, you can try to search for “compilationhadfailure” in the editor log.

Hope it helps,
Wilfrid