Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,21 @@
- eng/native/build-commons.sh
- eng/native/gen-buildsys.cmd
- src/native/libs/build-native.sh
- src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs
- src/coreclr/tools/Common/Compiler/ObjectWriter/MachObjectWriter.cs
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.

Based on the original path, shouldn't this be src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.Aot.cs? (aot vs Common)

- src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets
- src/mono/mono/tools/offsets-tool/offsets-tool.py
- src/mono/mono/offsets/offsets-tool.py
- src/mono/msbuild/apple/build/AppleBuild.targets
- src/installer/pkg/sfx/bundle/shared-framework-distribution-template-x64.xml
- src/installer/pkg/sfx/bundle/shared-framework-distribution-template-arm64.xml
- src/mono/msbuild/common/MonoAOTCompiler.props
- src/tasks/AppleAppBuilder/Xcode.cs
- src/tasks/MobileBuildTasks/Apple/AppleProject.cs
- src/tasks/MobileBuildTasks/Android/AndroidProject.cs
- src/tasks/AndroidAppBuilder/ApkBuilder.cs
- src/tasks/Crossgen2Tasks/Microsoft.NET.CrossGen.targets
- https://github.com/dotnet/sdk repo > src/Installer/redist-installer/targets/GeneratePKG.targets
-->
<AndroidApiLevelMin>21</AndroidApiLevelMin>
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.

Above is a list of all the files that might be hardcoding 21, this PR is missing some.

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.

The offsets-tool.py still has 21

<AndroidApiLevelMin>24</AndroidApiLevelMin>
Comment thread
simonrozsival marked this conversation as resolved.
<iOSVersionMin>13.0</iOSVersionMin>
Comment thread
simonrozsival marked this conversation as resolved.
<tvOSVersionMin>13.0</tvOSVersionMin>
<macOSVersionMin>14.0</macOSVersionMin>
Expand Down
2 changes: 1 addition & 1 deletion docs/workflow/building/coreclr/android.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Supported target architectures:

