-
Notifications
You must be signed in to change notification settings - Fork 533
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Xamarin.Android.Build.Tasks] XA1030 for AOT + PublishTrimmed=false (#…
…7406) Fixes: #7178 Using this combination on .NET 6+: <PropertyGroup Condition=" '$(Configuration)' == 'Release' "> <RunAOTCompilation>true</RunAOTCompilation> <PublishTrimmed>false</PublishTrimmed> </PropertyGroup> Causes apps to crash at runtime with: D Mono : AOT: module Microsoft.Maui.dll.so is unusable (GUID of dependent assembly Xamarin.AndroidX.AppCompat doesn't match (expected '1FC81757-8A70-4D56-93E6-8A635E2C23DE', got 'FD3821D1-CBF4-4956-B930-EA2A5379E18D')). AOT runs right after the `<ILLink/>` MSBuild task, and so this combination currently doesn't work when trimming is disabled. For now, solve this by emitting an `XA1030` error and fail the build. This way you at least get a reasonable error at build time instead of at runtime. I do not know of a scenario when it would be useful to disable trimming completely during a `Release` + AOT build. If you are hitting a trimming/linker issue, you would be better off preserving a single assembly, type, etc.
- Loading branch information
1 parent
a425844
commit 0515d1d
Showing
6 changed files
with
65 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
title: Xamarin.Android error XA1030 | ||
description: XA1030 error code | ||
ms.date: 09/26/2022 | ||
--- | ||
# Xamarin.Android error XA1030 | ||
|
||
## Example messages | ||
|
||
``` | ||
The 'RunAOTCompilation' MSBuild property is only supported when trimming is enabled. Edit the project file in a text editor to set 'PublishTrimmed' to 'true' for this build configuration. | ||
``` | ||
|
||
## Solution | ||
|
||
Instead of using: | ||
|
||
```xml | ||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> | ||
<RunAOTCompilation>true</RunAOTCompilation> | ||
<!-- Either of these disable the linker/trimmer --> | ||
<PublishTrimmed>false</PublishTrimmed> | ||
<AndroidLinkMode>None</AndroidLinkMode> | ||
</PropertyGroup> | ||
``` | ||
|
||
Use the default value for `$(PublishTrimmed)` and `$(AndroidLinkMode)` | ||
instead: | ||
|
||
```xml | ||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> | ||
<RunAOTCompilation>true</RunAOTCompilation> | ||
</PropertyGroup> | ||
``` | ||
|
||
Additionally, as mentioned by [`XA0119`](xa0119.md), you should not | ||
use `$(RunAOTCompilation)` in `Debug` configurations. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters