.NET for Android warning XA4214

Example messages

warning XA4214: The managed type `Library1.Class1` exists in multiple assemblies: Library1, Library2. Please refactor the managed type names in these assemblies so that they are not identical.
warning XA4214: References to the type `Library1.Class1` will refer to `Library1.Class1, Library1`.

Issue

If two or more C# types from different assemblies inherit from Java.Lang.Object and share the same fully qualified name, that name will always refer to just one of the types when used in Android resource files.

Solution

The typical way to resolve this warning is to rename the types so that each fully qualified name only exists in one assembly.

Another option is to add [Register] attributes on the conflicting managed types so that each one has a unique Java type name.

A third option is to qualify the type names with the assembly name in the Android resource files. For example, use the assembly-qualified name Library1.Class1, Library rather than just Library1.Class1. This only works in places where the XML schema allows a type name within an XML attribute. One example is the class attribute on fragment elements.

If you choose to use [Register] attributes or assembly-qualified names rather than renaming the managed types, then you can hide the warnings either by adding the /warnasmessage:XA4214 switch to the MSBuild command line or by adding XA4214 to the $(MSBuildWarningsAsMessages) property in your .csproj file:

<PropertyGroup>
    <MSBuildWarningsAsMessages>XA4214</MSBuildWarningsAsMessages>
</PropertyGroup>