Unity Android build failure: The specified executable is not a valid application for this OS platform

0

Building a Unity project for Android failures at last steps, here what I get in the console:

Failed running C:\Program Files\Unity\Hub\Editor\2019.2.4f1\Editor\Data\il2cpp/build/il2cpp.exe ... il2cpp.exe didn't catch exception: System.AggregateException: One or more errors occurred. ---> System.ComponentModel.Win32Exception: The specified executable is not a valid application for this OS platform.

How to understand what is going wrong and fix it?

Full error text:


Failed running C:\Program Files\Unity\Hub\Editor\2019.2.4f1\Editor\Data\il2cpp/build/il2cpp.exe --convert-to-cpp --emit-null-checks --enable-array-bounds-check --dotnetprofile="unityaot" --compile-cpp --libil2cpp-static --platform="Android" --architecture="ARMv7" --configuration="Release" --outputpath="D:\Projects\Unity3d\MyGame\Temp\StagingArea\assets\bin\Data\Native\armeabi-v7a\libil2cpp.so" --cachedirectory="D:\Projects\Unity3d\MyGame\Assets\..\Library\il2cpp_android_armeabi-v7a/il2cpp_cache" --additional-include-directories="C:/Program Files/Unity/Hub/Editor/2019.2.4f1/Editor/Data/PlaybackEngines/AndroidPlayer/Tools\bdwgc/include" --additional-include-directories="C:/Program Files/Unity/Hub/Editor/2019.2.4f1/Editor/Data/PlaybackEngines/AndroidPlayer/Tools\libil2cpp/include" --tool-chain-path="C:/Program Files/Unity/Hub/Editor/2019.2.4f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK" --profiler-report --map-file-parser="C:/Program Files/Unity/Hub/Editor/2019.2.4f1/Editor/Data/Tools/MapFileParser/MapFileParser.exe" --directory=D:/Projects/Unity3d/MyGame/Temp/StagingArea/assets/bin/Data/Managed --generatedcppdir=D:/Projects/Unity3d/MyGame/Temp/StagingArea/Il2Cpp/il2cppOutput 


stdout:
Building libil2cpp.so with AndroidToolChain
    Output directory: D:\Projects\Unity3d\MyGame\Temp\StagingArea\assets\bin\Data\Native\armeabi-v7a
    Cache directory: D:\Projects\Unity3d\MyGame\Library\il2cpp_android_armeabi-v7a\il2cpp_cache
