Created attachment 15124 [details]
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.
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.
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."
I have checked this issue with Xamarin.Forms 188.8.131.52-pre1 and observed that this issue has been fixed.
Hence closing this issue.