Edit

Share via


.NET for Android warning XA1005

Example messages

warning XA1005: Attempting basic type name matching for element with ID '@+id/text1' and type 'android.widget.TextView'
warning XA1005: If basic type name matching fails, please add a `xamarin:managedType` attribute to the element to specify the fully qualified managed type name of the element.

Issue

When Layout Bindings and Code-Behind are enabled, this warning will be emitted for every layout element that has the //*/@android:id attribute set and uses a fully qualified name for the element type.

For example, the warning will be emitted for both of the following elements:

<android.widget.TextView
    android:id="@+id/text1" />
<Android.Widget.TextView
    android:id="@+id/text2" />

But it will not be emitted for elements that use just an unqualified class name like:

<TextView
    android:id="@+id/text1" />

The "basic type name matching" tries to ensure that any fully qualified type name is a C# name rather than a Java name. First it checks a short list of known mappings between Java namespaces and C# namespaces, such as the mapping of android.view to Android.Views. For any remaining namespaces, it splits the namespace on . and capitalizes each part.

Solution

To resolve this warning, change each element to use its unqualified C# class name or add a xamarin:managedType attribute to each element to specify the fully qualified C# name.