android listview crashes not on iOS or UWP

This code works fine on iOS and UWP however on android it crashes. If I comment out hte mainStack.Children.Add(listView) line all works ok.

From output window
10-14 19:53:33.768 D/Mono ( 2550): Found as 'java_interop_jnienv_call_void_method'.
10-14 19:53:33.772 D/Mono ( 2550): Assembly Ref addref Xamarin.Forms.Platform.Android[0xa3ad5f80] -> Xamarin.Android.Support.v7.AppCompat[0xa3ad5b60]: 2
Unhandled Exception:

System.NullReferenceException: Object reference not set to an instance of an object.

10-14 19:53:40.964 D/Mono ( 2550): [0x8f47f920] worker finishing
Thread finished: #3
The thread 'Unknown' (0x3) has exited with code 0 (0x0).

From call stack
0x118 in Xamarin.Forms.Platform.Android.VisualElementRenderer<Xamarin.Forms.View>.SetElement at C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:193,5 C#
0x2E in Xamarin.Forms.Platform.Android.VisualElementRenderer<Xamarin.Forms.View>.Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement at C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:126,4 C#
0x21 in Xamarin.Forms.Platform.Android.Platform.CreateRenderer at C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\Platform.cs:289,4 C#
0xFC in Xamarin.Forms.Platform.Android.VisualElementRenderer<Syncfusion.SfNavigationDrawer.XForms.SfNavigationDrawer>.SetElement at C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:190,4 C#
0x2E in Xamarin.Forms.Platform.Android.VisualElementRenderer<Syncfusion.SfNavigationDrawer.XForms.SfNavigationDrawer>.Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement at C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:126,4 C#
0x21 in Xamarin.Forms.Platform.Android.Platform.CreateRenderer at C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\Platform.cs:289,4 C#

public View getDrawerContent()
{
StackLayout mainStack = new StackLayout();
mainStack.Opacity = 1;
mainStack.Orientation = StackOrientation.Vertical;
mainStack.HeightRequest = 500;
mainStack.BackgroundColor = Color.White;

        /*ObservableCollection<String> list = new ObservableCollection<string>();
        list.Add("Home");
        list.Add("Health Data");
        list.Add("Doctors");
        list.Add("Symptoms");
        */

        ListView listView = new ListView();

        listView.WidthRequest = 50;
        listView.VerticalOptions = LayoutOptions.FillAndExpand;
        listView.ItemsSource = new string[]{

"Home",
"Health Data",
"Doctors",
"Symptoms"

};

        listView.ItemSelected += ListView_ItemSelected;
        mainStack.Children.Add(listView);
        return mainStack;
    }

Answers

  • batmacibatmaci DEMember ✭✭✭✭✭

    Is that also happening with Mvvm Binding? Have you tested it?

  • batmacibatmaci DEMember ✭✭✭✭✭
    edited December 2016

    Wow.. this is still problem using the latest version.

  • HalilDoganBolakHalilDoganBolak USMember ✭✭
    edited April 2017

    I am also getting this error - Xamarin.Forms 2.3.4.224 and Syncfusion 15.1.0.33 - the latest versions available. Does anyone have a solution to SfNavigationDrawer crashing on Xamarin Android when a ListView is assigned to it as menu options - exactly as shown above ?

    This bug has been reported here - https://bugzilla.xamarin.com/show_bug.cgi?id=46563

  • HalilDoganBolakHalilDoganBolak USMember ✭✭

    Upgrading Syncfusion to 15.1.0.41 from 15.1.0.37 solved this error !

Sign In or Register to comment.