il2cpp.exe didn't catch exception: System.AggregateException: One or more errors occurred. ---> System.ComponentModel.Win32Exception: The specified executable is not a valid application for this OS platform.
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at Unity.IL2CPP.Shell.Execute(ExecuteArgs executeArgs, IExecuteController controller)
   at Unity.IL2CPP.Building.CppProgramBuilder.ProvideObjectFile(IntermediateObjectFileCompilationData data)
   at Unity.IL2CPP.Building.ParallelFor.c__DisplayClass1_0`2.b__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, IBuildStatisticsCollector statisticsCollector)
   at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
   at il2cpp.Program.DoRun(String[] args)
   at il2cpp.Program.Run(String[] args)
   at il2cpp.Program.Main(String[] args)
---> (Inner Exception #0) System.ComponentModel.Win32Exception (0x80004005): The specified executable is not a valid application for this OS platform.
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at Unity.IL2CPP.Shell.Execute(ExecuteArgs executeArgs, IExecuteController controller)
   at Unity.IL2CPP.Building.CppProgramBuilder.ProvideObjectFile(IntermediateObjectFileCompilationData data)
   at Unity.IL2CPP.Building.ParallelFor.c__DisplayClass1_0`2.b__0(Object o) (Inner Exception #1) System.ComponentModel.Win32Exception (0x80004005): The specified executable is not a valid application for this OS platform.
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at Unity.IL2CPP.Shell.Execute(ExecuteArgs executeArgs, IExecuteController controller)
   at Unity.IL2CPP.Building.CppProgramBuilder.ProvideObjectFile(IntermediateObjectFileCompilationData data)
   at Unity.IL2CPP.Building.ParallelFor.c__DisplayClass1_0`2.b__0(Object o) (Inner Exception #2) System.ComponentModel.Win32Exception (0x80004005): The specified executable is not a valid application for this OS platform.
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at Unity.IL2CPP.Shell.Execute(ExecuteArgs executeArgs, IExecuteController controller)
   at Unity.IL2CPP.Building.CppProgramBuilder.ProvideObjectFile(IntermediateObjectFileCompilationData data)
   at Unity.IL2CPP.Building.ParallelFor.c__DisplayClass1_0`2.b__0(Object o) (Inner Exception #3) System.ComponentModel.Win32Exception (0x80004005): The specified executable is not a valid application for this OS platform.
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at Unity.IL2CPP.Shell.Execute(ExecuteArgs executeArgs, IExecuteController controller)
   at Unity.IL2CPP.Building.CppProgramBuilder.ProvideObjectFile(IntermediateObjectFileCompilationData data)
   at Unity.IL2CPP.Building.ParallelFor.c__DisplayClass1_0`2.b__0(Object o) (Inner Exception #4) System.ComponentModel.Win32Exception (0x80004005): The specified executable is not a valid application for this OS platform.
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at Unity.IL2CPP.Shell.Execute(ExecuteArgs executeArgs, IExecuteController controller)
   at Unity.IL2CPP.Building.CppProgramBuilder.ProvideObjectFile(IntermediateObjectFileCompilationData data)
   at Unity.IL2CPP.Building.ParallelFor.c__DisplayClass1_0`2.b__0(Object o) (Inner Exception #5) System.ComponentModel.Win32Exception (0x80004005): The specified executable is not a valid application for this OS platform.
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at Unity.IL2CPP.Shell.Execute(ExecuteArgs executeArgs, IExecuteController controller)
   at Unity.IL2CPP.Building.CppProgramBuilder.ProvideObjectFile(IntermediateObjectFileCompilationData data)
   at Unity.IL2CPP.Building.ParallelFor.c__DisplayClass1_0`2.b__0(Object o) (Inner Exception #6) System.ComponentModel.Win32Exception (0x80004005): The specified executable is not a valid application for this OS platform.
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at Unity.IL2CPP.Shell.Execute(ExecuteArgs executeArgs, IExecuteController controller)
   at Unity.IL2CPP.Building.CppProgramBuilder.ProvideObjectFile(IntermediateObjectFileCompilationData data)
   at Unity.IL2CPP.Building.ParallelFor.c__DisplayClass1_0`2.b__0(Object o) (Inner Exception #7) System.ComponentModel.Win32Exception (0x80004005): The specified executable is not a valid application for this OS platform.
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at Unity.IL2CPP.Shell.Execute(ExecuteArgs executeArgs, IExecuteController controller)
   at Unity.IL2CPP.Building.CppProgramBuilder.ProvideObjectFile(IntermediateObjectFileCompilationData data)
   at Unity.IL2CPP.Building.ParallelFor.c__DisplayClass1_0`2.b__0(Object o) System.ComponentModel.Win32Exception: The specified executable is not a valid application for this OS platform.
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at Unity.IL2CPP.Shell.Execute(ExecuteArgs executeArgs, IExecuteController controller)
   at Unity.IL2CPP.Building.CppProgramBuilder.ProvideObjectFile(IntermediateObjectFileCompilationData data)
   at Unity.IL2CPP.Building.ParallelFor.c__DisplayClass1_0`2.b__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, IBuildStatisticsCollector statisticsCollector)
   at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
   at il2cpp.Program.DoRun(String[] args)
   at il2cpp.Program.Run(String[] args)
   at il2cpp.Program.Main(String[] args)

UnityEngine.Debug:LogError(Object)
UnityEditorInternal.Runner:RunProgram(Program, String, String, String, CompilerOutputParserBase) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:126)
UnityEditorInternal.Runner:RunManagedProgram(String, String, String, CompilerOutputParserBase, Action`1) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:71)
UnityEditorInternal.IL2CPPBuilder:RunIl2CppWithArguments(List`1, Action`1, String) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:503)
UnityEditorInternal.IL2CPPBuilder:ConvertPlayerDlltoCpp(String, String, String, Boolean) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:484)
UnityEditorInternal.IL2CPPBuilder:Run() (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:334)
UnityEditorInternal.IL2CPPUtils:RunIl2Cpp(String, String, IIl2CppPlatformProvider, Action`1, RuntimeClassRegistry) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:63)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

android
windows
unity3d
build-error
asked on Stack Overflow Oct 26, 2019 by Sergey

2 Answers

0

Built-in unity ndk itself is buggy, you need to install a stable version from google android developer page: Android NDK, Revision 16b (December 2017).

answered on Stack Overflow Oct 27, 2019 by 0xBFE1A8
0

I tried installing/reinstalling all kind of android tools, Unity editor, Visual Studio (yet I didn't try reinstalling Windows :). Finally, trying to solve another problem I tried to change Edit -> Project Settings -> Player -> Other Settings -> Configuration -> Scripting Backed, it changed it from IL2CCP to Mono and it cured my building errors (and building process got faster).

I still don't know why I'm the only one from the project team who has to deal with this issue when IL2CCP is selected, but at least now I can debug the project.

If you are interested in what is the difference between and here are good answers on this topic.

answered on Stack Overflow Nov 2, 2019 by Sergey

User contributions licensed under CC BY-SA 3.0