- Download and install [OpenJDK 23](https://openjdk.org/projects/jdk/23/)
- Download and install [Android Studio](https://developer.android.com/studio/install) and the following:
- Android SDK (minimum supported API level is 21)
- Android SDK (minimum supported API level is 24)
- Android NDK r27c

> [!NOTE]
Expand Down
2 changes: 1 addition & 1 deletion eng/common/cross/build-android-rootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ usage()
exit 1
}

__ApiLevel=28 # The minimum platform for arm64 is API level 21 but the minimum version that support glob(3) is 28. See $ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/glob.h
__ApiLevel=28 # The minimum platform for arm64 is API level 24 but the minimum version that supports glob(3) is 28. See $ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/glob.h
__BuildArch=arm64
__AndroidArch=aarch64
__AndroidToolchain=aarch64-linux-android
Expand Down
2 changes: 1 addition & 1 deletion eng/native/build-commons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ build_native()

if [[ "$targetOS" == android || "$targetOS" == linux-bionic ]]; then
# Keep in sync with $(AndroidApiLevelMin) in Directory.Build.props in the repository rooot
Comment thread
simonrozsival marked this conversation as resolved.
local ANDROID_API_LEVEL=21
local ANDROID_API_LEVEL=24
if [[ -z "$ANDROID_NDK_ROOT" ]]; then
echo "Error: You need to set the ANDROID_NDK_ROOT environment variable pointing to the Android NDK root."
exit 1
Expand Down
2 changes: 1 addition & 1 deletion eng/native/gen-buildsys.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ if /i "%__Arch%" == "wasm" (

if /i "%__Os%" == "android" (
:: Keep in sync with $(AndroidApiLevelMin) in Directory.Build.props in the repository rooot
Comment thread
simonrozsival marked this conversation as resolved.
set __ANDROID_API_LEVEL=21
set __ANDROID_API_LEVEL=24
if "%ANDROID_NDK_ROOT%" == "" (
echo Error: You need to set the ANDROID_NDK_ROOT environment variable pointing to the Android NDK root.
exit /B 1
Expand Down
4 changes: 2 additions & 2 deletions eng/pipelines/helix-platforms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,9 @@ variables:
- name: helix_android_ubuntu_latest
value: Ubuntu.2204.Amd64.Android.29.Open

# Oldest: API 21
# Oldest: API 24
- name: helix_android_ubuntu_oldest
value: Ubuntu.2204.Amd64.Android.21.Open
value: Ubuntu.2204.Amd64.Android.24.Open

# ===========================================
# Common Aliases (default to latest)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ The .NET Foundation licenses this file to you under the MIT license.
<CrossCompileArch Condition="$(CrossCompileRid.EndsWith('-arm'))">armv7</CrossCompileArch>

<CrossCompileAbi>gnu</CrossCompileAbi>
<CrossCompileAbi Condition="$(CrossCompileRid.StartsWith('linux-bionic-')) or $(CrossCompileRid.StartsWith('android-'))">android21</CrossCompileAbi>
<CrossCompileAbi Condition="$(CrossCompileRid.StartsWith('linux-bionic-')) or $(CrossCompileRid.StartsWith('android-'))">android24</CrossCompileAbi>
<CrossCompileAbi Condition="$(CrossCompileRid.StartsWith('linux-musl-')) or $(CrossCompileRid.StartsWith('alpine-'))">musl</CrossCompileAbi>
<CrossCompileAbi Condition="'$(CrossCompileRid)' == 'linux-arm'">gnueabihf</CrossCompileAbi>
<CrossCompileAbi Condition="'$(CrossCompileRid)' == 'linux-bionic-arm' or '$(CrossCompileRid)' == 'android-arm'">androideabi21</CrossCompileAbi>
<CrossCompileAbi Condition="'$(CrossCompileRid)' == 'linux-bionic-arm' or '$(CrossCompileRid)' == 'android-arm'">androideabi24</CrossCompileAbi>
<CrossCompileAbi Condition="'$(CrossCompileRid)' == 'linux-musl-arm'">musleabihf</CrossCompileAbi>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/nativeaot/docs/android-bionic.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Starting with .NET 8 Preview 7, it's possible to build shared libraries and comm

Not a full Android experience is available - it's only possible to publish for two Bionic RID: linux-bionic-arm64 and linux-bionic-x64. Publishing for Android RIDs (android-arm64/android-x64) is not possible. This limited experience corresponds to building with [Android NDK](https://developer.android.com/ndk) from Native code - the limitations are similar. Interop with Java needs to be done manually through JNI, if necessary.

The minimum API level is 21 at the time of writing the document, but search for AndroidApiLevelMin in this repo for more up-to-date information.
The minimum API level has been raised to 24 in .NET 11. Search for `AndroidApiLevelMin` in this repo for the current value.

To build for Bionic:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static void IsOSPlatformVersionAtLeast_InvalidArgs_Throws()
public static void TestIsOSVersionAtLeast_Android() => TestIsOSVersionAtLeast("Android");

[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
Comment on lines 109 to +110
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.

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 do we keep the version in the name of the test, instead of having something like TestIsOSVersionSupported_Android or TestIsAndroidVersionSupported?


[Fact, PlatformSpecific(TestPlatforms.iOS)]
public static void TestIsOSPlatform_IOS() => TestIsOSPlatform("iOS", OperatingSystem.IsIOS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ public void Add(ICertificatePal cert)
{
Interop.AndroidCrypto.PAL_KeyAlgorithm algorithm = certPal.PrivateKeyHandle switch
{
// The AndroidKeyStore doesn't support adding DSA private key entries in newer versions (API 23+)
// Our minimum supported version (API 21) does support it, but for simplicity, we simply block adding
// certificates with DSA private keys on all versions instead of trying to support it on two versions.
SafeDsaHandle => throw new PlatformNotSupportedException(SR.Cryptography_X509_StoreDSAPrivateKeyNotSupported),
SafeEcKeyHandle => Interop.AndroidCrypto.PAL_KeyAlgorithm.EC,
SafeRsaHandle => Interop.AndroidCrypto.PAL_KeyAlgorithm.RSA,
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/offsets/offsets-tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def require_emscipten_path (args):
self.sys_includes=[]
self.target = None
self.target_args = []
android_api_level = "-D__ANDROID_API=21"
android_api_level = "-D__ANDROID_API=24"
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

In offsets-tool.py, the Android API level define is set as -D__ANDROID_API=24, but Android/Bionic headers (and other native code in this repo) generally key off __ANDROID_API__ (double trailing underscores). As written, this define may not influence header feature selection, meaning the offsets could be generated against the wrong API surface. Consider switching to -D__ANDROID_API__=24 and/or encoding the API level in the --target triple (e.g., *-linux-android24).

Suggested change
android_api_level = "-D__ANDROID_API=24"
android_api_level = "-D__ANDROID_API__=24"

Copilot uses AI. Check for mistakes.
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.

@akoeplinger do you know if this is a relevant comment from Copilot or not? I suppose that if it's been this way up until now it should stay this way going forward.


if args.libclang_headers:
self.sys_includes+= [args.libclang_headers]
Expand Down
2 changes: 1 addition & 1 deletion src/mono/msbuild/android/build/AndroidBuild.targets
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
</PropertyGroup>

<PropertyGroup>
<AndroidLibraryMinApiLevel Condition="'$(AndroidLibraryMinApiLevel)' == ''">21</AndroidLibraryMinApiLevel>
<AndroidLibraryMinApiLevel Condition="'$(AndroidLibraryMinApiLevel)' == ''">24</AndroidLibraryMinApiLevel>
</PropertyGroup>

<ItemGroup>
Expand Down
8 changes: 0 additions & 8 deletions src/native/libs/System.Native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,6 @@ include(${CMAKE_CURRENT_LIST_DIR}/extra_libs.cmake)
set(NATIVE_LIBS_EXTRA)
append_extra_system_libs(NATIVE_LIBS_EXTRA)

if (CLR_CMAKE_TARGET_ANDROID AND NOT HAVE_GETIFADDRS)
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.

I assume this was android API specific, right?

Copy link
Copy Markdown
Member Author

@simonrozsival simonrozsival Apr 16, 2026

Choose a reason for hiding this comment

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

All this block does is add pal_ifaddrs.c which should be removed now that we're raising the min level to API 24:

#if __ANDROID_API__ >= 24
#error The pal_ifaddrs.h shim is only necessary for Android API 21-23 and it should be removed now that the minimum supported API level is 24 or higher
#endif

add_definitions(-DANDROID_GETIFADDRS_WORKAROUND)
add_compile_options(-Wno-gnu-zero-variadic-macro-arguments)

list (APPEND NATIVE_LIBS_EXTRA -llog)
list (APPEND NATIVE_SOURCES pal_ifaddrs.c)
endif ()

if (GEN_SHARED_LIB)
add_library(System.Native
SHARED
Expand Down
Loading
Loading