Error while building Android x64 using IL2CPP.

Hello, I’m new to unity and I’ve tried to build my game to support x64 devices.
However I get an error from IL2CPP.

Error Log:

Failed running C:\Program Files\Unity\Hub\Editor\2019.1.7f1\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="C:\Users\Hamza Hathoute\Desktop\Unity\Projects\PathGame\Temp\StagingArea\assets\bin\Data\Native\armeabi-v7a\libil2cpp.so" --cachedirectory="C:\Users\Hamza Hathoute\Desktop\Unity\Projects\PathGame\Assets\..\Library\il2cpp_android_armeabi-v7a/il2cpp_cache" --additional-include-directories="C:\Program Files\Unity\Hub\Editor\2019.1.7f1\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\bdwgc/include" --additional-include-directories="C:\Program Files\Unity\Hub\Editor\2019.1.7f1\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\libil2cpp/include" --tool-chain-path="C:/Program Files/Unity/Hub/Editor/2019.1.7f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK" --profiler-report --map-file-parser="C:/Program Files/Unity/Hub/Editor/2019.1.7f1/Editor/Data/Tools/MapFileParser/MapFileParser.exe" --directory="C:/Users/Hamza Hathoute/Desktop/Unity/Projects/PathGame/Temp/StagingArea/assets/bin/Data/Managed" --generatedcppdir="C:/Users/Hamza Hathoute/Desktop/Unity/Projects/PathGame/Temp/StagingArea/Il2Cpp/il2cppOutput"

stdout:

Building libil2cpp.so with AndroidToolChain

    Output directory: C:\Users\Hamza Hathoute\Desktop\Unity\Projects\PathGame\Temp\StagingArea\assets\bin\Data\Native\armeabi-v7a

    Cache directory: C:\Users\Hamza Hathoute\Desktop\Unity\Projects\PathGame\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)<---



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)

I must include that I’ve searched on the internet for a long time but couldn’t find anything. Thank you for your help.

To be clear, by x64 (which usually means Intel, 64-bit), do you really mean ARM64? Unity does not support building for Android for x64, but we do support ARM64.

Assuming that you mean ARM64, it looks like this error is related to the Android NDK installation. You will need to make sure you have a proper Android NDK installation for build for ARM64. Please check the Preferences dialog in the Unity Editor to determine which NDK version should be installed. Then you can install that NDL version from Google and point the Unity editor to the path to that NDK.

Also, not that you can find documentation about how to install the Android SDK and NDK here: Unity - Manual: Android environment setup

I am sorry Josh, I mean ARM64 (which I confused for x64 for a long time).
Thank you for your reply, I will try to reinstall NDK since the one I have was installed with the SDK from Unity Hub.

Indeed, after downloading NDK r16b and changing the NDK directory in Preferences. The build was successful.
Thank you Josh again!

i coudn’t do it. i got an error saying unity doesn’t support ndk r16b. I don’t know what to do? any help??

That will depend on the version of Unity you are using. See this documentation to determine which version of the NDK you would use for a given version of Unity: https://docs.unity3d.com/Manual/android-sdksetup.html