我有一个Xamarin.Forms项目。这是项目Android部分的MainActivity.cs:
[Activity(Label = "MyApp.Droid", Icon = "@drawable/icon", Theme = "@style/MyTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity {
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
}
}
每当我尝试在我的设备上进行测试时,我会收到Android.Util.AndroidRuntimeException
,其中包含以下消息:requestFeature() must be called before adding content
,即使我根本不打电话给requestFeature()
。这是堆栈跟踪:
--- End of managed Android.Util.AndroidRuntimeException stack trace ---
android.util.AndroidRuntimeException: requestFeature() must be called before adding content
at com.android.internal.policy.PhoneWindow.requestFeature(PhoneWindow.java:338)
at md5f4656b392f6d15b90a32ccb2cb36af91.MainActivity.n_onCreate(Native Method)
at md5f4656b392f6d15b90a32ccb2cb36af91.MainActivity.onCreate(MainActivity.java:29)
at android.app.Activity.performCreate(Activity.java:6672)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1140)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2612)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2724)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6123)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:107)
我已经尝试重新启动Xamarin Studio并清理/重建我的解决方案。我错过了什么?
编辑:刚刚创建了一个新的空白Xamarin.Forms项目。它完全在我的设备上运行。仍然无法让旧项目运行。
答案 0 :(得分:0)
解决方案: