Cannot Export to WebGL because of il2CPP stops working.
I am doing a simple project as a tutorial for Unity (using the latest version for Windows, 5.4.2f1). My project works when exported to Windows, but when I export to WebGL, I receive two errors (shown below). The project is extremely simple and made with assets provided by the tutorial, so I don't know why it isn't working.
I've tried running Unity as an administrator, and have checked for updates, but if there's another solution I need to pursue, please let me know. It is extremely important to me that I can publish to web.
Error 1:
Failed running D:#Prog Shortcuts\Programming Tools\Tools Pgrm Files\Unity\Editor\Data\il2cpp/build/il2cpp.exe --convert-to-cpp --compile-cpp --libil2cpp-static --platform="WebGL" --architecture="EmscriptenJavaScript" --configuration="Release" --outputpath="D:/#Code-Work/Unity Course/Unity Coursework/IntroWeekI/Solar System project/Assets /../Temp/StagingArea/Data\Native\UserAssembly.bc" --cachedirectory="D:/#Code-Work/Unity Course/Unity Coursework/IntroWeekI/Solar System project/Assets/../Library/il2cpp_cache" --compiler-flags="-Oz -DIL2CPP_EXCEPTION_DISABLED=1 " --linker-flags="-Oz -s NO_EXIT_RUNTIME=1" --additional-include-directories="D:/#Code-Work/Unity Course/Unity Coursework/IntroWeekI/Solar System project/Assets/../Temp/StagingArea/Data\Native\UserAssembly.bc" --extra-types.file="D:#Prog Shortcuts\Programming Tools\Tools Pgrm Files\Unity\Editor\Data\il2cpp\il2cpp_default_extra_types.txt" --assembly="D:#Code-Work\Unity Course\Unity Coursework\IntroWeekI\Solar System project\Temp\StagingArea\Data\Managed\Assembly-CSharp.dll" --assembly="D:#Code-Work\Unity Course\Unity Coursework\IntroWeekI\Solar System project\Temp\StagingArea\Data\Managed\UnityEngine.dll" --generatedcppdir="D:#Code-Work\Unity Course\Unity Coursework\IntroWeekI\Solar System project\Temp\StagingArea\Data\il2cppOutput"
stdout: Building UserAssembly.bc with EmscriptenToolChain. Output directory: D:#Code-Work\Unity Course\Unity Coursework\IntroWeekI\Solar System project\Temp\StagingArea\Data\Native Cache directory: D:#Code-Work\Unity Course\Unity Coursework\IntroWeekI\Solar System project\Library\il2cpp_cache il2cpp.exe didn't catch exception: System.AggregateException: One or more errors occurred. ---> System.TypeInitializationException: The type initializer for 'Unity.IL2CPP.Building.ToolChains.EmscriptenPaths' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Unity.IL2CPP.Building.ToolChains.EmscriptenPaths.get_WebGlRoot() at Unity.IL2CPP.Building.ToolChains.EmscriptenPaths.get_EmscriptenConfig() at Unity.IL2CPP.Building.ToolChains.EmscriptenPaths..cctor() --- End of inner exception stack trace --- at Unity.IL2CPP.Building.ToolChains.EmscriptenPaths.get_Python() at Unity.IL2CPP.Building.ToolChains.EmscriptenToolChain.CompilerExecutableFor(NPath sourceFile) at Unity.IL2CPP.Building.CppProgramBuilder.ProvideObjectFile(CppCompilationInstruction cppCompilationInstruction) at Unity.IL2CPP.Building.ParallelFor.c_AnonStorey1`2.<>m0(Object o) --- End of inner exception stack trace --- at Unity.IL2CPP.Building.ParallelFor.RunWithResult[D,T](D[] data, Func`2 action) at Unity.IL2CPP.Building.CppProgramBuilder.BuildAllCppFiles(IEnumerable`1 sourceFilesToCompile) at Unity.IL2CPP.Building.CppProgramBuilder.Build() at il2cpp.Program.DoRun(String[] args) at il2cpp.Program.Run(String[] args) at il2cpp.Program.Main(String[] args) ---> (Inner Exception #0) System.TypeInitializationException: The type initializer for 'Unity.IL2CPP.Building.ToolChains.EmscriptenPaths' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Unity.IL2CPP.Building.ToolChains.EmscriptenPaths.get_WebGlRoot() at Unity.IL2CPP.Building.ToolChains.EmscriptenPaths.get_EmscriptenConfig() at Unity.IL2CPP.Building.ToolChains.EmscriptenPaths..cctor() --- End of inner exception stack trace --- at Unity.IL2CPP.Building.ToolChains.EmscriptenPaths.get_Python() at Unity.IL2CPP.Building.ToolChains.EmscriptenToolChain.CompilerExecutableFor(NPath sourceFile) at Unity.IL2CPP.Building.CppProgramBuilder.ProvideObjectFile(CppCompilationInstruction cppCompilationInstruction) at Unity.IL2CPP.Building.ParallelFor.cAnonStorey1`2.<>m_0(Object o)<---
---> (Inner Exception #1) System.TypeInitializationException: The type initializer for 'Unity.IL2CPP.Building.ToolChains.EmscriptenPaths' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Unity.IL2CPP.Building.ToolChains.EmscriptenPaths.get_WebGlRoot() at Unity.IL2CPP.Building.ToolChains.EmscriptenPaths.get_EmscriptenConfig() at Unity.IL2CPP.Building.ToolChains.EmscriptenPaths..cctor() --- End of inner exception stack trace --- at Unity.IL2CPP.Building.ToolChains.EmscriptenPaths.get_Python() at Unity.IL2CPP.Building.ToolChains.EmscriptenToolChain.CompilerExecutableFor(NPath sourceFile) at Unity.IL2CPP.Building.CppProgramBuilder.ProvideObjectFile(CppCompilationInstruction cppCompilationInstruction) at Unity.IL2CPP.Building.ParallelFor.c_AnonStorey1`2.<>m_0(Object o)<---
---> (Inner Exception #2) System.TypeInitializationException: The type initializer for 'Unity.IL2CPP.Building.ToolChains.EmscriptenPaths' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Unity.IL2CPP.Building.ToolChains.EmscriptenPaths.get_WebGlRoot() at Unity.IL2CPP.Building.ToolChains.EmscriptenPaths.get_EmscriptenConfig() at Unity.IL2CPP.Building.ToolChains.EmscriptenPaths..cctor() --- End of inner exception stack trace --- at Unity.IL2CPP.Building.ToolChains.EmscriptenPaths.get_Python() at Unity.IL2CPP.Building.ToolChains.EmscriptenToolChain.CompilerExecutableFor(NPath sourceFile) at Unity.IL2CPP.Building.CppProgramBuilder.ProvideObjectFile(CppCompilationInstruction cppCompilationInstruction) at Unity.IL2CPP.Building.ParallelFor.c_AnonStorey1`2.<>m_0(Object o)<---
---> (Inner Exception #3) System.TypeInitializationException: The type initializer for 'Unity.IL2CPP.Building.ToolChains.EmscriptenPaths' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Unity.IL2CPP.Building.ToolChains.EmscriptenPaths.get_WebGlRoot() at Unity.IL2CPP.Building.ToolChains.EmscriptenPaths.get_EmscriptenConfig() at Unity.IL2CPP.Building.ToolChains.EmscriptenPaths..cctor() --- End of inner exception stack trace --- at Unity.IL2CPP.Building.ToolChains.EmscriptenPaths.get_Python() at Unity.IL2CPP.Building.ToolChains.EmscriptenToolChain.CompilerExecutableFor(NPath sourceFile) at Unity.IL2CPP.Building.CppProgramBuilder.ProvideObjectFile(CppCompilationInstruction cppCompilationInstruction) at Unity.IL2CPP.Building.ParallelFor.c_AnonStorey1`2.<>m_0(Object o)<---
stderr:
Unhandled Exception: System.AggregateException: One or more errors occurred. ---> System.TypeInitializationException: The type initializer for 'Unity.IL2CPP.Building.ToolChains.EmscriptenPaths' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Unity.IL2CPP.Building.ToolChains.EmscriptenPaths.get_WebGlRoot() at Unity.IL2CPP.Building.ToolChains.EmscriptenPaths.get_EmscriptenConfig() at Unity.IL2CPP.Building.ToolChains.EmscriptenPaths..cctor() --- End of inner exception stack trace --- at Unity.IL2CPP.Building.ToolChains.EmscriptenPaths.get_Python() at Unity.IL2CPP.Building.ToolChains.EmscriptenToolChain.CompilerExecutableFor(NPath sourceFile) at Unity.IL2CPP.Building.CppProgramBuilder.ProvideObjectFile(CppCompilationInstruction cppCompilationInstruction) at Unity.IL2CPP.Building.ParallelFor.c_AnonStorey1`2.<>m_0(Object o) --- End of inner exception stack trace --- at Unity.IL2CPP.Building.ParallelFor.RunWithResult[D,T](D[] data, Func`2 action) at Unity.IL2CPP.Building.CppProgramBuilder.BuildAllCppFiles(IEnumerable`1 sourceFilesToCompile) at Unity.IL2CPP.Building.CppProgramBuilder.Build() at il2cpp.Program.DoRun(String[] args) at il2cpp.Program.Run(String[] args) at il2cpp.Program.Main(String[] args)
0x0000000140E4CF6D (Unity) StackWalker::GetCurrentCallstack 0x0000000140E4EC61 (Unity) StackWalker::ShowCallstack 0x0000000140603C03 (Unity) GetStacktrace 0x000000014060102E (Unity) DebugStringToFile 0x000000014060148C (Unity) DebugStringToFile 0x0000000140E8D00C (Unity) DebugLogHandler_CUSTOM_Internal_Log 0x000000001E5CF1D3 (Mono JIT Code) (wrapper managed-to-native) UnityEngine.DebugLogHandler:Internal_Log (UnityEngine.LogType,string,UnityEngine.Object) 0x000000001E5CF0C5 (Mono JIT Code) [DebugLogHandler.cs:10] UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[]) 0x000000001E5CEC38 (Mono JIT Code) [Logger.cs:42] UnityEngine.Logger:Log (UnityEngine.LogType,object) 0x000000001E5CE569 (Mono JIT Code) [UnityEngineDebugBindings.gen.cs:121] UnityEngine.Debug:LogError (object) 0x000000001E574D79 (Mono JIT Code) [IL2CPPUtils.cs:98] UnityEditorInternal.Runner:RunManagedProgram (string,string,string,UnityEditor.Scripting.Compilers.CompilerOutputParserBase,System.Action`1 ) 0x000000001E5C985B (Mono JIT Code) [IL2CPPUtils.cs:350] UnityEditorInternal.IL2CPPBuilder:ConvertPlayerDlltoCpp (System.Collections.Generic.ICollection`1,string,string) 0x000000001E5676FE (Mono JIT Code) [IL2CPPUtils.cs:213] UnityEditorInternal.IL2CPPBuilder:Run () 0x000000001E566826 (Mono JIT Code) [IL2CPPUtils.cs:139] UnityEditorInternal.IL2CPPUtils:RunIl2Cpp (string,UnityEditorInternal.IIl2CppPlatformProvider,System.Action`1,UnityEditor.RuntimeClassRegistry,bool) 0x000000001E55FEA0 (Mono JIT Code) [BuildPostprocessor.cs:377] UnityEditor.WebGL.WebGlBuildPostprocessor:PostProcess (UnityEditor.Modules.BuildPostProcessArgs) 0x000000001E55EACA (Mono JIT Code) [PostprocessBuildPlayer.cs:176] UnityEditor.PostprocessBuildPlayer:Postprocess (UnityEditor.BuildTarget,string,string,string,int,int,string,string,UnityEditor.BuildOptions,UnityEditor.RuntimeClassRegistry,UnityEditor.BuildReporting.BuildReport) 0x000000001E55EEAF (Mono JIT Code) (wrapper runtime-invoke) :runtime_invoke_void_int_object_object_object_int_int_object_object_int_object_object (object,intptr,intptr,intptr) 0x000007FEEADC503F (mono) [mini.c:4937] mono_jit_runtime_invoke 0x000007FEEAD18385 (mono) [object.c:2623] mono_runtime_invoke 0x000000014033C495 (Unity) mono_runtime_invoke_profiled 0x00000001409E747D (Unity) BuildAssetBundleLocalPath 0x00000001409E7507 (Unity) BuildAssetBundleLocalPath 0x00000001409EA268 (Unity) BuildReporting::BuildReport::GetAppendices 0x00000001409FEA77 (Unity) std::deque > >,std::allocator > > > >::push_back 0x00000001409FF36F (Unity) BuildPlayer 0x00000001409E49EF (Unity) BuildPlayerWithLastSettings 0x00000001404C2DC7 (Unity) MonoManager::EndReloadAssembly 0x00000001404C3AFA (Unity) MonoManager::ReloadAssembly 0x000000014075ECFD (Unity) ReloadAllUsedAssemblies 0x0000000140BE2F08 (Unity) Application::TickTimer 0x0000000140E4768E (Unity) FindMonoBinaryToUse 0x0000000140E48CC1 (Unity) WinMain 0x00000001415CB660 (Unity) strnlen 0x0000000076D059CD (kernel32) BaseThreadInitThunk
Error 2:
Exception: D:#Prog Shortcuts\Programming Tools\Tools Pgrm Files\Unity\Editor\Data\il2cpp/build/il2cpp.exe did not run properly! UnityEditorInternal.Runner.RunManagedProgram (System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser, System.Action`1 setupStartInfo) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:100) UnityEditorInternal.IL2CPPBuilder.ConvertPlayerDlltoCpp (ICollection`1 userAssemblies, System.String outputDirectory, System.String workingDirectory) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:350) UnityEditorInternal.IL2CPPBuilder.Run () (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:213) UnityEditorInternal.IL2CPPUtils.RunIl2Cpp (System.String stagingAreaData, IIl2CppPlatformProvider platformProvider, System.Action`1 modifyOutputBeforeCompile, UnityEditor.RuntimeClassRegistry runtimeClassRegistry, Boolean developmentBuild) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:139) UnityEditor.WebGL.WebGlBuildPostprocessor.PostProcess (BuildPostProcessArgs args) (at /Users/builduser/buildslave/unity/build/PlatformDependent/WebGL/Extensions/Unity.WebGL.extensions/BuildPostprocessor.cs:377) UnityEditor.PostprocessBuildPlayer.Postprocess (BuildTarget target, System.String installPath, System.String companyName, System.String productName, Int32 width, Int32 height, System.String downloadWebplayerUrl, System.String manualDownloadWebplayerUrl, BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.BuildReporting.BuildReport report) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:176)
Answer by JoshPeterson · Nov 14, 2016 at 12:31 PM
It looks like this is the relevant error:
System.NullReferenceException: Object reference not set to an instance of an object. at Unity.IL2CPP.Building.ToolChains.EmscriptenPaths.get_WebGlRoot()
That error indicates something is wrong with the Unity installation, because it cannot properly find the Emscripten compiler to build the WebGL content. It looks like Unity might be installed at this path: D:#Prog Shortcuts\Programming Tools\Tools Pgrm Files\Unity
. I'm curious about the "#" character in the path. I wonder if the Emscripten tools might be thrown off by that character. Can you try to install or move Unity to a path without a "#" character in it?
Thank you, yes it was the problem. Thank you so muc. I have to rethink my habit of using "#"