Edit

.NET for Android error XA1049

Example messages

error XA1049: The 'AndroidEnableMarshalMethods' and 'PublishReadyToRun' MSBuild properties cannot both be set to 'true'. Set one property to 'false'.

Issue

$(AndroidEnableMarshalMethods) rewrites managed assemblies after trimming, while $(PublishReadyToRun) adds native code to those assemblies. The marshal methods rewriter cannot modify ReadyToRun assemblies.

Solution

Disable marshal methods or ReadyToRun in the project file:

<PropertyGroup>
  <AndroidEnableMarshalMethods>false</AndroidEnableMarshalMethods>
</PropertyGroup>

Alternatively:

<PropertyGroup>
  <PublishReadyToRun>false</PublishReadyToRun>
</PropertyGroup>