Skip to content

Commit 87d7b22

Browse files
[Xamarin.Android.Build.Tasks] emit XA1040 for experimental runtimes (#9834)
MonoVM is currently the default (and supported!) runtime for .NET for Android. Emit warning XA1040 when the user opts into using the experimental runtimes, such as: * CoreCLR, via `$(UseMonoRuntime)=false` * NativeAOT, via `$(PublishAot)=true` For example: warning XA1040: The NativeAOT runtime on Android is an experimental feature and not yet suitable for production use. File issues at: https://github.com/dotnet/android/issues If desired, you can opt out of the warning completely with `$(EnablePreviewFeatures)=true`, or use existing MSBuild mechanisms to suppress it.
1 parent e70f21e commit 87d7b22

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
title: .NET for Android warning XA1040
3+
description: XA1040 warning code
4+
ms.date: 02/24/2025
5+
---
6+
# .NET for Android warning XA1040
7+
8+
## Example messages
9+
10+
```
11+
warning XA1040: The CoreCLR runtime on Android is an experimental feature and not yet suitable for production use. File issues at: https://github.com/dotnet/android/issues
12+
warning XA1040: The NativeAOT runtime on Android is an experimental feature and not yet suitable for production use. File issues at: https://github.com/dotnet/android/issues
13+
```
14+
15+
## Issue
16+
17+
MonoVM is the default, supported runtime for .NET for Android.
18+
19+
Other runtimes are currently experimental, such as:
20+
21+
* CoreCLR, used via `$(UseMonoRuntime)=false`
22+
* NativeAOT, used via `$(PublishAot)=true`
23+
24+
## Solution
25+
26+
To silence this warning, you can either:
27+
28+
* Use MonoVM by removing `$(UseMonoRuntime)=false` or
29+
`$(PublishAot)=true` from your project file.
30+
31+
* Set `$(EnablePreviewFeatures)` to `true` in your project file.

src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Xamarin.Android.Build.Tasks/Properties/Resources.resx

+5
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,11 @@ To use a custom JDK path for a command line build, set the 'JavaSdkDirectory' MS
10161016
<value>The Android Support libraries are not supported in .NET 9 and later, please migrate to AndroidX. See https://aka.ms/net-android/androidx for more details.</value>
10171017
<comment>The following are literal names and should not be translated: Android Support, AndroidX, .NET.</comment>
10181018
</data>
1019+
<data name="XA1040" xml:space="preserve">
1020+
<value>The {0} runtime on Android is an experimental feature and not yet suitable for production use. File issues at: https://github.com/dotnet/android/issues</value>
1021+
<comment>The following are literal names and should not be translated: .NET.
1022+
{0} - The name of the .NET runtime, such as CoreCLR or NativeAOT.</comment>
1023+
</data>
10191024
<data name="XA4241" xml:space="preserve">
10201025
<value>Java dependency '{0}' is not satisfied.</value>
10211026
<comment>The following are literal names and should not be translated: Java.

src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets

+5
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,11 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved.
566566
FormatArguments="AndroidFastDeploymentType;9"
567567
Condition=" '$(AndroidFastDeploymentType)' != '' "
568568
/>
569+
<AndroidWarning Code="XA1040"
570+
ResourceName="XA1040"
571+
FormatArguments="$(_AndroidRuntime)"
572+
Condition=" '$(_AndroidRuntime)' != 'MonoVM' and '$(EnablePreviewFeatures)' != 'true' "
573+
/>
569574
</Target>
570575

571576
<Target Name="_CheckNonIdealConfigurations"

0 commit comments

Comments
 (0)