.NET for Android XA1042 hiba

Példaüzenetek

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

Issue

dotnet run elindít egy alkalmazást indítható <instrumentation> nélkül a <activity> elemén keresztül, de a AndroidManifest.xml fájlban található <instrumentation> elemnek nincs android:name attribútuma, ezért nincs indítható osztály.

Megoldás

Adjon nevet az <instrumentation> elemnek. Ha a kézzel írt AndroidManifest.xml fájlban van deklarálva, adja hozzá az attribútumot:

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

Ha az elem egy Android.App.Instrumentation alosztályból jön létre, állítsa be a Name tulajdonságot az [Instrumentation] attribútumon:

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

Alternatív megoldásként állítsa be a $(AndroidInstrumentation) MSBuild tulajdonság az elindítandó osztálynévhez.