.NET dla błędu systemu Android XA1048

Przykładowe komunikaty

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.

Issue

Aplikacja została skonfigurowana do uruchamiania przez element Android.App.Instrumentation, albo przez ustawienie $(AndroidUseInstrumentation) lub $(EnableMSTestRunner) do true, ale nie znaleziono elementu AndroidManifest.xml w <instrumentation>.

Różni się to od XA1043, który jest zgłaszany, gdy aplikacja nie ma ani uruchamialnego <activity>, ani <instrumentation>.

Rozwiązanie

Zadeklaruj instrumentację w aplikacji:

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

Możesz również nazwać klasę, aby uruchomić ją jawnie za pomocą polecenia $(AndroidInstrumentation) właściwość MSBuild lub ustaw $(AndroidUseInstrumentation) na false, aby zamiast tego uruchomić aktywność aplikacji.