Skip to content

Bump Android minimum API level from 21 to 24#126838

Open
simonrozsival wants to merge 7 commits intodotnet:mainfrom
simonrozsival:dev/simonrozsival/android-bump-min-api-level-to-24
Open

Bump Android minimum API level from 21 to 24#126838
simonrozsival wants to merge 7 commits intodotnet:mainfrom
simonrozsival:dev/simonrozsival/android-bump-min-api-level-to-24

Conversation

@simonrozsival
Copy link
Copy Markdown
Member

Note

This PR was created with the help of Copilot.

As part of the move to CoreCLR as the default runtime for .NET on Android, we are raising the minimum supported Android API level from 21 to 24.

Raising the required API level to 24 (Android 7.0 Nougat) allows us to drop several compatibility workarounds that existed solely to support API levels 21–23.

Changes

Minimum API level bump:

  • AndroidApiLevelMin in Directory.Build.props
  • Mirrored defaults in eng/native/build-commons.sh, AndroidBuild.targets, ApkBuilder.cs, and AndroidProject.cs

Removed System.Native getifaddrs shim (introduced in #71943, #76370):

  • Deleted pal_ifaddrs.c / pal_ifaddrs.h — a netlink-based reimplementation of getifaddrs/freeifaddrs that was needed because Bionic didn't include them until API 24
  • Removed the ANDROID_GETIFADDRS_WORKAROUND build flag and runtime dlopen/dlsym fallback in pal_interfaceaddresses.c

Simplified System.Security.Cryptography.Native.Android:

  • Removed the legacy SSLEngineResult.Status enum mapping — ordinal values changed between API 23 and 24 (introduced in [Android] Fix SslStream on Android API 21-23 #94408)
  • Removed the Conscrypt OpenSSLEngineImpl private-field reflection used to access the handshake session on API 21–23; now uses SSLEngine.getHandshakeSession() directly (introduced in [Android] Fix SslStream on Android API 21-23 #78918)
  • Removed the legacy SNI workaround that called internal Conscrypt APIs on API 21–23; now uses SNIHostName/SSLParameters.setServerNames() directly (introduced in [Android] Fix SslStream on Android API 21-23 #78918)
  • Made CertPathValidatorException.getReason(), CertPathValidatorException.BasicReason, PKIXReason, PKIXRevocationChecker, and related cert validation APIs required (available since API 24)

Tests and documentation:

  • Updated OperatingSystemTests to assert API 24 as the minimum
  • Updated Android-related documentation

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

Raises the minimum supported Android API level from 21 to 24 to align with the move to CoreCLR as the default runtime on Android, and removes compatibility shims/workarounds that were only needed for API 21–23.

Changes:

  • Bumps Android min API defaults across build props/targets and task defaults (21 → 24).
  • Removes the System.Native getifaddrs workaround/shim previously used for older Android API levels.
  • Simplifies Android crypto/SSL JNI code paths by making API 24+ APIs required and deleting legacy fallback logic.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Directory.Build.props Sets AndroidApiLevelMin to 24 (repo-wide minimum).
eng/native/build-commons.sh Updates native build script default Android API level to 24.
src/mono/msbuild/android/build/AndroidBuild.targets Updates AndroidLibraryMinApiLevel default to 24.
src/tasks/MobileBuildTasks/Android/AndroidProject.cs Updates task-side default min API level to 24.
src/tasks/AndroidAppBuilder/ApkBuilder.cs Updates builder-side default min API level to 24.
src/native/libs/System.Native/pal_interfaceaddresses.c Removes Android getifaddrs workaround code paths and relies on HAVE_GETIFADDRS.
src/native/libs/System.Native/pal_ifaddrs.h (deleted) Deletes the netlink getifaddrs shim header (no longer needed at API 24+).
src/native/libs/System.Native/pal_ifaddrs.c (deleted) Deletes the netlink getifaddrs shim implementation.
src/native/libs/System.Native/CMakeLists.txt Removes the Android workaround definitions and sources for pal_ifaddrs.c.
src/native/libs/System.Security.Cryptography.Native.Android/pal_jni.h Removes Conscrypt private-API globals and makes several JNI APIs non-optional.
src/native/libs/System.Security.Cryptography.Native.Android/pal_jni.c Makes API 24+ JNI types/methods mandatory; removes legacy Conscrypt reflection wiring.
src/native/libs/System.Security.Cryptography.Native.Android/pal_sslstream.c Removes API 21–23 SSLStatus mapping and legacy SNI/handshake-session workarounds.
src/native/libs/System.Security.Cryptography.Native.Android/pal_x509chain.c Requires API 24+ cert validation APIs and simplifies revocation option handling.
src/native/minipal/memorybarrierprocesswide.c Clarifies membarrier comment to specify “older than API 29”.
src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/OperatingSystemTests.cs Updates Android min-version assertion to 24.
src/coreclr/nativeaot/docs/android-bionic.md Updates documentation to reflect min API level is now 24.
docs/workflow/building/coreclr/android.md Updates Android build docs to reflect min API level is now 24.

simonrozsival and others added 7 commits April 13, 2026 18:11
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 dev/simonrozsival/android-bump-min-api-level-to-24 branch from 8b65125 to 7c91e8d Compare April 13, 2026 16:11
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/runtime-infrastructure
See info in area-owners.md if you want to be subscribed.

Comment on lines 109 to +110
[Fact, PlatformSpecific(TestPlatforms.Android)]
public static void TestIsOSVersionAtLeast_Android_21() => Assert.True(OperatingSystem.IsAndroidVersionAtLeast(21)); // 21 is our min supported version
public static void TestIsOSVersionAtLeast_Android_24() => Assert.True(OperatingSystem.IsAndroidVersionAtLeast(24)); // 24 is our min supported version
Copy link
Copy Markdown
Member

@jonathanpeppers jonathanpeppers Apr 13, 2026

Choose a reason for hiding this comment

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

This test should actually still pass unchanged, can you introduce a new test and keep the old one? (or use [Theory] with parameters?)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sure, we could do that, but I don't see a value of such test. If anything, we might want to completely drop this test.

@jkoritzinsky
Copy link
Copy Markdown
Member

This should allow us to fix #111665 I believe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants