errore XA1042 di .NET per Android

Messaggi di esempio

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

Issue

dotnet run avvia un'app senza avviabile <activity> tramite il relativo <instrumentation> elemento, ma l'elemento <instrumentation> trovato in AndroidManifest.xml non ha alcun attributo, quindi non esiste alcuna android:name classe da avviare.

Soluzione

Assegnare un nome all'elemento <instrumentation> . Se è dichiarato nel codice scritto a mano AndroidManifest.xml, aggiungi l'attributo:

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

Se l'elemento viene generato da una sottoclasse Android.App.Instrumentation , impostare la Name proprietà sull'attributo [Instrumentation] :

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

In alternativa, imposta il $(AndroidInstrumentation) Proprietà MSBuild corrispondente al nome della classe da avviare.