Unify Android minimum API level to 24 for all runtimes#11331
Conversation
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
There was a problem hiding this comment.
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
AndroidMinimumDotNetApiLeveldefault from 21 → 24 and removeAndroidMinimumNonMonoApiLevel. - Remove runtime-conditional min-API selection (MSBuild item conditions,
GenerateSupportedPlatformsconditional output,XABuildConfignon-mono maps, helper branching). - Simplify native preset inheritance by dropping
nonmono-common-*CMake presets and inheriting from standardcommon-*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
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@copilot CI is failing with this root cause analysis, fix it: |
…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>
... Fixed in cd8f3e8. The changes address all three CI failure categories:
|
The MAUI template on the net11.0 branch (which CI checks out) already defaults SupportedOSPlatformVersion to 24.0 for Android, so the -p:SupportedOSPlatformVersion=24 build argument is unnecessary. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Assisted-by: Claude:claude-opus-4.6-1m
With min SDK 24+, apksigner uses v2/v3 signature schemes only and skips v1 JAR signing, so META-INF/MANIFEST.MF is no longer present in signed APKs. Replace the ZIP entry check with an AssertApkIsSigned helper that runs 'apksigner verify' to validate signatures regardless of scheme. AAB signing still uses jarsigner (which always produces META-INF), so those assertions are unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Assisted-by: Claude:claude-opus-4.6-1m
With API level 24 unified across all runtimes, the separate redist-nativeaot directory (which copied CRT/DSO stubs from the API 24 sysroot) is redundant — the regular redist directory already uses API 24. Remove the NativeAOT-specific copy in Step_Android_SDK_NDK, point the NativeAOT pack at the common redist directory, and remove the redist-nativeaot glob from native.targets. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Assisted-by: Claude:claude-opus-4.6-1m
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=24inDirectory.Build.props). The separateAndroidMinimumNonMonoApiLevelproperty in dotnet/android was unnecessary since the Mono.sofiles 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
AndroidMinimumDotNetApiLevelfrom 21 to 24AndroidMinimumNonMonoApiLeveland all related properties, constants, template placeholders, and conditional logicnonmono-common-*CMake presets; NativeAOT/CoreCLR presets now inherit from regularcommon-*presets directlyArchToApiLevelNonMonodictionary fromXABuildConfigMonoAndroidHelper.GetMinimumApiLevel(no runtime branching)MinimumNonMonoApiLevelfromGenerateSupportedPlatformstaskAndroidMinimumSupportedApiLevelitems