From c6211c414a2947971d2fe196aba662191d39e448 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Fri, 7 Aug 2026 13:41:55 -0500 Subject: [PATCH] [Xamarin.Android.Build.Tasks] Use resolved NDK for AOT The AOT targets pass the public $(AndroidNdkDirectory) property directly to . When that property is unset but ResolveSdks finds an NDK through the configured development environment, AOT incorrectly behaves as if no NDK was found. Pass the resolved $(_AndroidNdkDirectory) value consistently and document the public property used to override NDK discovery. Fixes: https://github.com/dotnet/android/issues/7599 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0f915802-edea-4418-8313-f642a6da9c55 --- .../docs-mobile/building-apps/build-properties.md | 13 +++++++++++++ .../targets/Microsoft.Android.Sdk.Aot.targets | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Documentation/docs-mobile/building-apps/build-properties.md b/Documentation/docs-mobile/building-apps/build-properties.md index e5f00d45b4b..13a13a880ee 100644 --- a/Documentation/docs-mobile/building-apps/build-properties.md +++ b/Documentation/docs-mobile/building-apps/build-properties.md @@ -964,6 +964,19 @@ If you are getting this error you can add the following to the which will allow the `dx` step to succeed. +## AndroidNdkDirectory + +The `$(AndroidNdkDirectory)` property specifies a custom Android NDK +installation directory. The path can be set in the project file or on the +command line: + +```dotnetcli +dotnet build -p:AndroidNdkDirectory=/path/to/android-ndk +``` + +If this property is not set, .NET for Android locates the NDK from the +configured Android development environment. + ## AndroidPackageFormat An enum-style property with valid diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.Aot.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.Aot.targets index 2a214899948..b7b6d277209 100644 --- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.Aot.targets +++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.Aot.targets @@ -90,7 +90,7 @@ They run in a context of an inner build with a single $(RuntimeIdentifier).