Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
67995fb
[Xamarin.Android.Build.Tasks] don't set `$(UseMonoRuntime)` by default
jonathanpeppers Oct 1, 2025
f8886d3
More changes
jonathanpeppers Oct 1, 2025
e82465e
Test fixes
jonathanpeppers Oct 15, 2025
8c6c019
Fix more tests
jonathanpeppers Oct 15, 2025
d97bc8d
Fix more tests
jonathanpeppers Oct 15, 2025
1f5e256
Fix more tests
jonathanpeppers Oct 15, 2025
ef6fef3
Fix more tests
jonathanpeppers Oct 16, 2025
6591831
Fix tests
jonathanpeppers Oct 16, 2025
e336549
Update a handful more tests
grendello Oct 20, 2025
6848fc6
One more
grendello Oct 20, 2025
51f6620
Prep for environment var reading in CoreCLR and NativeAOT builds
grendello Oct 20, 2025
01d6703
Implement reader for the CoreCLR/NativeAOT style envvars from native …
grendello Oct 21, 2025
6a8612b
CheckAssemblyCounts test works now
grendello Oct 21, 2025
5b835af
Set runtime for the LinkDescription test
grendello Oct 21, 2025
cf0e25c
This is hopelessly broken atm
grendello Oct 21, 2025
f7d71d9
Restore VersionCodeTests to its original form and make it Mono-only
grendello Oct 22, 2025
7c6a372
CheckMonoDebugIsAddedToEnvironment is a Mono-only test
grendello Oct 22, 2025
78e6929
CheckIncludedNativeLibraries works
grendello Oct 22, 2025
0382b14
DoNotErrorOnPerArchJavaTypeDuplicates, partial
grendello Oct 22, 2025
0aa7159
RemoveDesigner works
grendello Oct 22, 2025
a850c33
CheckDebugModeWithTrimming works
grendello Oct 22, 2025
ee1b2c8
BuildAotApplicationWithSpecialCharactersInProject works
grendello Oct 22, 2025
624376f
GenerateJavaStubsAndAssembly works
grendello Oct 22, 2025
bd365cf
AndroidAddKeepAlives works
grendello Oct 22, 2025
7de27ba
ResolveNativeLibrariesInManagedReferences works
grendello Oct 22, 2025
487e238
BuildBasicApplicationReleaseWithCustomAotProfile works
grendello Oct 22, 2025
6a46664
XA0119Interpreter works
grendello Oct 23, 2025
e462308
SimilarAndroidXAssemblyNames works
grendello Oct 23, 2025
7d36978
AotAssembliesInIDE works
grendello Oct 23, 2025
b9e4cc7
Yep, that
grendello Oct 23, 2025
0bc286e
BuildApplicationWithMonoEnvironment works
grendello Oct 23, 2025
54ddb1a
BuildReleaseArm64 works
grendello Oct 23, 2025
a139676
BuildBasicApplicationFSharp works
grendello Oct 23, 2025
2fbd5af
CheckIncludedAssemblies works
grendello Oct 23, 2025
dc647ab
BasicApplicationRepetitiveReleaseBuild is mono-only for now
grendello Oct 23, 2025
fce7af2
Update MonoVM apkdesc files
grendello Oct 27, 2025
8570aaa
CheckHttpClientHandlerType works
grendello Oct 27, 2025
598b102
BuildWithNativeLibraryUnknownAbi works
grendello Oct 27, 2025
6486943
BuildSolutionWithMultipleProjectsInParallel works
grendello Oct 27, 2025
6d1f940
BuildBasicApplicationReleaseProfiledAotWithoutDefaultProfile works
grendello Oct 27, 2025
1ca2b35
BuildBasicApplicationReleaseProfiledAot works
grendello Oct 27, 2025
1739b32
BuildAotApplicationWithNdkAndBundleAndÜmläüts works
grendello Oct 27, 2025
5969a33
NoSymbolsArgShouldReduceAppSize works
grendello Oct 27, 2025
3c0525c
ChangeSupportedAbis works
grendello Oct 27, 2025
b9e89f2
CheckWhetherLibcAndLibmAreReferencedInAOTLibraries works
grendello Oct 27, 2025
a46ff2b
NativeAssemblyCacheWithSatelliteAssemblies works
grendello Oct 27, 2025
4198c05
BuildAotApplicationAndÜmläüts works
grendello Oct 28, 2025
a6f7114
CustomLinkDescriptionPreserve works
grendello Oct 28, 2025
502ca23
GlobalLayoutEvent_ShouldRegisterAndFire_OnActivityLaunch works
grendello Oct 28, 2025
3ed56bf
SubscribeToAppDomainUnhandledException
grendello Oct 28, 2025
3b3ac87
AppBundle works
grendello Oct 28, 2025
d4f17ed
Missed that
grendello Oct 28, 2025
f7ba721
BundleToolNoAbiSplitTests should work now
grendello Oct 28, 2025
23a5d24
InstallWithoutSharedRuntime, BaseZip and RunWithLLVMEnabled work
grendello Oct 28, 2025
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
11 changes: 5 additions & 6 deletions Documentation/docs-mobile/messages/xa1040.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,23 @@ ms.date: 02/24/2025
## Example messages

