.NET pro Android – chyba XA1048

Ukázkové zprávy

error XA1048: 'obj/Debug/net11.0-android/android/AndroidManifest.xml' does not contain an <instrumentation> element. Add an Android.App.Instrumentation subclass to the application, or set the $(AndroidInstrumentation) MSBuild property to the name of one.

Problém

Aplikace se rozhodla pro spouštění prostřednictvím prvku Android.App.Instrumentation, a to buď nastavením $(AndroidUseInstrumentation) nebo $(EnableMSTestRunner) do true, ale nebyl nalezen žádný <instrumentation> prvek v AndroidManifest.xml.

To se liší od XA1043, která se hlásí, když aplikace neobsahuje ani spustitelný <activity>, ani <instrumentation>.

Řešení

Deklarujte instrumentaci v aplikaci:

[Instrumentation (Name = "com.companyname.myapp.MyInstrumentation")]
public class MyInstrumentation : Instrumentation
{
    protected MyInstrumentation (IntPtr handle, JniHandleOwnership ownership)
        : base (handle, ownership) { }
}

Název třídy, která se má spustit, můžete také explicitně uvést pomocí $(AndroidInstrumentation) vlastnost MSBuild nebo místo toho nastavte $(AndroidUseInstrumentation) na false, aby se spustila aktivita aplikace.