.NET voor Android-foutcode XA1048

Voorbeeldberichten

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

De toepassing heeft gekozen voor het starten via een Android.App.Instrumentation, hetzij door instelling $(AndroidUseInstrumentation) of $(EnableMSTestRunner) aan true, maar er is geen <instrumentation> element gevonden in AndroidManifest.xml.

Dit verschilt van XA1043, dat wordt gerapporteerd wanneer de toepassing geen uitvoerbare <activity> en ook geen <instrumentation> heeft.

Solution

Declareer een instrumentatie in de toepassing:

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

U kunt de klasse ook expliciet een naam geven om te starten met de $(AndroidInstrumentation) MSBuild-eigenschap, of stel $(AndroidUseInstrumentation) in op false om in plaats daarvan de activiteit van de toepassing te starten.