```
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
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

MonoVM is the default, supported runtime for .NET for Android.
CoreCLR is the default, supported runtime for .NET for Android. Mono is also supported.

Other runtimes are currently experimental, such as:
You can opt into other runtimes via:

* CoreCLR, used via `$(UseMonoRuntime)=false`
* CoreCLR, default
* MonoVM, used via `$(UseMonoRuntime)=true`
* NativeAOT, used via `$(PublishAot)=true`

## Solution

To silence this warning, you can either:

* Use MonoVM by removing `$(UseMonoRuntime)=false` or
`$(PublishAot)=true` from your project file.
* Use CoreCLR by removing `$(PublishAot)=true` from your project file.

* Set `$(EnablePreviewFeatures)` to `true` in your project file.
10 changes: 5 additions & 5 deletions build-tools/automation/yaml-templates/stage-package-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ stages:
testName: Mono.Android.NET_Tests-Interpreter
project: tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj
testResultsFiles: TestResult-Mono.Android.NET_Tests-$(XA.Build.Configuration)Interpreter.xml
extraBuildArgs: -p:TestsFlavor=Interpreter -p:UseInterpreter=True
extraBuildArgs: -p:TestsFlavor=Interpreter -p:UseInterpreter=True -p:UseMonoRuntime=true
artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab
artifactFolder: $(DotNetTargetFramework)-Interpreter

Expand Down Expand Up @@ -154,7 +154,7 @@ stages:
testName: Mono.Android.NET_Tests-NoAot
project: tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj
testResultsFiles: TestResult-Mono.Android.NET_Tests-$(XA.Build.Configuration)NoAot.xml
extraBuildArgs: -p:TestsFlavor=NoAot -p:RunAOTCompilation=false
extraBuildArgs: -p:TestsFlavor=NoAot -p:RunAOTCompilation=false -p:UseMonoRuntime=true
artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab
artifactFolder: $(DotNetTargetFramework)-NoAot

Expand All @@ -164,7 +164,7 @@ stages:
testName: Mono.Android.NET_Tests-TrimModePartial
project: tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj
testResultsFiles: TestResult-Mono.Android.NET_Tests-$(XA.Build.Configuration)TrimModePartial.xml
extraBuildArgs: -p:TestsFlavor=TrimModePartial -p:TrimMode=partial
extraBuildArgs: -p:TestsFlavor=TrimModePartial -p:TrimMode=partial -p:UseMonoRuntime=true
artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab
artifactFolder: $(DotNetTargetFramework)-TrimModePartial

Expand All @@ -174,7 +174,7 @@ stages:
testName: Mono.Android.NET_Tests-AotLlvm
project: tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj
testResultsFiles: TestResult-Mono.Android.NET_Tests-$(XA.Build.Configuration)AotLlvm.xml
extraBuildArgs: -p:TestsFlavor=AotLlvm -p:EnableLLVM=true -p:AndroidEnableProfiledAot=false
extraBuildArgs: -p:TestsFlavor=AotLlvm -p:EnableLLVM=true -p:AndroidEnableProfiledAot=false -p:UseMonoRuntime=true
artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab
artifactFolder: $(DotNetTargetFramework)-AotLlvm

Expand All @@ -184,7 +184,7 @@ stages:
testName: Mono.Android.NET_Tests-IsAssignableFrom
project: tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj
testResultsFiles: TestResult-Mono.Android.NET_Tests-$(XA.Build.Configuration)IsAssignableFrom.xml
extraBuildArgs: -p:TestsFlavor=IsAssignableFrom -p:IncludeCategories=Intune -p:_AndroidIsAssignableFromCheck=false
extraBuildArgs: -p:TestsFlavor=IsAssignableFrom -p:IncludeCategories=Intune -p:_AndroidIsAssignableFromCheck=false -p:UseMonoRuntime=true
artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab
artifactFolder: $(DotNetTargetFramework)-IsAssignableFrom

Expand Down
2 changes: 1 addition & 1 deletion build-tools/scripts/TestApks.targets
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<PropertyGroup>
<!-- APK tests might run on 32-bit emulators -->
<RuntimeIdentifiers Condition=" '$(RuntimeIdentifier)' == '' and '$(PublishAot)' != 'true' and '$(UseMonoRuntime)' != 'false' ">android-arm64;android-x86;android-x64;</RuntimeIdentifiers>
<RuntimeIdentifiers Condition=" '$(RuntimeIdentifier)' == '' and '$(PublishAot)' != 'true' and '$(UseMonoRuntime)' == 'true' ">android-arm64;android-x86;android-x64;</RuntimeIdentifiers>
<TestAvdApiLevel Condition=" '$(TestAvdApiLevel)' == '' ">29</TestAvdApiLevel>
<TestAvdAbi Condition=" '$(TestAvdAbi)' == '' and '$(HostOS)' == 'Darwin' and '$(HostOSArchitecture)' == 'Arm64' ">arm64-v8a</TestAvdAbi>
<TestAvdAbi Condition=" '$(TestAvdAbi)' == '' ">x86_64</TestAvdAbi>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@
See: https://github.com/dotnet/sdk/blob/955c0fc7b06e2fa34bacd076ed39f61e4fb61716/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets#L16
-->
<_GetChildProjectCopyToPublishDirectoryItems>false</_GetChildProjectCopyToPublishDirectoryItems>
<UseMonoRuntime Condition=" '$(PublishAot)' == 'true' and '$(UseMonoRuntime)' == '' ">false</UseMonoRuntime>
<UseMonoRuntime Condition=" '$(UseMonoRuntime)' == '' ">true</UseMonoRuntime>
<_AndroidRuntime Condition=" '$(PublishAot)' == 'true' and '$(UseMonoRuntime)' != 'true' ">NativeAOT</_AndroidRuntime>
<_AndroidRuntime Condition=" '$(PublishAot)' != 'true' and '$(UseMonoRuntime)' != 'true' ">CoreCLR</_AndroidRuntime>
<_AndroidRuntime Condition=" '$(_AndroidRuntime)' == '' ">MonoVM</_AndroidRuntime>
<_AndroidRuntime Condition=" '$(PublishAot)' == 'true' ">NativeAOT</_AndroidRuntime>
Copy link
Member

Choose a reason for hiding this comment

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

What happens in Debug builds when you have <PublishAot>true</PublishAot> in the project file? Does it try to still run with NativeAOT? For "PublishAOT Debug builds", I believe we need to use CoreCLR 🤔 I suppose we can fix that later though.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think in this case it will try to use Mono AOT as it is now, at least the error messages I've seen suggest that. Yeah, we can't use NativeAOT for debug builds.

<_AndroidRuntime Condition=" '$(PublishAot)' != 'true' and '$(UseMonoRuntime)' == 'true' ">MonoVM</_AndroidRuntime>
<_AndroidRuntime Condition=" '$(_AndroidRuntime)' == '' ">CoreCLR</_AndroidRuntime>
<PublishAotUsingRuntimePack Condition=" '$(PublishAotUsingRuntimePack)' == '' and '$(_AndroidRuntime)' == 'NativeAOT' ">true</PublishAotUsingRuntimePack>

<!-- Use $(AndroidMinimumSupportedApiLevel) for $(SupportedOSPlatformVersion) if unset -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public void BuildBasicApplicationReleaseProfiledAot ([Values (true, false)] bool
IsRelease = true,
AndroidEnableProfiledAot = true,
};
// Mono-only test
proj.SetRuntime (AndroidRuntime.MonoVM);
proj.SetProperty ("EnableLLVM", enableLLVM.ToString ());
proj.SetProperty (proj.ActiveConfigurationProperties, "AndroidExtraAotOptions", "--verbose");
using var b = CreateApkBuilder ();
Expand All @@ -84,6 +86,8 @@ public void BuildBasicApplicationReleaseWithCustomAotProfile ()
IsRelease = true,
AndroidEnableProfiledAot = true,
};
// A Mono-only test
proj.SetRuntime (AndroidRuntime.MonoVM);
proj.SetProperty (proj.ActiveConfigurationProperties, "AndroidExtraAotOptions", "--verbose");

byte [] custom_aot_profile = XamarinAndroidCommonProject.GetResourceContents ("Xamarin.ProjectTools.Resources.Base.custom.aotprofile");
Expand All @@ -102,32 +106,60 @@ public void BuildBasicApplicationReleaseProfiledAotWithoutDefaultProfile ()
IsRelease = true,
AndroidEnableProfiledAot = true,
};
// Mono-only test
proj.SetRuntime (AndroidRuntime.MonoVM);
proj.SetProperty (proj.ActiveConfigurationProperties, "AndroidUseDefaultAotProfile", "false");
using var b = CreateApkBuilder ();
b.Verbosity = LoggerVerbosity.Detailed;
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
StringAssertEx.DoesNotContainRegex (@$"Using profile data file.*dotnet\.aotprofile", b.LastBuildOutput, "Should not use default AOT profile", RegexOptions.IgnoreCase);
}

static IEnumerable<object[]> Get_BuildAotApplicationWithSpecialCharactersInProjectData ()
{
var ret = new List<object[]> ();

foreach (AndroidRuntime runtime in new[] { AndroidRuntime.MonoVM, AndroidRuntime.CoreCLR }) {
AddTestData ("テスト", false, false, runtime);
AddTestData ("テスト", true, true, runtime);
AddTestData ("テスト", true, false, runtime);
AddTestData ("随机生成器", false, false, runtime);
AddTestData ("随机生成器", true, true, runtime);
AddTestData ("随机生成器", true, false, runtime);
AddTestData ("中国", false, false, runtime);
AddTestData ("中国", true, true, runtime);
AddTestData ("中国", true, false, runtime);
}

return ret;

void AddTestData (string testName, bool isRelease, bool aot, AndroidRuntime runtime)
{
ret.Add (new object[] {
testName,
isRelease,
aot,
runtime,
});
}
}

[Test]
[TestCase ("テスト", false, false)]
[TestCase ("テスト", true, true)]
[TestCase ("テスト", true, false)]
[TestCase ("随机生成器", false, false)]
[TestCase ("随机生成器", true, true)]
[TestCase ("随机生成器", true, false)]
[TestCase ("中国", false, false)]
[TestCase ("中国", true, true)]
[TestCase ("中国", true, false)]
public void BuildAotApplicationWithSpecialCharactersInProject (string testName, bool isRelease, bool aot)
[TestCaseSource (nameof (Get_BuildAotApplicationWithSpecialCharactersInProjectData))]
public void BuildAotApplicationWithSpecialCharactersInProject (string testName, bool isRelease, bool aot, AndroidRuntime runtime)
{
if (aot && runtime == AndroidRuntime.CoreCLR) {
Assert.Ignore ("AOT + CoreCLR == NativeAOT; Not supported yet here");
return;
}

var rootPath = Path.Combine (Root, "temp", TestName);
var proj = new XamarinAndroidApplicationProject () {
ProjectName = testName,
IsRelease = isRelease,
AotAssemblies = aot,
};
proj.SetAndroidSupportedAbis ("armeabi-v7a", "arm64-v8a", "x86", "x86_64");
proj.SetRuntime (runtime);
using (var builder = CreateApkBuilder (Path.Combine (rootPath, proj.ProjectName))){
Assert.IsTrue (builder.Build (proj), "Build should have succeeded.");
}
Expand Down Expand Up @@ -156,6 +188,7 @@ public void BuildAotApplicationWithSpecialCharactersInProject (string testName,
},
};

// TODO: possibly enable NativeAOT
[Test]
[TestCaseSource (nameof (AotChecks))]
public void BuildAotApplicationWithNdkAndBundleAndÜmläüts (string supportedAbis, bool enableLLVM, bool usesAssemblyBlobs)
Expand All @@ -171,6 +204,8 @@ public void BuildAotApplicationWithNdkAndBundleAndÜmläüts (string supportedAb
PackageName = "com.xamarin.buildaotappwithspecialchars",
};

// Mono-only test
proj.SetRuntime (AndroidRuntime.MonoVM);
proj.SetProperty ("AndroidNdkDirectory", AndroidNdkPath);
proj.SetRuntimeIdentifiers (supportedAbis.Split (';'));
proj.SetProperty ("EnableLLVM", enableLLVM.ToString ());
Expand Down Expand Up @@ -227,6 +262,9 @@ public void BuildAotApplicationAndÜmläüts (string supportedAbis, bool enableL
AotAssemblies = true,
PackageName = "com.xamarin.buildaotappandbundlewithspecialchars",
};

// Mono-only test
proj.SetRuntime (AndroidRuntime.MonoVM);
proj.SetRuntimeIdentifiers (supportedAbis.Split (';'));
proj.SetProperty ("EnableLLVM", enableLLVM.ToString ());
proj.SetProperty ("AndroidUseAssemblyStore", usesAssemblyBlobs.ToString ());
Expand Down Expand Up @@ -353,6 +391,10 @@ public void NoSymbolsArgShouldReduceAppSize ([Values (false, true)] bool skipDeb
IsRelease = true,
AotAssemblies = true,
};

// Mono-only test
proj.SetRuntime (AndroidRuntime.MonoVM);

var supportedAbi = "arm64-v8a";
proj.SetAndroidSupportedAbis (supportedAbi);
proj.SetProperty ("EnableLLVM", true.ToString ());
Expand Down Expand Up @@ -393,6 +435,8 @@ public void AotAssembliesInIDE ()
IsRelease = true,
AotAssemblies = true,
};
// Mono-only test
proj.SetRuntime (AndroidRuntime.MonoVM);
proj.SetAndroidSupportedAbis (supportedAbis);
using var b = CreateApkBuilder ();
Assert.IsTrue (b.RunTarget (proj, target: "Build"));
Expand Down Expand Up @@ -423,6 +467,8 @@ public void CheckWhetherLibcAndLibmAreReferencedInAOTLibraries ()
EmbedAssembliesIntoApk = true,
AotAssemblies = true,
};
// Mono-only test
proj.SetRuntime (AndroidRuntime.MonoVM);
proj.SetProperty ("EnableLLVM", "True");

var abis = new [] { "arm64-v8a", "x86_64" };
Expand Down
Loading
Loading