Skip to content

Unify Android minimum API level to 24 for all runtimes#11331

Open
sbomer wants to merge 4 commits into
mainfrom
dev/sbomer/apilevel
Open

Unify Android minimum API level to 24 for all runtimes#11331
sbomer wants to merge 4 commits into
mainfrom
dev/sbomer/apilevel

Conversation

@sbomer
Copy link
Copy Markdown
Member

@sbomer sbomer commented May 12, 2026

Summary

Unify the Android minimum NDK API level to 24 for all runtimes (MonoVM, CoreCLR, NativeAOT), matching what dotnet/runtime already uses.

Motivation

dotnet/runtime builds all runtimes — including MonoVM — against API level 24 (AndroidApiLevelMin=24 in Directory.Build.props). The separate AndroidMinimumNonMonoApiLevel property in dotnet/android was unnecessary since the Mono .so files from runtime were already compiled at API 24 regardless. The only effect of the API 21 setting was selecting older CRT/DSO linker stubs from the NDK sysroot.

Related: dotnet/runtime#126838

Changes

  • Bump AndroidMinimumDotNetApiLevel from 21 to 24
  • Remove AndroidMinimumNonMonoApiLevel and all related properties, constants, template placeholders, and conditional logic
  • Remove nonmono-common-* CMake presets; NativeAOT/CoreCLR presets now inherit from regular common-* presets directly
  • Remove ArchToApiLevelNonMono dictionary from XABuildConfig
  • Simplify MonoAndroidHelper.GetMinimumApiLevel (no runtime branching)
  • Remove MinimumNonMonoApiLevel from GenerateSupportedPlatforms task
  • Remove runtime-conditional AndroidMinimumSupportedApiLevel items

sbomer and others added 2 commits May 12, 2026 14:33
dotnet/runtime builds all runtimes (MonoVM, CoreCLR, NativeAOT) against
API level 24. The separate AndroidMinimumNonMonoApiLevel property and all
NonMono-specific API level plumbing in dotnet/android was unnecessary
since MonoVM was already being compiled at API 24 by runtime.

Changes:
- Bump AndroidMinimumDotNetApiLevel from 21 to 24
- Remove AndroidMinimumNonMonoApiLevel and all related properties,
  constants, template placeholders, and conditional logic
- Simplify CMake presets: nonmono-common-* now inherit from common-*
- Remove ArchToApiLevelNonMono dictionary from XABuildConfig
- Simplify MonoAndroidHelper.GetMinimumApiLevel (no runtime branching)
- Remove MinimumNonMonoApiLevel from GenerateSupportedPlatforms task
- Remove runtime-conditional AndroidMinimumSupportedApiLevel items

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Assisted-by: Claude:claude-opus-4.6-1m
Remove the nonmono-common-* preset definitions (now redundant) and
update all consumers to inherit from common-arm64-v8a / common-x86_64
directly.

Related: dotnet/runtime#126838

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Assisted-by: Claude:claude-opus-4.6-1m
Copilot AI review requested due to automatic review settings May 12, 2026 21:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR unifies the Android minimum NDK/API level to 24 across all runtimes (MonoVM, CoreCLR, NativeAOT) and removes the now-redundant “non-mono” minimum API level plumbing throughout build tasks, templates, and native CMake presets.

Changes:

  • Bump AndroidMinimumDotNetApiLevel default from 21 → 24 and remove AndroidMinimumNonMonoApiLevel.
  • Remove runtime-conditional min-API selection (MSBuild item conditions, GenerateSupportedPlatforms conditional output, XABuildConfig non-mono maps, helper branching).
  • Simplify native preset inheritance by dropping nonmono-common-* CMake presets and inheriting from standard common-* presets.
