Skip to content

Enable android-arm NativeAOT runtime packs#12029

Open
simonrozsival wants to merge 3 commits into
mainfrom
nativeaot-android-arm
Open

Enable android-arm NativeAOT runtime packs#12029
simonrozsival wants to merge 3 commits into
mainfrom
nativeaot-android-arm

Conversation

@simonrozsival

Copy link
Copy Markdown
Member

Summary

  • enable android-arm NativeAOT runtime-pack resolution for .NET for Android apps
  • add the android-arm NativeAOT runtime pack to the workload manifest and native runtime build
  • download NativeAOT Android runtime packs and copy Android crypto archive assets into Microsoft.Android.Runtime.NativeAOT packs
  • keep android-arm NativeAOT runtime pack and ILCompiler versions aligned with the dotnet/runtime dependency version
  • include an API 37 metadata fix needed for this branch to build locally

Validation

  • make prepare && make all MSBUILD_ARGS="/m:1 /nr:false /p:UseSharedCompilation=false"
  • ./dotnet-local.sh publish samples/NativeAOT/NativeAOT.csproj -c Release -r android-arm -tl:off -nr:false
  • verified generated assets resolve Microsoft.NETCore.App.Runtime.NativeAOT.android-arm and Microsoft.DotNet.ILCompiler to 11.0.0-preview.7.26355.102
  • installed and launched the published APK on Samsung A16 (armeabi-v7a), process stayed alive with no fatal logcat lines

Note: local sample publish required replacing the built SDK tools System.IO.Hashing.dll with the package's netstandard2.0 asset to avoid a current main-branch MSBuild task assembly-load mismatch. The repo build itself passed without that local workaround.

Note

This PR description was created with GitHub Copilot.

simonrozsival and others added 2 commits July 9, 2026 12:55
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@simonrozsival simonrozsival force-pushed the nativeaot-android-arm branch from 28e7cf5 to 5816a3c Compare July 9, 2026 10:55
@simonrozsival simonrozsival marked this pull request as ready for review July 9, 2026 10:57
Copilot AI review requested due to automatic review settings July 9, 2026 10:57
@simonrozsival

Copy link
Copy Markdown
Member Author

/review

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

Android PR Reviewer completed successfully!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enables NativeAOT runtime-pack resolution and pack production for the android-arm (armeabi-v7a) RID, aligning NativeAOT/ILCompiler pack versions with the repo’s dotnet/runtime dependency and ensuring required native crypto assets are present in the produced packs.

Changes:

  • Adds Microsoft.Android.Runtime.NativeAOT.37.android-arm to the Android workload manifest and wires up build/NDK metadata to support NativeAOT on android-arm.
  • Downloads the upstream Microsoft.NETCore.App.Runtime.NativeAOT.android-* packs during workload provisioning and uses MicrosoftNETCoreAppRefPackageVersion to keep pack versions aligned.
  • Copies libSystem.Security.Cryptography.Native.Android.a from upstream NativeAOT runtime packs into Microsoft.Android.Runtime.NativeAOT pack outputs and adjusts NativeAOT linking to prefer the runtime-pack-provided archive when available.
Show a summary per file
File Description
src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets Plumbs MicrosoftNETCoreAppRefPackageVersion into bundled versions generation inputs/replacements.
src/Xamarin.Android.Build.Tasks/Microsoft.NET.Sdk.Android/WorkloadManifest.in.json Adds the android-arm NativeAOT runtime pack to the workload pack list and pack definitions.
src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.NativeAOT.targets Enables android-arm NativeAOT runtime-pack restore/selection and adds android-arm toolchain/linker handling.
src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/in/Microsoft.Android.Sdk.BundledVersions.in.targets Exposes MicrosoftNETCoreAppRefPackageVersion in the generated SDK bundled-versions targets.
src/workloads/workloads.csproj Downloads upstream NativeAOT Android runtime packs as part of workload provisioning.
src/native/native.targets Copies upstream NativeAOT crypto archive into the local NativeAOT runtime pack output for supported RIDs.
src/native/native-nativeaot.csproj Expands NativeAOT native build RID list to include armeabi-v7a (android-arm).
src/native/CMakePresets.json.in Adds nativeaot CMake presets for armeabi-v7a debug/release builds.
src/Mono.Android/metadata Adds an API 37 metadata removal for android.app.appfunctions.AppFunctionState.
build-tools/scripts/Ndk.projitems Marks android-arm as supporting NativeAOT in NDK ABI metadata.
build-tools/create-packs/Microsoft.Android.Runtime.proj Includes upstream NativeAOT crypto archive as a NativeAOT runtime-pack asset when present.

Copilot's findings

  • Files reviewed: 11/11 changed files
  • Comments generated: 1

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Android PR Review — ⚠️ Needs Changes

