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
2 changes: 1 addition & 1 deletion Documentation/docs-mobile/messages/xa0119.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Remove the following from `Release` configurations:

* `<AndroidEnableFastDeployment>False</AndroidEnableFastDeployment>`
* `<AotAssemblies>True</AotAssemblies>` or in .NET 6 `<RunAOTCompilation>True</RunAOTCompilation>`
* `<PublishReadyToRun>True</PublishReadyToRun>` (for CoreCLR)
* `<PublishReadyToRun>True</PublishReadyToRun>` (for CoreCLR, when trimming is enabled)

Consider submitting a [bug][bug] if you are getting one of these
warnings under normal circumstances.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ This file contains the CoreCLR-specific MSBuild logic for .NET for Android.
<PropertyGroup Condition=" '$(AndroidApplication)' == 'true' ">
<!-- Default PublishReadyToRun to true for CoreCLR Release mode and publish builds without debug symbols -->
<PublishReadyToRun Condition=" '$(PublishReadyToRun)' == '' and ('$(Configuration)' == 'Release' or ('$(_IsPublishing)' == 'true' and '$(DebugSymbols)' != 'true')) ">true</PublishReadyToRun>
<_AndroidReadyToRunWithoutTrimming Condition=" '$(PublishReadyToRun)' == 'true' and '$(PublishTrimmed)' != 'true' ">true</_AndroidReadyToRunWithoutTrimming>
<PublishReadyToRun Condition=" '$(_AndroidReadyToRunWithoutTrimming)' == 'true' ">false</PublishReadyToRun>
<PublishReadyToRunComposite Condition=" '$(_AndroidReadyToRunWithoutTrimming)' == 'true' ">false</PublishReadyToRunComposite>
<PublishReadyToRunComposite Condition=" '$(PublishReadyToRunComposite)' == '' and '$(PublishReadyToRun)' == 'true' ">true</PublishReadyToRunComposite>
<_IsPublishing Condition=" '$(_IsPublishing)' == '' and '$(PublishReadyToRun)' == 'true' ">true</_IsPublishing>
<AllowReadyToRunWithoutRuntimeIdentifier Condition=" '$(PublishReadyToRun)' == 'true' and '$(RuntimeIdentifiers)' != '' ">true</AllowReadyToRunWithoutRuntimeIdentifier>
Expand Down
4 changes: 4 additions & 0 deletions src/Xamarin.Android.Build.Tasks/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@ The term "lock file" comes from NuGet. For example, search for "UnauthorizedLock
<value>Using fast deployment and ReadyToRun at the same time is not recommended. Use fast deployment for Debug configurations and ReadyToRun for Release configurations.</value>
<comment>The following are literal names and should not be translated: ReadyToRun, Debug, Release.</comment>
</data>
<data name="XA0119_ReadyToRunWithoutTrimming" xml:space="preserve">
<value>ReadyToRun has been disabled because trimming is disabled. Set the 'PublishTrimmed' MSBuild property to 'true' to use ReadyToRun.</value>
<comment>The following are literal names and should not be translated: ReadyToRun, 'PublishTrimmed', 'true'.</comment>
</data>
<data name="XA0121" xml:space="preserve">
<value>Assembly '{0}' is using '[assembly: {1}]', which is no longer supported. Use a newer version of this NuGet package or notify the library author.</value>
<comment>The following are literal names and should not be translated: [assembly: {1}], NuGet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2306,21 +2306,6 @@ public void CheckLintResourceFileReferencesAreFixed ([Values (AndroidRuntime.Cor
// TODO: [TestCase (false, AndroidRuntime.NativeAOT)]
public void SimilarAndroidXAssemblyNames (bool publishTrimmed, AndroidRuntime runtime)
{
if (!publishTrimmed && runtime == AndroidRuntime.CoreCLR) {
// This currently fails with the following exception:
//
// error XALNS7015: System.NotSupportedException: Writing mixed-mode assemblies is not supported
// at Mono.Cecil.ModuleWriter.Write(ModuleDefinition module, Disposable`1 stream, WriterParameters parameters)
// at Mono.Cecil.ModuleWriter.WriteModule(ModuleDefinition module, Disposable`1 stream, WriterParameters parameters)
// at Mono.Cecil.ModuleDefinition.Write(String fileName, WriterParameters parameters)
// at Mono.Cecil.AssemblyDefinition.Write(String fileName, WriterParameters parameters)
// at Xamarin.Android.Tasks.SaveChangedAssemblyStep.ProcessAssembly(AssemblyDefinition assembly, StepContext context) in src/Xamarin.Android.Build.Tasks/Tasks/AssemblyModifierPipeline.cs:line 197
// at Xamarin.Android.Tasks.AssemblyPipeline.Run(AssemblyDefinition assembly, StepContext context) in src/Xamarin.Android.Build.Tasks/Utilities/AssemblyPipeline.cs:line 26
// at Xamarin.Android.Tasks.AssemblyModifierPipeline.RunPipeline(AssemblyPipeline pipeline, ITaskItem source, ITaskItem destination) in src/Xamarin.Android.Build.Tasks/Tasks/AssemblyModifierPipeline.cs:line 175
Assert.Ignore ("CoreCLR: fails because of a Mono.Cecil lack of support");
return;
}

bool aotAssemblies = runtime == AndroidRuntime.MonoVM && publishTrimmed;
var proj = new XamarinAndroidApplicationProject {
IsRelease = true,
Expand All @@ -2337,6 +2322,24 @@ public void SimilarAndroidXAssemblyNames (bool publishTrimmed, AndroidRuntime ru
Assert.IsTrue (builder.Build (proj), "Build should have succeeded.");
}

[Test]
public void FixAbstractMethodsOnReadyToRunAssembly ()
{
var proj = new XamarinAndroidApplicationProject {
IsRelease = true,
PackageReferences = {
new Package { Id = "Xamarin.AndroidX.CustomView", Version = "1.1.0.17" },
new Package { Id = "Xamarin.AndroidX.CustomView.PoolingContainer", Version = "1.0.0.4" },
}
};
proj.SetRuntime (AndroidRuntime.CoreCLR);
proj.SetProperty (KnownProperties.PublishTrimmed, false.ToString ());
proj.MainActivity = proj.DefaultMainActivity.Replace ("//${AFTER_ONCREATE}", "AndroidX.CustomView.PoolingContainer.PoolingContainer.IsPoolingContainer (null);");
using var builder = CreateApkBuilder ();
Assert.IsTrue (builder.Build (proj), "Build should have succeeded.");
StringAssertEx.Contains ("warning XA0119: ReadyToRun has been disabled because trimming is disabled.", builder.LastBuildOutput);
}

[Test]
public void IncrementalBuildDifferentDevice ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public void BasicApplicationPublishReadyToRunCustomConfiguration ([Values] bool
proj.SetProperty ("AndroidEnableAssemblyCompression", "false");
proj.SetProperty ("Optimize", "true");
proj.SetProperty ("DebugType", "None");
proj.SetProperty ("PublishTrimmed", "true");
proj.SetProperty ("PublishReadyToRunComposite", isComposite.ToString ());

// Use `dotnet publish` rather than `msbuild /t:Publish`: only the `dotnet publish` CLI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,10 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved.
ResourceName="XA0119_ReadyToRun"
Condition=" '$(AndroidEnableFastDeployment)' == 'True' And '$(PublishReadyToRun)' == 'True' "
/>
<AndroidWarning Code="XA0119"
ResourceName="XA0119_ReadyToRunWithoutTrimming"
Condition=" '$(_AndroidReadyToRunWithoutTrimming)' == 'true' "
/>
<AndroidWarning Code="XA1027"
ResourceName="XA1027"
Condition=" $(_AndroidXA1027) == 'true' "
Expand Down