Edit

.NET for Android error XA1048

Example messages

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

The application opted into launching through an Android.App.Instrumentation, either by setting $(AndroidUseInstrumentation) or $(EnableMSTestRunner) to true, but no <instrumentation> element was found in AndroidManifest.xml.

This differs from XA1043, which is reported when the application has neither a launchable <activity> nor an <instrumentation>.

Solution

Declare an instrumentation in the application:

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

You can also name the class to launch explicitly with the $(AndroidInstrumentation) MSBuild property, or set $(AndroidUseInstrumentation) to false to launch the application's activity instead.