Show a summary per file
File Description
src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.props.in Removes runtime-conditional min API items and uses unified NDK API placeholders.
src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets Removes placeholder replacements and task inputs tied to non-mono min API.
src/Xamarin.Android.Build.Tasks/Utilities/MonoAndroidHelper.cs Simplifies minimum API lookup to a single architecture→API mapping.
src/native/CMakePresets.json.in Drops nonmono-common-* presets; CoreCLR/NativeAOT inherit from common-* directly.
Configuration.props Sets unified default AndroidMinimumDotNetApiLevel to 24 and removes non-mono property.
build-tools/xaprepare/xaprepare/xaprepare.targets Removes generation-time placeholder replacement for the non-mono min API property.
build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs Removes non-mono placeholder generation for presets/build config/projitems.
build-tools/xaprepare/xaprepare/ConfigAndData/BuildAndroidPlatforms.cs Removes non-mono min API accessor; uses unified min API.
build-tools/xaprepare/xaprepare/Application/Properties.Defaults.cs.in Removes default property wiring for AndroidMinimumNonMonoApiLevel.
build-tools/xaprepare/xaprepare/Application/KnownProperties.cs Removes AndroidMinimumNonMonoApiLevel constant.
build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/GenerateSupportedPlatforms.cs Removes non-mono conditional output generation for supported platforms.
build-tools/scripts/XABuildConfig.cs.in Removes non-mono minimum API version and non-mono arch→API dictionary.
build-tools/scripts/Ndk.projitems.in Removes non-mono API-level properties/metadata from NDK projitems.

Copilot's findings

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

Comment thread src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.props.in Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@simonrozsival
Copy link
Copy Markdown
Member

@copilot CI is failing with this root cause analysis, fix it:

Root Cause: Minimum API Level Raised to 24
The branch dev/sbomer/apilevel appears to raise the minimum supported Android API level from 23 to 24. This causes widespread failures:

MAUI Integration build fails with XA4216 because MAUI projects still set SupportedOSPlatformVersion to 23.
Hundreds of MSBuild unit tests fail because test projects build with the default (old) minimum API level and hit FailedBuildException.
Windows Build & Smoke Test has untracked .sarif files from Guardian analysis.

…n tests and MAUI CI

Agent-Logs-Url: https://github.com/dotnet/android/sessions/cf359a88-368d-4ed1-8b97-2b96b4b3a8d5

Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented May 13, 2026

@copilot CI is failing with this root cause analysis, fix it:

Root Cause: Minimum API Level Raised to 24

...

Fixed in cd8f3e8. The changes address all three CI failure categories:

  1. MSBuild unit tests — Updated default SupportedOSPlatformVersion from "21.0" to "24.0" in XamarinAndroidApplicationProject (fixes hundreds of tests that use this default), plus updated all other test files that explicitly set API levels 21/22/23: WearApplicationProject, ManifestTest.cs, PackagingTest.cs, WearTests.cs, GenerateTrimmableTypeMapTests.cs, BuildTest.cs, AndroidGradleProjectTests.cs, and TrimmableTypeMapGeneratorTests.cs. Also updated expected version codes in ManifestTest.cs for version code patterns that include {minSDK}.

  2. MAUI Integration XA4216 — Added -p:SupportedOSPlatformVersion=24 to both Debug and Release MAUI template builds in azure-pipelines.yaml to override MAUI's template default (which still sets API 23) while MAUI hasn't yet updated their minimum.

  3. NativeAOT sample and DefaultProperties.targets comment updated for consistency.

project: $(Build.StagingDirectory)/MauiTestProj/MauiTestProj.csproj
arguments: >-
-f $(DotNetTargetFramework)-android -c Debug
-p:SupportedOSPlatformVersion=24
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this needed, it seems like they already have 24 here in the dotnet new maui template:

project: $(Build.StagingDirectory)/MauiTestProj/MauiTestProj.csproj
arguments: >-
-f $(DotNetTargetFramework)-android -c Release
-p:SupportedOSPlatformVersion=24
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same here.

@sbomer sbomer self-assigned this May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants