Unity2021.2.7f1 with android studio build ndk error

Run on Mac M1 max
Failed to build Unity2021.2.7f1 android project using Android Studio 2020.3.1

Build failed with 0 successful nodes and 0 failed ones
Error: Internal build system error. BuildProgram exited with code 1.
Unity.IL2CPP.Bee.BuildLogic.ToolchainNotFoundException: IL2CPP C++ code builder is unable to build C++ code. In order to build C++ code for Android, you must have the following NDK version installed:
* Android NDK v21d

Unable to detect any compatible Android NDK installation!
* Found Android NDK installation at "/Applications/Unity/Hub/Editor/2021.2.7f1/PlaybackEngines/AndroidPlayer/SDK/ndk/android-ndk-r21d" but building is not supported on this host

The correct Android NDK can be installed through Unity Hub.


   at Unity.IL2CPP.Bee.BuildLogic.Android.AndroidBuildLogic.UserAvailableToolchainFor(Architecture architecture, NPath toolChainPath, NPath sysRootPath) in /Users/bokken/build/output/unity/il2cpp/Bee/Unity.IL2CPP.Bee.BuildLogic.Android/AndroidBuildLogic.cs:line 159
   at Unity.IL2CPP.Bee.IL2CPPExeCompileCppBuildProgram.BuildProgram.Main(String[] args, String currentDirectory) in Unity.IL2CPP.Bee.IL2CPPExeCompileCppBuildProgram.dll:token 0x6000002+0x0
   at il2cpp.Compilation.InProcessBuildProgram.StartImpl(String workingDirectory, String[] arguments) in /Users/bokken/build/output/unity/il2cpp/il2cpp/Compilation/InProcessBuildProgram.cs:line 51


Error: Unity.IL2CPP.Building.BuilderFailedException: Build failed with 0 successful nodes and 0 failed ones
Error: Internal build system error. BuildProgram exited with code 1.
Unity.IL2CPP.Bee.BuildLogic.ToolchainNotFoundException: IL2CPP C++ code builder is unable to build C++ code. In order to build C++ code for Android, you must have the following NDK version installed:
* Android NDK v21d

Unable to detect any compatible Android NDK installation!
* Found Android NDK installation at "/Applications/Unity/Hub/Editor/2021.2.7f1/PlaybackEngines/AndroidPlayer/SDK/ndk/android-ndk-r21d" but building is not supported on this host

The correct Android NDK can be installed through Unity Hub.


   at Unity.IL2CPP.Bee.BuildLogic.Android.AndroidBuildLogic.UserAvailableToolchainFor(Architecture architecture, NPath toolChainPath, NPath sysRootPath) in /Users/bokken/build/output/unity/il2cpp/Bee/Unity.IL2CPP.Bee.BuildLogic.Android/AndroidBuildLogic.cs:line 159
   at Unity.IL2CPP.Bee.IL2CPPExeCompileCppBuildProgram.BuildProgram.Main(String[] args, String currentDirectory) in Unity.IL2CPP.Bee.IL2CPPExeCompileCppBuildProgram.dll:token 0x6000002+0x0
   at il2cpp.Compilation.InProcessBuildProgram.StartImpl(String workingDirectory, String[] arguments) in /Users/bokken/build/output/unity/il2cpp/il2cpp/Compilation/InProcessBuildProgram.cs:line 51


   at il2cpp.Program.DoRun(String[] args, RuntimePlatform platform, Il2CppCommandLineArguments il2CppCommandLineArguments, BuildingOptions buildingOptions, Boolean throwExceptions) in /Users/bokken/build/output/unity/il2cpp/il2cpp/Program.cs:line 331

Bug report case id: 1392400

Same with me on M1, Unity2021.2.7f1 (silicon).
Not work even using both NDK https://dl.google.com/android/repository/android-ndk-r21d-darwin-aarch64.zip and
https://dl.google.com/android/repository/android-ndk-r21d-darwin-x86_64.zip

Same problem here on M1 Max. Unity 2021.2.7f1

Same on M1, Unity 2021.2.8f1.

Same on M1, Unity 2021.2.8f1. Tried replacing the NDK folder with a new 21d install and same thing.

Same problem with M1. Has anyone fixed it?

Same on M1, tried with Unity 2021.2.12f1.

Same problem on M1 (Unity 2021.2.13f1)

Same problem on M1 (Unity 2021.2.13f1)

Same problem with M1 pro(Unity 2021.2.14). Has anyone fixed it?

Same on M1, I tried 2020.3.30f1, 2021.2.16f1, 2022.1.0.b13, every Silicon version have that issue, Intel ones are fine.

Is there a bug report somewhere we can follow?

zzzzzz same problem.

same here… any fix ?

seems this bug exists in the first M1 version, not sure why it was not fixed for a long time. See #306 Now Available - Native Apple Silicon Editor Preview Builds page-7

A few moment later. 2021.2.18f1 same.

Fixed on Unity 2021.3f1

Same issue in Unity2021.3f1

1 Like

Same issue in Unity 2021.3.2f1 and Unity 2022.1.0f1 (Silicon version)

Same issue in Unity 2021.2.3f1c1 (Silicon version)

Same issue in Unity 2021.2.31f1c1 (Silicon version)