Enables android-arm (armeabi-v7a) NativeAOT runtime packs: workload manifest entry, runtime-pack download, NDK toolchain wiring, CMake presets, and crypto-archive plumbing. The structure closely mirrors the existing arm64/x64 NativeAOT paths, and the version plumbing is consistent (DotNetRuntimePacksVersion defaults to MicrosoftNETCoreAppRefPackageVersion, so the new BundledVersions/lookup wiring lines up).

Findings

  • ⚠️ 1 warningAndroidNdkApiLevel_Arm is referenced but never defined, so _NDKApiLevel is empty for android-arm (see inline on Microsoft.Android.Sdk.NativeAOT.targets). Works in the validated default workload-linker path, but breaks the _AndroidUseWorkloadNativeLinker != 'true' NDK path and is a latent inconsistency with arm64/x64. One-line fix.
  • 💡 2 suggestions — an unrelated AppFunctionState API-37 metadata <remove-node> bundled into this PR; and a potential silent crypto-lib drop if the download vs. lookup version properties ever diverge.

CI

Not green yet — the Mac build and Java.Interop Mac tests are in progress and the main dotnet-android build is queued. The earlier Windows/Linux runs show cancelled because a newer build superseded them (not real failures). Please confirm the pipeline goes green before merging.

Positive callouts

  • Correctly handles the NDK quirk where the 32-bit ARM clang prefix (armv7a-linux-androideabi) differs from the sysroot dir (arm-linux-androideabi).
  • CMake presets, RID→ABI mapping, and _PrivateBuildTargetAbi are consistent with the arm64/x64 precedent.
  • Real-device validation on an armeabi-v7a phone is documented in the PR description.

Automated review — please verify each suggestion against full context before acting.

Generated by Android PR Reviewer for #12029 · 265.6 AIC · ⌖ 28 AIC · ⊞ 6.8K
Comment /review to run again

Comment thread src/Mono.Android/metadata Outdated
Comment thread src/native/native.targets
simonrozsival

This comment was marked as outdated.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: f3ad2c76-9fba-41d4-a747-c5602aeae335
@simonrozsival

Copy link
Copy Markdown
Member Author

/review

@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown

Android PR Reviewer completed successfully!

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Code Review — Enable android-arm NativeAOT runtime packs

Verdict: ⚠️ Needs Changes (minor — 3 💡 suggestions, 0 errors, 0 warnings)

This is a clean, well-scoped MSBuild/CMake plumbing change to bring up android-arm (armeabi-v7a) NativeAOT. I verified the changes against the full source files:

  • _NdkClangPrefix/_NdkSysrootAbi/_NdkAbi are now set explicitly per RID; armv7a-linux-androideabi (clang prefix) vs arm-linux-androideabi (sysroot) is the correct NDK split for 32-bit arm, and the derived _NdkAbi=arm matches the compiler-rt/libunwind file naming used later in the file.
  • AndroidNdkApiLevel_Arm uses the existing @NDK_ARMEABI_V7_API@ replacement token (already consumed elsewhere in Xamarin.Android.Common.props.in), and the new @MICROSOFT_NETCORE_APP_REF_PACKAGE_VERSION@ token is wired through both the cache lines and ReplaceFileContents replacements — so incremental builds won't go stale.
  • ✅ The KnownRuntimePack/KnownILCompilerPack override correctly appends android-arm to RuntimePackRuntimeIdentifiers and aligns ILCompiler + runtime-pack versions.
  • ✅ Good test coverage: a Restore test asserting the android-arm pack is selected (and that it does not fall back to linux-bionic-arm), plus an NDK-linker build test.

Suggestions (all non-blocking)

  1. 💡 Duplicated crypto-lib NuGet-cache path across three files — extract to a shared property.
  2. 💡 Silent Exists(...) skip of the crypto archive during pack creation could mask a broken restore.
  3. 💡 Document the intentional MicrosoftNETCoreAppRefPackageVersion vs DotNetRuntimePacksVersion divergence in workloads.csproj.

Notes

  • CI status is currently pending on the head commit — a maintainer should confirm the pipeline goes green before merge (per review guidelines, this keeps the verdict at ⚠️ rather than ✅).
  • The PR description acknowledges a local System.IO.Hashing.dll workaround unrelated to these changes; nothing in the diff depends on it.

Nice work — the per-RID abstraction is a clean improvement over the previous string-concatenation approach.

Generated by Android PR Reviewer for #12029 · 127.1 AIC · ⌖ 17.5 AIC · ⊞ 6.8K
Comment /review to run again

Comment thread src/native/native.targets
Comment thread src/native/native.targets
Comment thread src/workloads/workloads.csproj
@simonrozsival simonrozsival added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants