Skip to content

Commit 3a3beeb

Browse files
authored
[Mono.Android] Bind and enumify API-36 (#9814) (#10005)
Context: d5152b6 [API-36 on main] Note that our repository does not currently have build system support for having multiple ***stable*** API platform versions in a single .NET version. To work around this, this commit treats API-36 as an "unstable" API level for the context of our build system. However, it removes the need for users to use `$(EnablePreviewFeatures)` and thus is a stable platform version to our users. If we actually updated `$(AndroidLatestStableApiLevel)` to `36` it would have (at least) the following issues: - We would no longer build or ship API-35 for .NET 9 - `net9.0-android` would switch from `net9.0-android35.0` to `net9.0-android36.0` which we do not want. Once shipped, `net9.0-android` should not change meaning. Proper multi-stable support would require expanding `$(AndroidLatestStableApiLevel)` to something akin to `$(AndroidMinimumStableApiLevel)`/`$(AndroidMaximumStableApiLevel)` or `@(AndroidStableApiLevels)`. We have chosen not to invest in this work at this time. Original API-36 support commit message follows: Context: https://developer.android.com/about/versions/16 Context: https://android-developers.googleblog.com/2025/03/the-third-beta-of-android-16.html Android 16 Beta 3 has been released. * [API-36 Beta 3 vs. API-35][0] * [API-36 Beta 3 vs. API-Baklava Beta 2][1] The Android 16 Preview Program Overview [Timeline and updates][2] section suggests the following timeline: * Nov/Dec: Developer Previews * Jan/Feb: Unstable Betas * Mar/Apr: Stable Betas * ???: Final Additionally, enumify and mark API-36 as "stable", which changes `net10.0-android` to default to `net10.0-android36.0`. We still need to decide on our strategy for backporting this to .NET 9 service releases. ## Notes APICompat: - There are several `Android.Runtime.RequiresPermissionAttribute` fields that have been removed. As we do not consume this attribute, it does not cause any API breakage. - Several `[ObsoletedOSPlatformAttribute]` attributes are missing. These have all been documented as "undeprecated" in Android's change list: https://developer.android.com/sdk/api_diff/36/changes PublicAPI: - Nullable reference type attribute changes (`T?` -> `T!`) - Method parameter name changes. This is technically a source breaking change, but something we've never tracked or fixed before. - Some consts changed "values" in `PublicAPI*.txt` like from `MediaCodecProfileType.Av1profilemain10hdr10` to `MediaCodecProfileType.Apvprofile42210hdr10`: - const Android.Media.MediaCodecInfo.CodecProfileLevel.AV1ProfileMain10HDR10 = Android.Media.MediaCodecProfileType.Av1profilemain10hdr10 -> Android.Media.MediaCodecProfileType + const Android.Media.MediaCodecInfo.CodecProfileLevel.AV1ProfileMain10HDR10 = Android.Media.MediaCodecProfileType.Apvprofile42210hdr10 -> Android.Media.MediaCodecProfileType This is a weird enum that has lots of members with the same values, and the PublicAPI tooling likely chooses the first alphabetically. The const *value* did not actually change, just the way it is listed in `PublicAPI*.txt`: public enum Android.Media.MediaCodecProfileType { [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android36.0")] Apvprofile42210hdr10 = 4096, [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android29.0")] Av1profilemain10hdr10 = 4096, // … } MAUI Integration Tests: - It looks like the MAUI Integration tests are broken because they [explicitly target net10.0-android35.0][3] instead of `net10.0-android`. The MAUI team will need to update this when our changes flow to them. [0]: https://developer.android.com/sdk/api_diff/36/changes [1]: https://developer.android.com/sdk/api_diff/36-incr/changes [2]: https://developer.android.com/about/versions/16/overview [3]: https://github.com/dotnet/maui/blob/c451130571777aef5d9fa2737789dd987430e6dc/Directory.Build.props#L158
1 parent 8bab45f commit 3a3beeb

File tree

19 files changed

+387016
-15
lines changed

19 files changed

+387016
-15
lines changed

Configuration.props

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
<AndroidLatestStablePlatformId Condition="'$(AndroidLatestStablePlatformId)' == ''">$(AndroidLatestStableApiLevel)</AndroidLatestStablePlatformId>
3030
<AndroidLatestStableFrameworkVersion Condition="'$(AndroidLatestStableFrameworkVersion)'==''">v15.0</AndroidLatestStableFrameworkVersion>
3131
<!-- *Latest* *unstable* API level binding that we support; this can be the same as *stable* -->
32-
<AndroidLatestUnstableApiLevel Condition="'$(AndroidLatestUnstableApiLevel)' == ''">$(AndroidLatestStableApiLevel)</AndroidLatestUnstableApiLevel>
33-
<AndroidLatestUnstablePlatformId Condition="'$(AndroidLatestUnstablePlatformId)' == ''">$(AndroidLatestStablePlatformId)</AndroidLatestUnstablePlatformId>
34-
<AndroidLatestUnstableFrameworkVersion Condition="'$(AndroidLatestUnstableFrameworkVersion)'==''">$(AndroidLatestStableFrameworkVersion)</AndroidLatestUnstableFrameworkVersion>
32+
<AndroidLatestUnstableApiLevel Condition="'$(AndroidLatestUnstableApiLevel)' == ''">36</AndroidLatestUnstableApiLevel>
33+
<AndroidLatestUnstablePlatformId Condition="'$(AndroidLatestUnstablePlatformId)' == ''">36</AndroidLatestUnstablePlatformId>
34+
<AndroidLatestUnstableFrameworkVersion Condition="'$(AndroidLatestUnstableFrameworkVersion)'==''">v16.0</AndroidLatestUnstableFrameworkVersion>
3535
<!-- The default API level used for $(TargetPlatformVersion) -->
3636
<AndroidDefaultTargetDotnetApiLevel Condition=" '$(AndroidDefaultTargetDotnetApiLevel)' == '' ">$(AndroidLatestStableApiLevel)</AndroidDefaultTargetDotnetApiLevel>
3737
<!-- The API level and TargetFrameworkVersion for the default Mono.Android.dll build -->
@@ -69,7 +69,7 @@
6969
<MicrosoftAndroidx64PackDir>$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.$(AndroidApiLevel).android-x64\$(AndroidPackVersion)\runtimes\android-x64\</MicrosoftAndroidx64PackDir>
7070
<MicrosoftAndroidSdkPackDir>$(BuildOutputDirectory)lib\packs\$(MicrosoftAndroidSdkPackName)\$(AndroidPackVersion)\</MicrosoftAndroidSdkPackDir>
7171
<MicrosoftAndroidSdkOutDir>$(MicrosoftAndroidSdkPackDir)\tools\</MicrosoftAndroidSdkOutDir>
72-
<MicrosoftAndroidSdkAnalysisOutDir>$(BuildOutputDirectory)lib\packs\Microsoft.Android.Ref.$(AndroidApiLevel)\$(AndroidPackVersion)\analyzers\dotnet\cs\</MicrosoftAndroidSdkAnalysisOutDir>
72+
<MicrosoftAndroidSdkAnalysisOutDir>$(BuildOutputDirectory)lib\packs\Microsoft.Android.Ref.$(AndroidLatestStableApiLevel)\$(AndroidPackVersion)\analyzers\dotnet\cs\</MicrosoftAndroidSdkAnalysisOutDir>
7373
<MakeConcurrency Condition=" '$(MakeConcurrency)' == '' And '$(HostCpuCount)' != '' ">-j$(HostCpuCount)</MakeConcurrency>
7474
<ManagedRuntime Condition=" '$(ManagedRuntime)' == '' And '$(OS)' != 'Windows_NT' ">mono</ManagedRuntime>
7575
<ManagedRuntimeArgs Condition=" '$(ManagedRuntimeArgs)' == '' And '$(ManagedRuntime)' == 'mono' ">--debug=casts</ManagedRuntimeArgs>

build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/CheckApiCompatibility.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public sealed class CheckApiCompatibility : Task
3333
{ "v13.0", "v12.1" },
3434
{ "v14.0", "v13.0" },
3535
{ "v15.0", "v14.0" },
36+
{ "v16.0", "v15.0" },
3637
};
3738

