Edit

.NET for Android warning XA1040

Example messages

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

Issue

NativeAOT is an experimental runtime option for .NET for Android. When you enable NativeAOT via $(PublishAot)=true for a supported publish or optimized build, this warning is emitted to indicate that NativeAOT is not yet suitable for production use.

The supported runtimes are:

  • CoreCLR (the default for Android applications in .NET 11 and later)
  • MonoVM, the default for .NET 10 and earlier and available through $(UseMonoRuntime)=true only on supported targets
  • NativeAOT, selected by $(PublishAot)=true for supported publish or optimized builds

In .NET 11 and later, $(UseMonoRuntime)=true is rejected with NETSDK1242; it is not an escape hatch from CoreCLR.

Solution

To silence this warning, you can either:

  • Use a supported runtime by removing $(PublishAot)=true from your project file.

  • Set $(EnablePreviewFeatures) to true in your project file to acknowledge the experimental nature of NativeAOT.