.NET for Android error/warning XA1023

Example messages

error XA1023: Using the DX DEX Compiler is not supported. Please set the DEX compiler to 'd8' in the Visual Studio project property pages or edit the project file in a text editor and set the 'AndroidDexTool' MSBuild property to 'd8'.
warning XA1023: Using the DX DEX Compiler is deprecated. Please set the DEX compiler to 'd8' in the Visual Studio project property pages or edit the project file in a text editor and set the 'AndroidDexTool' MSBuild property to 'd8'.
error XA1023: Using the DX DEX Compiler is not supported in .NET for Android projects that target .NET 6 or higher. Please set the DEX compiler to 'd8' in the Visual Studio project property pages or edit the project file in a text editor and set the 'AndroidDexTool' MSBuild property to 'd8'.

Issue

Google has deprecated the DX DEX Compiler in favor of the D8 DEX Compiler. On February 1, 2021, DX will no longer be a part of Android SDK or Android Studio.

The DX DEX Compiler will not supported in .NET 6 or higher, nor in .NET for Android 12.4 and higher.

Solution

Update the $(AndroidDexTool) MSBuild property to d8 to select the D8 DEX Compiler. This property corresponds to the Dex compiler setting in the Visual Studio project properties pages. Alternatively, remove <AndroidDexTool> from the .csproj file to let the build select the default value d8.