Can not build to Android with backend Il2cpp

I’m trying to build apk with backend il2cpp as it’s recently required by Google play console for 64 bit compatibility , however I’m getting this error message, can any one please provide help

Error messages:

Exception: C:\Program Files\Unity\Hub\Editor\2019.1.4f1\Editor\Data\il2cpp/build/il2cpp.exe did not run properly!
UnityEditorInternal.Runner.RunProgram (UnityEditor.Utils.Program p, System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:130)
UnityEditorInternal.Runner.RunManagedProgram (System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser, System.Action1[T] setupStartInfo) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:73) UnityEditorInternal.IL2CPPBuilder.RunIl2CppWithArguments (System.Collections.Generic.List1[T] arguments, System.Action1[T] setupStartInfo, System.String workingDirectory) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:496) UnityEditorInternal.IL2CPPBuilder.ConvertPlayerDlltoCpp (System.String inputDirectory, System.String outputDirectory, System.String workingDirectory, System.Boolean platformSupportsManagedDebugging) (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 (System.String tempFolder, System.String stagingAreaData, UnityEditorInternal.IIl2CppPlatformProvider platformProvider, System.Action1[T] modifyOutputBeforeCompile, UnityEditor.RuntimeClassRegistry runtimeClassRegistry) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:63)
UnityEditor.Android.PostProcessor.Tasks.RunIl2Cpp.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <563f4bbc342a4b6b88ae70c46cea610c>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <563f4bbc342a4b6b88ae70c46cea610c>:0)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <563f4bbc342a4b6b88ae70c46cea610c>:0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <563f4bbc342a4b6b88ae70c46cea610c>:0)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:281)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

Second error message:

Failed running C:\Program Files\Unity\Hub\Editor\2019.1.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=“E:\Work\Unity project\Projects\INERTIA FINAL01\Temp\StagingArea\assets\bin\Data\Native\armeabi-v7a\libil2cpp.so” --cachedirectory=“E:\Work\Unity project\Projects\INERTIA FINAL01\Assets..\Library\il2cpp_android_armeabi-v7a/il2cpp_cache” --additional-include-directories=“C:\Program Files\Unity\Hub\Editor\2019.1.4f1\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\bdwgc/include” --additional-include-directories=“C:\Program Files\Unity\Hub\Editor\2019.1.4f1\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\libil2cpp/include” --tool-chain-path=“C:/Program Files/Unity/Hub/Editor/2019.1.4f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK” --profiler-report --map-file-parser=“C:/Program Files/Unity/Hub/Editor/2019.1.4f1/Editor/Data/Tools/MapFileParser/MapFileParser.exe” --directory=“E:/Work/Unity project/Projects/INERTIA FINAL01/Temp/StagingArea/assets/bin/Data/Managed” --generatedcppdir=“E:/Work/Unity project/Projects/INERTIA FINAL01/Temp/StagingArea/Il2Cpp/il2cppOutput”

stdout:
il2cpp.exe didn’t catch exception: System.Exception: Android NDK r13b or newer not detected at ‘C:\Program Files\Unity\Hub\Editor\2019.1.4f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK’.
at Unity.IL2CPP.Building.ToolChains.Android.AndroidNDKUtilities…ctor(NPath ndkRootPath, Architecture architecture, Boolean useDependenciesToolChain)
at Unity.IL2CPP.Building.ToolChains.AndroidToolChain…ctor(Architecture architecture, BuildConfiguration buildConfiguration, Boolean treatWarningsAsErrors, Boolean assemblyOutput, Boolean useDependenciesToolChain, NPath toolchainPath)
at Unity.IL2CPP.Building.Platforms.AndroidPlatformSupport.MakeCppToolChain(BuildingOptions buildingOptions)
at il2cpp.Program.DoRun(String args)
at il2cpp.Program.Run(String args)
at il2cpp.Program.Main(String args)
stderr:

Unhandled Exception: System.Exception: Android NDK r13b or newer not detected at ‘C:\Program Files\Unity\Hub\Editor\2019.1.4f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK’.
at Unity.IL2CPP.Building.ToolChains.Android.AndroidNDKUtilities…ctor(NPath ndkRootPath, Architecture architecture, Boolean useDependenciesToolChain)
at Unity.IL2CPP.Building.ToolChains.AndroidToolChain…ctor(Architecture architecture, BuildConfiguration buildConfiguration, Boolean treatWarningsAsErrors, Boolean assemblyOutput, Boolean useDependenciesToolChain, NPath toolchainPath)
at Unity.IL2CPP.Building.Platforms.AndroidPlatformSupport.MakeCppToolChain(BuildingOptions buildingOptions)
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, Action1) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:73) UnityEditorInternal.IL2CPPBuilder:RunIl2CppWithArguments(List1, Action1, 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, Action1, RuntimeClassRegistry) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:63)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

Just resolved this one myself. I had to untoggle x86 Target Architecture in Player Settings → Other Settings. Someone mentioned getting updated NDK or split APKs by target architecture if you have to build x86 still. In my case I did not.

Same here,
I’ve tried for a few days now to get a working ARM64 build - using many different version of Unity/PK/SDK combinations

I’ve tried the following:
Stages:
NOTE: RUN UNITY HUB AS ADMIN - if you don’t get a ‘give permissions confirmation screen’ Run Unity directly as admin from it’s location.
NOTE: Unity 2018.2.1f1 Requires version 28 of SDK, r16b of NDK and JDK 1.8 (Version 8, Default loc: C:\Program Files\Java\jdk1.8.0_221)
NOTE: Delete Plugins folder in assets if you have used it, this causes a build location error for some reason…(Unable to build In unity : "UnityEditor.BuildPlayerWindow+BuildMethodException:" - Stack Overflow)
NOTE: Delete all .sln files in the UnityProject (Build Fail - Unity 2018.3.0b9 - Questions & Answers - Unity Discussions)
NOTE: Delete .vs folder (Hidden)
NOTE: Make sure build output location is as simple as possible, recommmend root C/D drive
NOTE: Make sure Gradle build is selected in player settings, less than this will cause errors
NOTE: Mya be advisable to set Minify options under player settings to None
NOTE: Make sure you uninstall packages that prevent a build such as :
NUnit
Unity Collaborate
Test Framework

NOTE: If build failure still, try deleting Library directory - it will be rebuilt considering above changes