简体   繁体   English

将窗口小部件添加到现有Xamarin Android应用程序时捆绑savedInstanceState null

[英]Bundle savedInstanceState null when Adding a widget to a existing Xamarin Android App

I have and existing android app developed with Xamarin . 我有和现有的 Android应用程序与Xamarin开发。

It works perfect. 它完美无缺。

I decided to create a widget for my app, and I followed Xamarin Widget Sample , http://forums.xamarin.com/discussion/22941... and Vogela Widget tutorial guidelines to add what it's needed. 我决定为我的应用程序创建一个小部件,然后我按照Xamarin Widget Samplehttp://forums.xamarin.com/discussion/22941 ...Vogela Widget教程指南来添加它所需要的内容。

Unfortunately since them the app crashes on start with this exception 不幸的是,因为他们的应用程序崩溃开始与此异常

Java.Lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.ContentFrameLayout.setId(int)' on a null object reference Java.Lang.NullPointerException:尝试在空对象引用上调用虚方法'void android.support.v7.widget.ContentFrameLayout.setId(int)'

The problem comes because when loading the first activity and doing base.OnCreate (savedInstanceState); 问题来自于加载第一个活动并执行base.OnCreate (savedInstanceState); Bundle savedInstanceState is null. Bundle savedInstanceState为null。

I finally found the error by myself. 我终于找到了自己的错误。 It seems the xml folder gives some errors on xamarin android. 似乎xml文件夹在xamarin android上给出了一些错误。 I just moved the contento to layout and reference it as layout/ instead of /xml 我只是将contento移动到布局并将其作为layout/而不是/xml引用

Another solution as mentioned here 这里提到的另一个解决方案

delete bin and obj folders on Android project and rebuild it 删除Android项目上的binobj文件夹并重建它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM