简体   繁体   中英

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

I have and existing android app developed with 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.

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

The problem comes because when loading the first activity and doing base.OnCreate (savedInstanceState); Bundle savedInstanceState is null.

I finally found the error by myself. It seems the xml folder gives some errors on xamarin android. I just moved the contento to layout and reference it as layout/ instead of /xml

Another solution as mentioned here

delete bin and obj folders on Android project and rebuild it

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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