Skip to content
Merged
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: 2 additions & 0 deletions Documentation/docs-mobile/TOC.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@
href: messages/xa1048.md
- name: XA1049
href: messages/xa1049.md
- name: XA1050
href: messages/xa1050.md
- name: "XA2xxx: Linker"
items:
- name: "XA2xxx: Linker"
Expand Down
1 change: 1 addition & 0 deletions Documentation/docs-mobile/messages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ Either change the value in the AndroidManifest.xml to match the $(SupportedOSPla
+ [XA1047](xa1047.md): Required attribute '{0}' missing from element '{1}'; {2} line {3}.
+ [XA1048](xa1048.md): '{0}' does not contain an <instrumentation> element.
+ [XA1049](xa1049.md): The 'AndroidEnableMarshalMethods' and 'PublishReadyToRun' MSBuild properties cannot both be set to 'true'.
+ [XA1050](xa1050.md): The 'AndroidR8ObfuscationMode' MSBuild property has an invalid value.

## XA2xxx: Linker

Expand Down
34 changes: 34 additions & 0 deletions Documentation/docs-mobile/messages/xa1050.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: .NET for Android error XA1050
description: XA1050 error code
ms.date: 09/10/2026
f1_keywords:
- "XA1050"
---

# .NET for Android error XA1050

## Example messages

```dotnetcli
error XA1050: The 'AndroidR8ObfuscationMode' MSBuild property has an invalid value of 'private-member'. Valid values are 'disabled' and 'private-members'.
```

## Issue

The [`$(AndroidR8ObfuscationMode)`](../building-apps/build-properties.md#androidr8obfuscationmode)
MSBuild property contains an unsupported value. This property is validated when
R8 runs.

## Solution

Set `$(AndroidR8ObfuscationMode)` to one of the supported values:

```xml
<PropertyGroup>
<AndroidR8ObfuscationMode>private-members</AndroidR8ObfuscationMode>
</PropertyGroup>
```

Use `disabled` to preserve all Java names and use the legacy non-optimizing
Android R8 configuration.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Xamarin.Android.Build.Tasks/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,11 @@ To use a custom JDK path for a command line build, set the 'JavaSdkDirectory' MS
<value>The 'AndroidEnableMarshalMethods' and 'PublishReadyToRun' MSBuild properties cannot both be set to 'true'. Set one property to 'false'.</value>
<comment>The following are literal names and should not be translated: AndroidEnableMarshalMethods, PublishReadyToRun, MSBuild, true, false.</comment>
</data>
<data name="XA1050" xml:space="preserve">
<value>The 'AndroidR8ObfuscationMode' MSBuild property has an invalid value of '{0}'. Valid values are 'disabled' and 'private-members'.</value>
<comment>The following are literal names and should not be translated: AndroidR8ObfuscationMode, MSBuild, disabled, private-members.
{0} - The invalid value of the AndroidR8ObfuscationMode MSBuild property.</comment>
</data>
<data name="XA4241" xml:space="preserve">
<value>Java dependency '{0}' is not satisfied.</value>
<comment>The following are literal names and should not be translated: Java.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,27 @@ public void CheckR8MetadataFilesExist (
}
}

[TestCase ("", true)]
[TestCase ("r8", false)]
public void InvalidR8ObfuscationModeIsValidatedOnlyForR8 (string linkTool, bool expectedResult)
{
var proj = new XamarinAndroidApplicationProject {
IsRelease = true,
};
proj.SetProperty (proj.ReleaseProperties, KnownProperties.AndroidLinkTool, linkTool);
proj.SetProperty (proj.ReleaseProperties, KnownProperties.AndroidR8ObfuscationMode, "private-member");

using var builder = CreateApkBuilder ();
builder.Target = "_ValidateAndroidR8ObfuscationMode";
Comment thread
jonathanpeppers marked this conversation as resolved.
Resolved
builder.ThrowOnBuildFailure = false;
builder.AutomaticNuGetRestore = false;
Assert.AreEqual (expectedResult, builder.Build (proj), "Validation result should depend on whether R8 is enabled.");
if (!expectedResult) {
StringAssertEx.Contains ("error XA1050", builder.LastBuildOutput);
StringAssertEx.Contains ("'private-member'", builder.LastBuildOutput);
}
}

[Test]
public void CheckR8InfoMessagesToNotBreakTheBuild ([Values (AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3078,6 +3078,15 @@ because xbuild doesn't support framework reference assemblies.
Condition=" '$(AndroidApplication)' == 'True' "/>
<Import Project="$(MSBuildThisFileDirectory)Xamarin.Android.Designer.targets" />

<Target Name="_ValidateAndroidR8ObfuscationMode"
Condition=" '$(AndroidLinkTool)' == 'r8' "
BeforeTargets="_CheckForInvalidConfigurationAndPlatform">
<AndroidError Code="XA1050"
ResourceName="XA1050"
FormatArguments="$(AndroidR8ObfuscationMode)"
Condition=" '$(AndroidR8ObfuscationMode)' != 'disabled' And '$(AndroidR8ObfuscationMode)' != 'private-members' " />
</Target>

<Import Project="$(MSBuildThisFileDirectory)Xamarin.Installer.Common.targets"
Condition=" '$(DesignTimeBuild)' != 'true' "/>
<Target Name="_ValidateAndroidJcwCodegenTarget"
Expand Down
Loading