Skip to content

Commit 02f7ae7

Browse files
committed
[NDK] Properly detect 64-bit NDK
The code detecting whether an instance of NDK is a 64-bit one assumed that the GNU binutils paths existed below the toolchains dir and used them to check whether the 64-bit platform directory exists under them in order to determine if the NDK is a 64-bit one. NDK r23, however, will remove the GNU binutils completely and those paths no longer exist. Add a check for the `toolchains/llvm/prebuilt/[PLATFORM]` directory existence before the older check so that detection works correctly for NDK r23+.
1 parent 623332d commit 02f7ae7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Xamarin.Android.Tools.AndroidSdk/Sdks/AndroidSdkBase.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ public virtual void Initialize (string? androidSdkPath = null, string? androidNd
8787
if (!string.IsNullOrEmpty (AndroidNdkPath)) {
8888
// It would be nice if .NET had real globbing support in System.IO...
8989
string toolchainsDir = Path.Combine (AndroidNdkPath, "toolchains");
90-
if (Directory.Exists (toolchainsDir)) {
90+
string llvmNdkToolchainDir = Path.Combine (toolchainsDir, "llvm", "prebuilt", NdkHostPlatform64Bit);
91+
92+
if (Directory.Exists (llvmNdkToolchainDir)) {
93+
IsNdk64Bit = true;
94+
} else if (Directory.Exists (toolchainsDir)) {
9195
IsNdk64Bit = Directory.EnumerateDirectories (toolchainsDir, "arm-linux-androideabi-*")
9296
.Any (dir => Directory.Exists (Path.Combine (dir, "prebuilt", NdkHostPlatform64Bit)));
9397
}

0 commit comments

Comments
 (0)