示例消息
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
应用程序选择通过 Android.App.Instrumentation启动,方式之一是设置
$(AndroidUseInstrumentation) 或
$(EnableMSTestRunner) 到 true,但在 AndroidManifest.xml 中未找到 <instrumentation> 元素。
这与 XA1043 不同;后者是在应用程序既没有可启动的 <activity>,也没有 <instrumentation> 时报告的。
解决方案
在应用程序中声明一个插桩组件:
[Instrumentation (Name = "com.companyname.myapp.MyInstrumentation")]
public class MyInstrumentation : Instrumentation
{
protected MyInstrumentation (IntPtr handle, JniHandleOwnership ownership)
: base (handle, ownership) { }
}
你还可以使用以下内容显式指定要启动的类
$(AndroidInstrumentation) MSBuild 属性,或者将 $(AndroidUseInstrumentation) 设置为 false,以转而启动应用程序的 Activity。