diff --git a/build-tools/create-packs/Microsoft.Android.Runtime.proj b/build-tools/create-packs/Microsoft.Android.Runtime.proj
index d20f8f00eaa..cfb62c05183 100644
--- a/build-tools/create-packs/Microsoft.Android.Runtime.proj
+++ b/build-tools/create-packs/Microsoft.Android.Runtime.proj
@@ -115,6 +115,7 @@ projects that use the Microsoft.Android.Runtimes framework in .NET 6+.
+
<_AndroidRuntimePackAssemblies Include="$(_MonoAndroidNETOutputRoot)$(AndroidLatestStableApiLevel)\Microsoft.Android.Runtime.NativeAOT.dll" />
diff --git a/build-tools/scripts/Ndk.projitems b/build-tools/scripts/Ndk.projitems
index 3dd66262b97..025c62ac4d9 100644
--- a/build-tools/scripts/Ndk.projitems
+++ b/build-tools/scripts/Ndk.projitems
@@ -24,7 +24,7 @@
android-arm
True
True
- False
+ True
@ANDROID_PACK_VERSION_LONG@
@ANDROID_PACK_VERSION_LONG@
+ @MICROSOFT_NETCORE_APP_REF_PACKAGE_VERSION@
<_AndroidLatestStableApiLevel>@ANDROID_LATEST_STABLE_API_LEVEL@
<_AndroidLatestUnstableApiLevel>@ANDROID_LATEST_UNSTABLE_API_LEVEL@
diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.NativeAOT.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.NativeAOT.targets
index e145c311485..96835c928c8 100644
--- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.NativeAOT.targets
+++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.NativeAOT.targets
@@ -22,7 +22,7 @@ This file contains the NativeAOT-specific MSBuild logic for .NET for Android.
true
true
-
+
<_IsPublishing Condition=" '$(_IsPublishing)' == '' ">true
@@ -35,6 +35,19 @@ This file contains the NativeAOT-specific MSBuild logic for .NET for Android.
true
+
+
+
+ $(MicrosoftNETCoreAppRefPackageVersion)
+
+ <_AndroidNetCoreAppNativeAotKnownRuntimePack Include="@(KnownRuntimePack->WithMetadataValue('Identity', 'Microsoft.NETCore.App')->WithMetadataValue('RuntimePackLabels', 'NativeAOT'))" />
+
+
+ $(MicrosoftNETCoreAppRefPackageVersion)
+ %(RuntimePackRuntimeIdentifiers);android-arm
+
+
+
true
@@ -90,9 +103,16 @@ This file contains the NativeAOT-specific MSBuild logic for .NET for Android.
<_NdkAbi Condition=" '$(RuntimeIdentifier)' == 'android-arm64' ">aarch64
<_NdkAbi Condition=" '$(RuntimeIdentifier)' == 'android-x64' ">x86_64
+ <_NdkAbi Condition=" '$(RuntimeIdentifier)' == 'android-arm' ">arm
<_NDKApiLevel Condition=" '$(RuntimeIdentifier)' == 'android-arm64' ">$(AndroidNdkApiLevel_Arm64)
<_NDKApiLevel Condition=" '$(RuntimeIdentifier)' == 'android-x64' ">$(AndroidNdkAPiLevel_X64)
- <_NdkSysrootAbi>$(_NdkAbi)-linux-android
+ <_NDKApiLevel Condition=" '$(RuntimeIdentifier)' == 'android-arm' ">$(AndroidNdkApiLevel_Arm)
+ <_NdkClangPrefix Condition=" '$(RuntimeIdentifier)' == 'android-arm64' ">aarch64-linux-android
+ <_NdkClangPrefix Condition=" '$(RuntimeIdentifier)' == 'android-x64' ">x86_64-linux-android
+ <_NdkClangPrefix Condition=" '$(RuntimeIdentifier)' == 'android-arm' ">armv7a-linux-androideabi
+ <_NdkSysrootAbi Condition=" '$(RuntimeIdentifier)' == 'android-arm64' ">aarch64-linux-android
+ <_NdkSysrootAbi Condition=" '$(RuntimeIdentifier)' == 'android-x64' ">x86_64-linux-android
+ <_NdkSysrootAbi Condition=" '$(RuntimeIdentifier)' == 'android-arm' ">arm-linux-androideabi
<_NdkPrebuiltAbi Condition=" $([MSBuild]::IsOSPlatform('windows')) ">windows-x86_64
<_NdkPrebuiltAbi Condition=" $([MSBuild]::IsOSPlatform('osx')) ">darwin-x86_64
<_NdkPrebuiltAbi Condition=" $([MSBuild]::IsOSPlatform('linux')) ">linux-x86_64
@@ -128,8 +148,8 @@ This file contains the NativeAOT-specific MSBuild logic for .NET for Android.
application. If, for some reason, `clang++` has to be used, `` need to be
added to pass `-nostdlib` to it.
-->
- $(_NdkAbi)-linux-android$(_NDKApiLevel)-clang$(_NdkWrapperScriptExt)
- $(_NdkAbi)-linux-android$(_NDKApiLevel)-clang$(_NdkWrapperScriptExt)
+ $(_NdkClangPrefix)$(_NDKApiLevel)-clang$(_NdkWrapperScriptExt)
+ $(_NdkClangPrefix)$(_NDKApiLevel)-clang$(_NdkWrapperScriptExt)
llvm-objcopy
@@ -214,6 +234,7 @@ This file contains the NativeAOT-specific MSBuild logic for .NET for Android.
+ <_PrivateBuildTargetAbi Condition=" '$(RuntimeIdentifier)' == 'android-arm' " Include="armeabi-v7a" />
<_PrivateBuildTargetAbi Condition=" '$(RuntimeIdentifier)' == 'android-arm64' " Include="arm64-v8a" />
<_PrivateBuildTargetAbi Condition=" '$(RuntimeIdentifier)' == 'android-x64' " Include="x86_64" />
@@ -361,6 +382,10 @@ This file contains the NativeAOT-specific MSBuild logic for .NET for Android.
<_NativeAotSystemLibraries Include="m" />
<_NativeAotSystemLibraries Include="c" />
+
+ <_NativeAotLinkLibraries Remove="$(IlcSdkPath)libSystem.Security.Cryptography.Native.Android.a" />
+ <_NativeAotLinkLibraries Include="$(_NativeAotRuntimePackNativeDir)libSystem.Security.Cryptography.Native.Android.a" />
+
diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.NET.Sdk.Android/WorkloadManifest.in.json b/src/Xamarin.Android.Build.Tasks/Microsoft.NET.Sdk.Android/WorkloadManifest.in.json
index 5de67dcdf60..6a3a324bc61 100644
--- a/src/Xamarin.Android.Build.Tasks/Microsoft.NET.Sdk.Android/WorkloadManifest.in.json
+++ b/src/Xamarin.Android.Build.Tasks/Microsoft.NET.Sdk.Android/WorkloadManifest.in.json
@@ -15,6 +15,7 @@
"Microsoft.Android.Runtime.CoreCLR.37.android-arm",
"Microsoft.Android.Runtime.CoreCLR.37.android-arm64",
"Microsoft.Android.Runtime.CoreCLR.37.android-x64",
+ "Microsoft.Android.Runtime.NativeAOT.37.android-arm",
"Microsoft.Android.Runtime.NativeAOT.37.android-arm64",
"Microsoft.Android.Runtime.NativeAOT.37.android-x64",
"Microsoft.Android.Templates"
@@ -91,6 +92,10 @@
"kind": "framework",
"version": "@WORKLOAD_VERSION@"
},
+ "Microsoft.Android.Runtime.NativeAOT.37.android-arm": {
+ "kind": "framework",
+ "version": "@WORKLOAD_VERSION@"
+ },
"Microsoft.Android.Runtime.NativeAOT.37.android-arm64": {
"kind": "framework",
"version": "@WORKLOAD_VERSION@"
diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/NativeAotBuildTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/NativeAotBuildTests.cs
index 1c176bec323..9f1cfab9198 100644
--- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/NativeAotBuildTests.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/NativeAotBuildTests.cs
@@ -1,3 +1,5 @@
+using System.IO;
+
using NUnit.Framework;
using Xamarin.Android.Tasks;
using Xamarin.ProjectTools;
@@ -11,6 +13,35 @@ namespace Xamarin.Android.Build.Tests
[Category ("Node-2")]
public class NativeAotBuildTests : BaseTest
{
+ [Test]
+ public void RestoreNativeAot_AndroidArmRuntimePack ()
+ {
+ var proj = new XamarinAndroidApplicationProject {
+ IsRelease = true,
+ };
+ proj.SetRuntime (AndroidRuntime.NativeAOT);
+ proj.SetRuntimeIdentifiers (["armeabi-v7a"]);
+
+ using var builder = CreateApkBuilder ();
+ Assert.IsTrue (
+ builder.RunTarget (proj, "Restore"),
+ "Restore should succeed for android-arm."
+ );
+
+ var intermediate = Path.Combine (Root, builder.ProjectDirectory, proj.IntermediateOutputPath);
+ var assets = File.ReadAllText (Path.Combine (intermediate, "..", "project.assets.json"));
+ StringAssert.Contains (
+ "\"Microsoft.NETCore.App.Runtime.NativeAOT.android-arm\"",
+ assets,
+ "Restore should select the android-arm NativeAOT runtime pack."
+ );
+ StringAssert.DoesNotContain (
+ "\"Microsoft.NETCore.App.Runtime.NativeAOT.linux-bionic-arm\"",
+ assets,
+ "Restore should not fall back to the linux-bionic-arm NativeAOT runtime pack."
+ );
+ }
+
[Test]
public void BuildNativeAot_WithoutNdk ()
{
@@ -44,6 +75,25 @@ public void BuildNativeAot_WithNdkLinker ()
);
}
+ [Test]
+ public void BuildNativeAot_AndroidArm_WithNdkLinker ()
+ {
+ var proj = new XamarinAndroidApplicationProject {
+ IsRelease = true,
+ };
+ proj.SetRuntime (AndroidRuntime.NativeAOT);
+ proj.SetRuntimeIdentifiers (["armeabi-v7a"]);
+ proj.SetProperty ("_SkipNdkResolution", "false");
+
+ using var builder = CreateApkBuilder ();
+ Assert.IsTrue (
+ builder.Build (proj, parameters: [
+ "_AndroidUseWorkloadNativeLinker=false",
+ ]),
+ "android-arm build should succeed with NDK linker."
+ );
+ }
+
[Test]
public void BuildNativeAot_WithoutNdk_WorkloadLinkerDisabled_Fails ()
{
diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets
index 6c562f5378c..ce4332b110e 100644
--- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets
+++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets
@@ -284,6 +284,7 @@
<_BundledVersionsCacheLines Include="AndroidLatestUnstableApiLevel=$(AndroidLatestUnstableApiLevel)" />
<_BundledVersionsCacheLines Include="DotNetTargetFramework=$(DotNetTargetFramework)" />
<_BundledVersionsCacheLines Include="DotNetTargetFrameworkVersion=$(DotNetTargetFrameworkVersion)" />
+ <_BundledVersionsCacheLines Include="MicrosoftNETCoreAppRefPackageVersion=$(MicrosoftNETCoreAppRefPackageVersion)" />
+ Replacements="@ANDROID_PACK_VERSION_LONG@=$(AndroidPackVersionLong);@ANDROID_LATEST_STABLE_API_LEVEL@=$(AndroidLatestStableApiLevel);@ANDROID_LATEST_UNSTABLE_API_LEVEL@=$(AndroidLatestUnstableApiLevel);@DOTNET_TARGET_FRAMEWORK@=$(DotNetTargetFramework);@MICROSOFT_NETCORE_APP_REF_PACKAGE_VERSION@=$(MicrosoftNETCoreAppRefPackageVersion)" >
true
+ @NDK_ARMEABI_V7_API@
@NDK_ARM64_V8A_API@
@NDK_X86_64_API@
diff --git a/src/native/CMakePresets.json.in b/src/native/CMakePresets.json.in
index 926a370a3cc..1c5607585f1 100644
--- a/src/native/CMakePresets.json.in
+++ b/src/native/CMakePresets.json.in
@@ -151,6 +151,11 @@
"inherits": ["default-common", "common-debug", "common-armeabi-v7a"]
},
+ {
+ "name": "nativeaot-default-debug-armeabi-v7a",
+ "inherits": ["nativeaot-default-common", "common-debug", "common-armeabi-v7a"]
+ },
+
{
"name": "coreclr-default-debug-armeabi-v7a",
"inherits": ["default-common", "common-debug", "common-armeabi-v7a"]
@@ -161,6 +166,11 @@
"inherits": ["default-common", "common-release", "common-armeabi-v7a"]
},
+ {
+ "name": "nativeaot-default-release-armeabi-v7a",
+ "inherits": ["nativeaot-default-common", "common-release", "common-armeabi-v7a"]
+ },
+
{
"name": "coreclr-default-release-armeabi-v7a",
"inherits": ["default-common", "common-release", "common-armeabi-v7a"]
diff --git a/src/native/native-nativeaot.csproj b/src/native/native-nativeaot.csproj
index 6083fc9e639..4b26073d620 100644
--- a/src/native/native-nativeaot.csproj
+++ b/src/native/native-nativeaot.csproj
@@ -8,7 +8,7 @@
false
arm64:x86_64
- arm64-v8a:x86_64
+ armeabi-v7a:arm64-v8a:x86_64
diff --git a/src/native/native.targets b/src/native/native.targets
index 80c87e42131..41c225d349b 100644
--- a/src/native/native.targets
+++ b/src/native/native.targets
@@ -373,6 +373,14 @@
RuntimePackName="$(_RuntimePackName)" />
+
+ <_RuntimePackFiles Include="$(XAPackagesDir)\microsoft.netcore.app.runtime.nativeaot.%(AndroidSupportedTargetJitAbi.AndroidRID)\$(MicrosoftNETCoreAppRefPackageVersion)\runtimes\%(AndroidSupportedTargetJitAbi.AndroidRID)\native\libSystem.Security.Cryptography.Native.Android.a"
+ Condition="Exists('$(XAPackagesDir)\microsoft.netcore.app.runtime.nativeaot.%(AndroidSupportedTargetJitAbi.AndroidRID)\$(MicrosoftNETCoreAppRefPackageVersion)\runtimes\%(AndroidSupportedTargetJitAbi.AndroidRID)\native\libSystem.Security.Cryptography.Native.Android.a')"
+ AndroidRID="%(AndroidSupportedTargetJitAbi.AndroidRID)"
+ AndroidRuntime="$(CMakeRuntimeFlavor)"
+ RuntimePackName="$(_RuntimePackName)" />
+
+
+
+
+
+
+
+