Bug 42361 - DatePicker crash on Android 4.4.2 Tablet after dialog is closed
Summary: DatePicker crash on Android 4.4.2 Tablet after dialog is closed
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.3.1
Hardware: PC Windows
: Normal blocker
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-07-05 17:54 UTC by Jordi Badia
Modified: 2016-07-22 12:32 UTC (History)
7 users (show)

Tags: ac
Is this bug a regression?: Yes
Last known good build: 2.3.0


Attachments
Sample project to reproduce the crash (42.68 KB, application/x-zip-compressed)
2016-07-05 17:54 UTC, Jordi Badia
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Jordi Badia 2016-07-05 17:54:05 UTC
Created attachment 16574 [details]
Sample project to reproduce the crash

When closing the dialog of a DatePicker in Android 4.4.2 (tablet) an exception is raised. In my custom app I get the following exception (using Xamarin Forms v2.3.1.111-pre2):

System.NullReferenceException: Object reference not set to an instance of an object.
07-05 18:31:47.150 I/MonoDroid( 7337):   at Xamarin.Forms.Platform.Android.DatePickerRenderer+<>c__DisplayClass8_0.<CreateDatePickerDialog>b__0 (System.Object o, Android.App.DateSetEventArgs e) [0x00037] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\Renderers\DatePickerRenderer.cs:102 
07-05 18:31:47.150 I/MonoDroid( 7337):   at Android.App.DatePickerDialog+IOnDateSetListenerImplementor.OnDateSet (Android.Widget.DatePicker view, Int32 year, Int32 monthOfYear, Int32 dayOfMonth) [0x0000d] in /Users/builder/data/lanes/3415/7db2aac3/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.App.DatePickerDialog.cs:149 
07-05 18:31:47.150 I/MonoDroid( 7337):   at Android.App.DatePickerDialog+IOnDateSetListenerInvoker.n_OnDateSet_Landroid_widget_DatePicker_III (IntPtr jnienv, IntPtr native__this, IntPtr native_view, Int32 year, Int32 monthOfYear, Int32 dayOfMonth) [0x00011] in /Users/builder/data/lanes/3415/7db2aac3/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.App.DatePickerDialog.cs:86 
07-05 18:31:47.150 I/MonoDroid( 7337):   at (wrapper dynamic-method) System.Object:257a5201-38e9-452f-b136-dee6d5385eea (intptr,intptr,intptr,int,int,int)


In the sample I get:

07-05 19:36:48.740 I/MonoDroid(10110): System.NotSupportedException: Unable to activate instance of type Android.Content.IDialogInterfaceOnCancelListenerImplementor from native handle 0xe1000019 (key_handle 0x4195b6c0). ---> System.MissingMethodException: No constructor found for Android.Content.IDialogInterfaceOnCancelListenerImplementor::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership) ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown.
07-05 19:36:48.740 I/MonoDroid(10110): Java.Lang.Error: Exception of type 'Java.Lang.Error' was thrown.
07-05 19:36:48.740 I/MonoDroid(10110):   --- End of managed exception stack trace ---
07-05 19:36:48.750 I/MonoDroid(10110): java.lang.Error: Java callstack:
07-05 19:36:48.750 I/MonoDroid(10110): 	at mono.android.content.DialogInterface_OnCancelListenerImplementor.n_onCancel(Native Method)
07-05 19:36:48.750 I/MonoDroid(10110): 	at mono.android.content.DialogInterface_OnCancelListenerImplementor.onCancel(DialogInterface_OnCancelListenerImplementor.java:30)
07-05 19:36:48.750 I/MonoDroid(10110): 	at android.app.Dialog$ListenersHandler.handleMessage(Dialog.java:1241)
07-05 19:36:48.750 I/MonoDroid(10110): 	at android.os.Handler.dispatchMessage(Handler.java:102)
07-05 19:36:48.750 I/MonoDroid(10110): 	at android.os.Looper.loop(Looper.java:136)
07-05 19:36:48.750 I/MonoDroid(10110): 	at android.app.ActivityThread.main(ActivityThread.java:5017)
07-05 19:36:48.750 I/MonoDroid(10110): 	at java.lang.reflect.Method.invokeNative(Native Method)
07-05 19:36:48.750 I/MonoDroid(10110): 	at java.lang.reflect.Method.invoke(Method.java:515)
07-05 19:36:48.750 I/MonoDroid(10110): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
07-05 19:36:48.750 I/MonoDroid(10110): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
07-05 19:36:48.750 I/MonoDroid(10110): 	at dalvik.system.NativeStart.main(Native Method)
07-05 19:36:48.750 I/MonoDroid(10110):   --- End of inner exception stack trace ---
07-05 19:36:48.750 I/MonoDroid(10110):   at Java.Interop.TypeManager.CreateProxy (System.Type type, IntPtr handle, JniHandleOwnership transfer) [0x00039] in /Users/builder/data/lanes/3415/7db2aac3/source/monodroid/src/Mono.Android/src/Java.Interop/TypeManager.cs:304 
07-05 19:36:48.750 I/MonoDroid(10110):   at Java.Interop.TypeManager.CreateInstance (IntPtr handle, JniHandleOwnership transfer, System.Type targetType) [0x00138] in /Users/builder/data/lanes/3415/7db2aac3/source/monodroid/src/Mono.Android/src/Java.Interop/TypeManager.cs:282 
07-05 19:36:48.750 I/MonoDroid(10110):   --- End of inner exception stack trace ---
07-05 19:36:48.750 I/MonoDroid(10110):   at Java.Interop.TypeManager.CreateInstance (IntPtr handle, JniHandleOwnership transfer, System.Type targetType) [0x00186] in /Users/builder/data/lanes/3415/7db2aac3/source/monodroid/src/Mono.Android/src/Java.Interop/TypeManager.cs:289 
07-05 19:36:48.750 I/MonoDroid(10110):   at Java.Lang.Object.GetObject (IntPtr handle, JniHandleOwnership transfer, System.Type type) [0x000e5] in /Users/builder/data/lanes/3415/7db2aac3/source/monodroid/src/Mono.Android/src/Java.Lang/Object.cs:459 
07-05 19:36:48.750 I/MonoDroid(10110):   at Java.Lang.Object._GetObject[T] (IntPtr handle, JniHandleOwnership transfer) [0x0001a] in /Users/builder/data/lanes/3415/7db2aac3/source/monodroid/src/Mono.Android/src/Java.Lang/Object.cs:430 
07-05 19:36:48.750 I/MonoDroid(10110):   at Java.Lang.Object.GetObject[T] (IntPtr handle, JniHandleOwnership transfer) [0x00000] in /Users/builder/data/lanes/3415/7db2aac3/source/monodroid/src/Mono.Android/src/Java.Lang/Object.cs:422 
07-05 19:36:48.750 I/MonoDroid(10110):   at Java.Lang.Object.GetObject[T] (IntPtr jnienv, IntPtr handle, JniHandleOwnership transfer) [0x00006] in /Users/builder/data/lanes/3415/7db2aac3/source/monodroid/src/Mono.Android/src/Java.Lang/Object.cs:416 
07-05 19:36:48.750 I/MonoDroid(10110):   at Android.Content.IDialogInterfaceOnCancelListenerInvoker.n_OnCancel_Landroid_content_DialogInterface_ (IntPtr jnienv, IntPtr native__this, IntPtr native_dialog) [0x00000] in /Users/builder/data/lanes/3415/7db2aac3/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Content.IDialogInterface.cs:80 
07-05 19:36:48.750 I/MonoDroid(10110):   at (wrapper dynamic-method) System.Object:ca8152ee-f668-4a4a-b427-db4b72f46739 (intptr,intptr,intptr)

