Android Build with il2cpp failed: The specified executable is not a valid application for this OS platform.
Hi! I am not sure if this is the correct place to post this, but I have scoured the internet and all of the different forum post related to this. Please have some patience, because part of the problem is that I lack the technical skills to completely understand how to debug the issue and follow the instructions given. I have also inherited the code base, so there might be aspects of the code that causes issues, but I cant see them intuitively.
The issue is that when building for android using il2cpp, the build fails with the following error message: System.ComponentModel.Win32Exception: The specified executable is not a valid application for this OS platform (Including full output at the end of the post)
I am trying to build with Unity 2019.1.10 and 2019.1.11f - I can on request try to build on a newer version of Unity, but last time i managed to complete a build was on the 2019.1.10f version, so I have reverted the project to that state to see if i could manage to make a build at all.
Some of the things that i have investigated: I tried to make a build using mono, mono worked.
I have tried to see if the is an issue with NDK install location - I have met a blocker here, because I do not know how to check this. What i have done is install android build support through Unity hub (for unity 2019.1.10f). And also through the in editor prompt when trying to switch to a target platform that you lack the build tools for (using unity 2019.1.11f). In the latter case, Hub does not mark the Unity version as having the android module installed
I am running windows 10.
I am unable to share a complete copy of the project.
output:
Failed running C:\Program Files\Unity\Hub\Editor\2019.1.10f1\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:\Development\ProjectName\Temp\StagingArea\assets\bin\Data\Native\armeabi-v7a\libil2cpp.so" --cachedirectory="D:\Development\ProjectName\Assets\..\Library\il2cpp_android_armeabi-v7a/il2cpp_cache" --additional-include-directories="C:\Program Files\Unity\Hub\Editor\2019.1.10f1\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\bdwgc/include" --additional-include-directories="C:\Program Files\Unity\Hub\Editor\2019.1.10f1\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\libil2cpp/include" --tool-chain-path="C:/Program Files/Unity/Hub/Editor/2019.1.10f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK" --incremental-g-c-time-slice=3 --profiler-report --map-file-parser="C:/Program Files/Unity/Hub/Editor/2019.1.10f1/Editor/Data/Tools/MapFileParser/MapFileParser.exe" --directory="D:/Development/ProjectName/Temp/StagingArea/assets/bin/Data/Managed" --generatedcppdir="D:/Development/ProjectName/Temp/StagingArea/Il2Cpp/il2cppOutput"
stdout:
Building libil2cpp.so with AndroidToolChain
Output directory: D:\Development\ProjectName\Temp\StagingArea\assets\bin\Data\Native\armeabi-v7a
Cache directory: D:\Development\ProjectName\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.<RunWithResult>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.<RunWithResult>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.<RunWithResult>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.<RunWithResult>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.<RunWithResult>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.<RunWithResult>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.<RunWithResult>b__0(Object o)<---
stderr:
Unhandled 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.<RunWithResult>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:128)
UnityEditorInternal.Runner:RunManagedProgram(String, String, String, CompilerOutputParserBase, Action`1) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:73)
UnityEditorInternal.IL2CPPBuilder:RunIl2CppWithArguments(List`1, Action`1, String) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:496)
UnityEditorInternal.IL2CPPBuilder:ConvertPlayerDlltoCpp(String, String, String, Boolean) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:477)
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)
Answer by JoshPeterson · May 12, 2020 at 11:27 AM
My best guess is that you have installed the Android NDK tools for macOS or Linux instead of the Android NDK tools for Windows.
You can find Unity's documentation about the Android NDK here: https://docs.unity3d.com/Manual/android-sdksetup.html
I would recommend you install a fresh version of Unity and use the Unity Hub to install the NDK. Then create a new, empty project for Android and see is that will build. If that builds correctly, then you can go back to this project with that working version of Unity and try it.
Your answer
Follow this Question
Related Questions
Failed running Android build with il2CPP with Unity 2019.2.11f1 2 Answers
Can't Build with IL2CPP for Android after 2018.3.0 Update(Empty Project) 1 Answer
Android Build Error because of no certificate?? 0 Answers
il2cpp android build error 2019.2.19f1 1 Answer
Why is IL2CPP hanging or taking so long to finish? 8 hours in. 0 Answers