3839
static readonly string assemblyToValidate = "Mono.Android.dll";

build-tools/api-merge/merge-configuration.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424
<File Path="api-33.xml.in" Level="33" />
2525
<File Path="api-34.xml.in" Level="34" />
2626
<File Path="api-35.xml.in" Level="35" />
27+
<File Path="api-36.xml.in" Level="36" />
2728
</Inputs>
2829
<Outputs>
29-
<File Path="api-35.xml" LastLevel="35" />
30+
<File Path="api-36.xml" LastLevel="36" />
3031
</Outputs>
3132
</Configuration>

build-tools/automation/yaml-templates/variables.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ variables:
5757
- name: IsRelOrTargetingRel
5858
value: $[or(startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'), startsWith(variables['System.PullRequest.TargetBranch'], 'release/'))]
5959
- name: DefaultTestSdkPlatforms # Comma-separated SDK Platform(s) to install on test agents (no spaces)
60-
value: 35
60+
value: 35,36
6161
- name: ExcludedNightlyNUnitCategories
6262
value: 'cat != SystemApplication & cat != TimeZoneInfo & cat != Localization'
6363
- name: RunMAUITestJob

build-tools/create-android-api/create-android-api.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105

106106
<PropertyGroup>
107107
<ApiMerge>..\..\bin\Build$(Configuration)\api-merge.dll</ApiMerge>
108-
<_ConfigurationFile>..\..\bin\Build$(Configuration)\merge-configuration.xml</_ConfigurationFile>
108+
<_ConfigurationFile>..\api-merge\merge-configuration.xml</_ConfigurationFile>
109109
<_ConfigurationInputBaseDirectory>..\..\bin\Build$(Configuration)\api\</_ConfigurationInputBaseDirectory>
110110
<_ConfigurationOutputBaseDirectory>..\..\bin\Build$(Configuration)\api\</_ConfigurationOutputBaseDirectory>
111111
</PropertyGroup>

build-tools/scripts/BuildEverything.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ endif
1313

1414
leeroy:
1515
$(call DOTNET_BINLOG,leeroy) $(SOLUTION) $(_MSBUILD_ARGS)
16+
$(call DOTNET_BINLOG,monoandroid-preview) $(SOLUTION) -t:BuildExtraApiLevels
1617
$(call DOTNET_BINLOG,setup-workload) -t:ConfigureLocalWorkload build-tools/create-packs/Microsoft.Android.Sdk.proj

build-tools/scripts/DotNet.targets

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,22 @@
2929
<MSBuild Projects="$(_Root)build-tools\create-packs\Microsoft.Android.Sdk.proj" Targets="ConfigureLocalWorkload" />
3030
</Target>
3131

32-
<Target Name="PackDotNet">
33-
<!-- Build extra versions of Mono.Android.dll if necessary -->
32+
<!-- Build Mono.Android.dll for additional API levels if necessary -->
33+
<Target Name="BuildExtraApiLevels">
3434
<MSBuild
3535
Condition=" '$(AndroidDefaultTargetDotnetApiLevel)' != '$(AndroidLatestStableApiLevel)' "
3636
Projects="$(_Root)src\Mono.Android\Mono.Android.csproj"
37-
Properties="TargetFramework=$(DotNetTargetFramework);AndroidApiLevel=$(AndroidDefaultTargetDotnetApiLevel);AndroidPlatformId=$(AndroidDefaultTargetDotnetApiLevel);DisableApiCompatibilityCheck=true"
37+
Properties="AndroidApiLevel=$(AndroidDefaultTargetDotnetApiLevel);AndroidPlatformId=$(AndroidDefaultTargetDotnetApiLevel)"
3838
/>
3939
<MSBuild
4040
Condition=" '$(AndroidLatestUnstableApiLevel)' != '$(AndroidLatestStableApiLevel)' "
4141
Projects="$(_Root)src\Mono.Android\Mono.Android.csproj"
42-
Properties="TargetFramework=$(DotNetTargetFramework);AndroidApiLevel=$(AndroidLatestUnstableApiLevel);AndroidPlatformId=$(AndroidLatestUnstablePlatformId);DisableApiCompatibilityCheck=true"
42+
Properties="AndroidApiLevel=$(AndroidLatestUnstableApiLevel);AndroidPlatformId=$(AndroidLatestUnstablePlatformId);AndroidFrameworkVersion=$(AndroidLatestUnstableFrameworkVersion)"
4343
/>
44+
</Target>
45+
46+
<Target Name="PackDotNet"
47+
DependsOnTargets="BuildExtraApiLevels">
4448
<MSBuild Projects="$(_Root)build-tools\create-packs\Microsoft.Android.Sdk.proj" Targets="CreateAllPacks" />
4549
<MSBuild Projects="$(_Root)build-tools\create-packs\Microsoft.Android.Sdk.proj" Targets="ExtractWorkloadPacks" />
4650
<!-- Clean up old, previously restored packages -->

build-tools/xaprepare/xaprepare/ConfigAndData/BuildAndroidPlatforms.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class BuildAndroidPlatforms
4646
new AndroidPlatform (apiName: "Tiramisu", apiLevel: 33, platformID: "33", include: "v13.0", framework: "v13.0"),
4747
new AndroidPlatform (apiName: "UpsideDownCake", apiLevel: 34, platformID: "34", include: "v14.0", framework: "v14.0"),
4848
new AndroidPlatform (apiName: "VanillaIceCream", apiLevel: 35, platformID: "35", include: "v15.0", framework: "v15.0"),
49+
new AndroidPlatform (apiName: "Baklava", apiLevel: 36, platformID: "36", include: "v16.0", framework: "v16.0", stable: false),
4950
};
5051

5152
}

