Bug 46563 - Adding ListView in Custom control crashes in Android
Summary: Adding ListView in Custom control crashes in Android
Status: ASSIGNED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android (show other bugs)
Version: 2.3.1
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: David Ortinau [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2016-11-08 09:20 UTC by Paul Anderson
Modified: 2017-06-19 21:46 UTC (History)
10 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
A simple sample is created using the custom control (1.49 MB, application/zip)
2016-11-15 05:26 UTC, Paul Anderson
Details

Description Paul Anderson 2016-11-08 09:20:57 UTC
This code works fine on iOS and UWP however on android it crashes. If I comment out the mainStack.Children.Add(listView) line all works ok. In Addition to the above, the same code works fine with Xamarin old version(2.3.1.114) after updating to the latest one this crashes occurs.

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;
    }
Comment 1 adrianknight89 2016-11-08 15:04:55 UTC
Can you attach a project instead of a code snippet?
Comment 2 Paul Anderson 2016-11-15 05:26:29 UTC
Created attachment 18463 [details]
A simple sample is created using the custom control

Please run the sample in newer version of Xamarin.Forms(2.3.1.127)
Comment 3 Paul Anderson 2016-11-15 05:28:44 UTC
Hi,
Sample is attached as per your request please check.
Comment 4 adrianknight89 2016-11-27 21:56:13 UTC
I don't have access to Syncfusion. Are you able to create a simpler repro without that library? I suspect that SetElement is passed a null object. This might be a problem with the library you're using rather than XF.
Comment 5 adrianknight89 2016-11-27 21:58:08 UTC
Ugh. Nvm. Just noticed that you're from SF. :) I'll check what was changed after 2.3.1.114.
Comment 6 adrianknight89 2016-11-27 22:21:31 UTC
I'm not sure if your issue is at all related to this: https://bugzilla.xamarin.com/show_bug.cgi?id=47911, but it's something to keep in mind. If you are implementing a custom carousel view, make sure the items have a Parent & Platform.

Can you attach a repro with the missing dlls so I can compile and run it? Otherwise XF team can pick this up :)
Comment 7 Paul Anderson 2016-11-29 05:03:13 UTC
Hi,

The issue have resolved now, thank you for your updates.
Comment 8 Paul Anderson 2016-12-16 08:43:01 UTC
Hi,

The issue is still persists even after updating to Xamarin.Forms version 2.3.3.175.(But works well in 2.3.3.114 and older version).
Comment 9 Paul Anderson 2016-12-16 08:46:08 UTC
Sorry for the misconception it is Xamarin.Forms version 2.3.1.175 and 2.3.1.114
Comment 10 adrianknight89 2016-12-16 16:11:53 UTC
Did you update to 2.3.3(not 1).175? Does the issue exist there?
Comment 11 Paul Anderson 2016-12-20 07:22:15 UTC
Yes,I have updated to the latest version(2.3.1.175),but still the issue persists.
Comment 12 Namyslaw Szymaniuk 2017-01-16 10:41:36 UTC
Issue occurs also to me, at 2.3.3.180, as well as at lestest pre version 2.3.4.184-pre1, when I'm using Syncfusion SfNavigationDrawer.

It's reproducible even at sample project, delivered by Syncfusion - http://files2.syncfusion.com/Xamarin.Forms/Samples/NavigationDrawer_GettingStarted.zip

When I'm not puting ListView into SfNavigationDrawer, there is no issue.
Comment 13 Halil Dogan Bolak 2017-04-11 12:54:19 UTC
Same problem persists with Xamarin.Forms 2.3.4.224 and Syncfusion 15.1.0.33 !
Comment 14 Chris King 2017-06-19 16:37:16 UTC
Assigned to you because it was resolved by a customer.

Note You need to log in before you can comment on or make changes to this bug.