Błąd XA1042 platformy .NET dla systemu Android

Przykładowe komunikaty

error XA1042: The <instrumentation> element in 'obj/Debug/net11.0-android/android/AndroidManifest.xml' is missing the android:name attribute.

Issue

dotnet run uruchamia aplikację bez uruchamialnego <activity> za pomocą elementu <instrumentation>, ale element <instrumentation> znaleziony w pliku AndroidManifest.xml nie ma atrybutu android:name, więc nie ma klasy do uruchomienia.

Rozwiązanie

Nadaj <instrumentation> elementowi nazwę. Jeśli jest to zadeklarowane w ręcznie napisanym AndroidManifest.xml, dodaj atrybut:

<instrumentation android:name="com.companyname.myapp.MyInstrumentation" />

Jeśli element jest generowany z podklasy Android.App.Instrumentation, ustaw właściwość Name w atrybucie [Instrumentation]:

[Instrumentation (Name = "com.companyname.myapp.MyInstrumentation")]
public class MyInstrumentation : Instrumentation
{
}

Możesz też ustawić $(AndroidInstrumentation) Właściwość MSBuild ustawiona na nazwę klasy do uruchomienia.