build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/AndroidToolchain.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public AndroidToolchain ()
4949
// https://dl-ssl.google.com/android/repository/sys-img/google_apis/sys-img2-1.xml
5050
// * system images
5151
//
52+
// Note "isLatestStable" is a bad name, it's actually "xaprepare should install this API by default"
5253
Components = new List<AndroidToolchainComponent> {
5354
new AndroidPlatformComponent ("android-2.3.3_r02", apiLevel: "10", pkgRevision: "2"),
5455
new AndroidPlatformComponent ("android-15_r05", apiLevel: "15", pkgRevision: "5"),
@@ -72,6 +73,7 @@ public AndroidToolchain ()
7273
new AndroidPlatformComponent ("platform-33-ext3_r03", apiLevel: "33", pkgRevision: "3"),
7374
new AndroidPlatformComponent ("platform-34-ext7_r02", apiLevel: "34", pkgRevision: "2"),
7475
new AndroidPlatformComponent ("platform-35_r01", apiLevel: "35", pkgRevision: "1", isLatestStable: true),
76+
new AndroidPlatformComponent ("platform-36_r01", apiLevel: "36", pkgRevision: "1", isLatestStable: true),
7577

7678
new AndroidToolchainComponent ("source-35_r01",
7779
destDir: Path.Combine ("sources", "android-35"),

src/Microsoft.Android.Sdk.Analysis/Microsoft.Android.Sdk.Analysis.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,4 @@
1313
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" PrivateAssets="all" />
1414
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" PrivateAssets="all" />
1515
</ItemGroup>
16-
<ItemGroup>
17-
<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
18-
</ItemGroup>
1916
</Project>

src/Mono.Android/Mono.Android.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
</PropertyGroup>
2727

2828
<PropertyGroup>
29-
<DefineConstants Condition=" '$(AndroidApiLevel)' &gt; '$(AndroidLatestStableApiLevel)' ">$(DefineConstants);ANDROID_UNSTABLE</DefineConstants>
3029
<OutputPath>$(_MonoAndroidNETDefaultOutDir)</OutputPath>
3130

3231
<!-- Allow PublicApiAnalyzers to be turned off -->

0 commit comments

Comments
 (0)