.NET for Android warning XA1027

Example messages

warning XA1027: The 'EnableProguard' MSBuild property is set to 'true' and the 'AndroidLinkTool' MSBuild property is empty, so 'AndroidLinkTool' will default to 'proguard'.
error XA1011: Using ProGuard with the D8 DEX compiler is no longer supported. Please set the code shrinker to 'r8' in the Visual Studio project property pages or edit the project file in a text editor and set the 'AndroidLinkTool' MSBuild property to 'r8'.

Issue

The project is currently configured to use the D8 DEX compiler and has the older EnableProguard MSBuild property set to true without any value set for the newer AndroidLinkTool MSBuild property. This results in an XA1011 error because the ProGuard code shrinker is no longer compatible with the D8 DEX compiler.

Solution

  1. Edit the project file in Visual Studio or another text editor and remove all of the old <EnableProguard> elements.

  2. After saving the project file, open it in Visual Studio as usual and set the Code shrinker in the Visual Studio project properties pages to r8, or continue editing the project file in the text editor and set the AndroidLinkTool MSBuild property to r8:

    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
      <AndroidLinkTool>r8</AndroidLinkTool>
    </PropertyGroup>
    

R8 might in some cases produce new build warnings or errors compared to ProGuard, so the ProGuard rules for the project might require a few updates to resolve any new warnings or errors that appear after this change.