|Summary:||[Android] NullReferenceException when using a custom ViewCellRenderer|
|Product:||Forms||Reporter:||Michael Rumpler <michael>|
|Severity:||normal||CC:||adrianknight89, cody.beyer, ehart, matthias.hacker, parmendrak, rwagh|
|Tags:||Is this bug a regression?:||---|
|Last known good build:|
Description Michael Rumpler 2016-02-22 14:43:30 UTC
Created attachment 15124 [details] repro project When you create a custom ViewCell which adds some elements to its View and that custom ViewCell uses a custom renderer in the Android project, then there will be a NullReferenceException after the custom renderers GetCellCore method successfully returned the cell. The exception is raised here: at Xamarin.Forms.Platform.Android.ConditionalFocusLayout.ApplyTouchListenersToSpecialCells (Xamarin.Forms.Cell item) [0x0008f] in <filename unknown>:0 at Xamarin.Forms.Platform.Android.TableViewModelRenderer.GetView (Int32 position, Android.Views.View convertView, Android.Views.ViewGroup parent) [0x00153] in <filename unknown>:0 at Android.Widget.BaseAdapter.n_GetView_ILandroid_view_View_Landroid_view_ViewGroup_ (IntPtr jnienv, IntPtr native__this, Int32 position, IntPtr native_convertView, IntPtr native_parent) [0x0001a] in /Users/builder/data/lanes/2692/e98e9627/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Widget.BaseAdapter.cs:509 at (wrapper dynamic-method) System.Object:8ed84031-e813-4601-b703-371118af0f60 (intptr,intptr,int,intptr,intptr) The bug can be reproduced with the attached project which uses XF 2.1.0-pre4. You can work around this bug when you do not assign anything to the custom ViewCells View property or do not call InitializeComponent if you defined it in xaml. This bug is a duplicate of bug #29210. That bug has been created on 2015-04-17 for XF 1.4.1 and set to resolved fixed by Rui Marinho on 2015-06-03. But as several others pointed out afterwards, the bug is not fixed. I asked Rui and Anubhav Ranjan (who created it) to reopen 29210, but they did not respond. So I created a duplicate where I can control the status.
Comment 1 toSilence 2016-03-10 13:49:22 UTC
We have the same issiue - looks like the a null comparison is missing in that method. It should be easy and fast to fix and we really need this. Or a workaround.
Comment 2 rwagh 2016-03-21 10:29:06 UTC
i tried workaround mentioned at http://forums.xamarin.com/discussion/comment/110003/#Comment_110003 and it worked for me "I resolved the issue by changing my ViewCells to derive from Cell and use CellRenderer. Of course, this requires all of your UI code to be in platform specific projects. Mine already was so it wasn't a big issue for me. If you're relying on Xam Forms for your layout then this approach would not work."
Comment 3 adrianknight89 2016-11-27 21:44:58 UTC
Comment 4 Parmendra Kumar 2017-02-01 18:10:28 UTC
I have checked this issue with Xamarin.Forms 22.214.171.124-pre1 and observed that this issue has been fixed. Hence closing this issue. Thanks.