In the sample project, first I tried with Xamarin Forms v2.0.0.6482 and v2.3.0.107 and both worked.
Comment 1 Jordi Badia 2016-07-05 18:08:27 UTC
I forgot to mention that the DatePicker work as expected in both apps on a smartphone with Android 4.4.2
Comment 2 Samantha Houts [MSFT] 2016-07-05 18:28:38 UTC
Confirmed on pre-Lollipop emulators.
Comment 3 Jani Lirkki 2016-07-07 06:08:09 UTC
This occurs to me on my Android 5.1.1 device as well, seems to be regression in Xamarin Forms 2.3.1.111-pre2 compared to 2.3.0 builds.
Comment 4 Rui Marinho 2016-07-13 10:13:52 UTC
Should be fixed in 2.3.1-pre3
Comment 5 Jani Lirkki 2016-07-20 06:18:18 UTC
I tested with XF version 2.3.1.113-pre3 and it still crashes if I open the datepicker, change the date and close the datepicker. Here is the call stack:

System.NullReferenceException: Object reference not set to an instance of an object.
  at Xamarin.Forms.Platform.Android.DatePickerRenderer+<>c__DisplayClass8_0.<CreateDatePickerDialog>b__0 (System.Object o, Android.App.DateSetEventArgs e) [0x0003e] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\Renderers\DatePickerRenderer.cs:108 
  at Android.App.DatePickerDialog+IOnDateSetListenerImplementor.OnDateSet (Android.Widget.DatePicker view, Int32 year, Int32 monthOfYear, Int32 dayOfMonth) [0x0000d] in /Users/builder/data/lanes/3415/7db2aac3/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.App.DatePickerDialog.cs:149 
  at Android.App.DatePickerDialog+IOnDateSetListenerInvoker.n_OnDateSet_Landroid_widget_DatePicker_III (IntPtr jnienv, IntPtr native__this, IntPtr native_view, Int32 year, Int32 monthOfYear, Int32 dayOfMonth) [0x00011] in /Users/builder/data/lanes/3415/7db2aac3/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.App.DatePickerDialog.cs:86 
  at (wrapper dynamic-method) System.Object:01017f45-9060-4bcc-8e98-802c17920561 (intptr,intptr,intptr,int,int,int)
Comment 6 Paul DiPietro [MSFT] 2016-07-21 18:54:47 UTC
Can you wipe the bin/obj folders and do a clean and rebuild? I just tested the repro project against a tablet emulator running KitKat (4.4.4) and it crashes on pre2 but not on pre3, so unless there's something going on between 4.4.2 and 4.4.4, this should presumably be functioning correctly.
Comment 7 Paul DiPietro [MSFT] 2016-07-21 18:56:10 UTC
Or based on your other comment, is this 5.1.1 that this is happening on? I apologize for any confusion on my end here.
Comment 8 Jani Lirkki 2016-07-21 19:01:03 UTC
5.1.1 it is for me.
Comment 9 Paul DiPietro [MSFT] 2016-07-21 19:50:01 UTC
I just tested it against both phone and tablet emulators running 5.1.1 with no apparent issues. If this is installed on a physical device, please also try uninstalling the app from it if you haven't already.
Comment 10 Parmendra Kumar 2016-07-22 12:32:00 UTC
I have checked this issue with Xamarin.Forms 2.3.1.113-pre3 and Android 4.4.2 and its working fine at my end.