.NET for Android エラー XA1042

メッセージの例

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

Issue

dotnet runは、<instrumentation>要素を介して起動可能な<activity>なしでアプリを起動しますが、AndroidManifest.xmlで見つかった<instrumentation>要素にはandroid:name属性がないため、起動するクラスはありません。

ソリューション

<instrumentation>要素に名前を付けます。 手書きの AndroidManifest.xmlで宣言されている場合は、属性を追加します。

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

要素がAndroid.App.Instrumentationサブクラスから生成される場合は、[Instrumentation]属性にNameプロパティを設定します。

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

または、次を設定します $(AndroidInstrumentation) 起動するクラス名を指定する MSBuild プロパティ。