Edit

.NET for Android error XA1043

Example messages

error XA1043: Could not determine what to launch: 'obj/Debug/net11.0-android/android/AndroidManifest.xml' does not contain a launchable <activity> or an <instrumentation> element. Set the $(AndroidLaunchActivity) or $(AndroidInstrumentation) MSBuild property to specify one.

Issue

dotnet run needs something to launch on the device. It looks for a launchable <activity> in AndroidManifest.xml, and falls back to an <instrumentation> element for apps that have no user interface, such as a benchmark host. Neither was found.

Solution

Declare an activity with a MAIN/LAUNCHER intent filter:

[Activity (MainLauncher = true)]
public class MainActivity : Activity
{
}

Or, for an app that has no activity, declare an instrumentation:

[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 $(AndroidLaunchActivity) or $(AndroidInstrumentation) MSBuild properties.