Error XA1048 de .NET para Android

Mensajes de ejemplo

error XA1048: 'obj/Debug/net11.0-android/android/AndroidManifest.xml' does not contain an <instrumentation> element. Add an Android.App.Instrumentation subclass to the application, or set the $(AndroidInstrumentation) MSBuild property to the name of one.

Issue

La aplicación se configuró para iniciarse mediante un Android.App.Instrumentation, ya sea estableciendo $(AndroidUseInstrumentation) o $(EnableMSTestRunner) a true, pero no se encontró ningún <instrumentation> elemento en AndroidManifest.xml.

Esto difiere de XA1043, que se notifica cuando la aplicación no tiene ni un <activity> ejecutable ni un <instrumentation>.

Solution

Declare una instrumentación en la aplicación:

[Instrumentation (Name = "com.companyname.myapp.MyInstrumentation")]
public class MyInstrumentation : Instrumentation
{
    protected MyInstrumentation (IntPtr handle, JniHandleOwnership ownership)
        : base (handle, ownership) { }
}

También puede especificar explícitamente el nombre de la clase que se debe iniciar con . propiedad $(AndroidInstrumentation) de MSBuild, o establezca $(AndroidUseInstrumentation) en false para iniciar la actividad de la aplicación en su lugar.