Bug 38769 - Null exception from DatePicker on Android API level 16 with Xamarin.Forms
Summary: Null exception from DatePicker on Android API level 16 with Xamarin.Forms
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.1.0
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-02-15 16:17 UTC by oddbjorn.bakke
Modified: 2018-01-04 09:29 UTC (History)
6 users (show)

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

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 oddbjorn.bakke 2016-02-15 16:17:32 UTC
I get a Java.Lang.NullPointerException when setting minimum date on a DatePicker in API 16.
Exception is thrown when clicking on the control, when the date dialog should have been opened.

Tested on GT-P3110 (Samsung Galaxy Tab 2 7")
Works in Xamarin Forms 1.3.5.6335, but not in version 2.0.1.6505.
Works with both versions on Nexus 5X (API 23).

Code to reproduce(PCL):

//Fails on: 2.0.1.6505
//Works on: 1.3.5.6335
var dt = new DatePicker ();
dt.MinimumDate = DateTime.Today;
dt.MaximumDate = DateTime.Today.AddDays (7);
// The root page of your application
MainPage = new ContentPage {
   Content = new StackLayout {
      VerticalOptions = LayoutOptions.Center,
         Children = {
            dt
      }
   }
};

  --- End of managed exception stack trace ---
java.lang.NullPointerException
	at android.widget.CalendarView.onScroll(CalendarView.java:1224)
	at android.widget.CalendarView.access$900(CalendarView.java:76)
	at android.widget.CalendarView$2.onScroll(CalendarView.java:1085)
	at android.widget.AbsListView.invokeOnItemScrollListener(AbsListView.java:1520)
	at android.widget.ListView.layoutChildren(ListView.java:1707)
	at android.widget.AbsListView.onLayout(AbsListView.java:2300)
	at android.view.View.layout(View.java:14061)
	at android.view.ViewGroup.layout(ViewGroup.java:4376)
	at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655)
	at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1513)
	at android.widget.LinearLayout.onLayout(LinearLayout.java:1426)
	at android.view.View.layout(View.java:14061)
	at android.view.ViewGroup.layout(ViewGroup.java:4376)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
	at android.view.View.layout(View.java:14061)
	at android.view.ViewGroup.layout(ViewGroup.java:4376)
	at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655)
	at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1644)
	at android.widget.LinearLayout.onLayout(LinearLayout.java:1428)
	at android.view.View.layout(View.java:14061)
	at android.view.ViewGroup.layout(ViewGroup.java:4376)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
	at android.view.View.layout(View.java:14061)
	at android.view.ViewGroup.layout(ViewGroup.java:4376)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
	at android.view.View.layout(View.java:14061)
	at android.view.ViewGroup.layout(ViewGroup.java:4376)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
	at android.view.View.layout(View.java:14061)
	at android.view.ViewGroup.layout(ViewGroup.java:4376)
	at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655)
	at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1513)
	at android.widget.LinearLayout.onLayout(LinearLayout.java:1426)
	at android.view.View.layout(View.java:14061)
	at android.view.ViewGroup.layout(ViewGroup.java:4376)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
	at android.view.View.layout(View.java:14061)
	at android.view.ViewGroup.layout(ViewGroup.java:4376)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
	at android.view.View.layout(View.java:14061)
	at android.view.ViewGroup.layout(ViewGroup.java:4376)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
	at android.view.View.layout(View.java:14061)
	at android.view.ViewGroup.layout(ViewGroup.java:4376)
	at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1986)
	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1807)
	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4464)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
	at android.view.Choreographer.doCallbacks(Choreographer.java:555)
	at android.view.Choreographer.doFrame(Choreographer.java:525)
	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
	at android.os.Handler.handleCallback(Handler.java:615)
	at android.os.Handler.dispatchMessage(Handler.java:92)
	at android.os.Looper.loop(Looper.java:137)
	at android.app.ActivityThread.main(ActivityThread.java:4895)
	at java.lang.reflect.Method.invokeNative(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:511)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
	at dalvik.system.NativeStart.main(Native Method)
Comment 1 oddbjorn.bakke 2016-04-14 12:55:50 UTC
Bug still exists with 2.1.0.6529
Tried with: Xamarin.Forms.Platform.Android.FormsAppCompatActivity
And with: Xamarin.Forms.Platform.Android.FormsApplicationActivity
Comment 2 Paul DiPietro [MSFT] 2016-12-22 17:40:40 UTC
This looks to have been fixed at some point as it does not occur on the latest stable version of Forms (2.3.3.175) when running on API 16.
Comment 3 sumit bachketi 2017-12-21 09:52:16 UTC
Facing the same problem on Android v(4.4.2) with xamarin form version 2.5.0.121934.
Comment 4 sumit bachketi 2017-12-25 08:48:04 UTC
Noticed on HUDL tab.
Comment 5 Joe 2018-01-03 16:38:12 UTC
This problem is still present in the following library:

Xamarin.Android.Support.v7.AppCompat (v26.1.0.1) when used within a xamarin (v4.7.10.38) android project (android sdk v8.0.2.1)

would recommend this being re-opened if at all possible. I'll have to check the current exception stacktrace but it's referring to a null textedit within the datepicker.
Comment 6 Joe 2018-01-04 09:29:39 UTC
This Is the stacktrace provided by the layout manager when attempting to add the datepicker to a layout. I've tried this on the latest versions as well:

Xamarin v4.8.0.753
Android SDK v8.1.0.25

same problem persists.




Trying to load class android.support.v7.widget.AppCompatTextView

Failed to process message RenderLayout
mono.android.DesignerException: java.lang.NullPointerException
	at mono.android.DesignerException.fromThrowable(DesignerException.java:46)
	at mono.android.DesignerSession.checkRenderResultForError(DesignerSession.java:190)
	at mono.android.DesignerSession.renderInternal(DesignerSession.java:343)
	at mono.android.SessionProjectCallback.computeInMonoDroidContextUnsafe(SessionProjectCallback.java:112)
	at mono.android.DesignerSession.render(DesignerSession.java:335)
	at mono.android.DesignerSession.processMessage(DesignerSession.java:721)
	at mono.android.MessageListener.executeMessage(MessageListener.java:88)
	at mono.android.MessageListener$Runner.run(MessageListener.java:44)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
	at android.content.res.Resources_Delegate.getValue(Resources_Delegate.java:788)
	at android.content.res.Resources.getValue(Resources.java:1286)
	at android.support.v4.content.res.ResourcesCompat.loadFont(ResourcesCompat.java:212)
	at android.support.v4.content.res.ResourcesCompat.getFont(ResourcesCompat.java:206)
	at android.support.v7.widget.TintTypedArray.getFont(TintTypedArray.java:119)
	at android.support.v7.widget.AppCompatTextHelper.updateTypefaceAndStyle(AppCompatTextHelper.java:208)
	at android.support.v7.widget.AppCompatTextHelper.onSetTextAppearance(AppCompatTextHelper.java:242)
	at android.support.v7.widget.AppCompatTextView.setTextAppearance(AppCompatTextView.java:161)
	at android.widget.TextView.setTextAppearance(TextView.java:2791)
	at android.widget.YearPickerView$YearAdapter.getView(YearPickerView.java:192)
	at android.widget.AbsListView.obtainView(AbsListView.java:2362)
	at android.widget.ListView.onMeasure(ListView.java:1203)
	at android.view.View.measure(View.java:19734)
	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120)
	at com.android.internal.widget.DialogViewAnimator.onMeasure(DialogViewAnimator.java:64)
	at android.view.View.measure(View.java:19734)
	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120)
	at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
	at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
	at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
	at android.view.View.measure(View.java:19734)
	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120)
	at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
	at android.view.View.measure(View.java:19734)
	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120)
	at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
	at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
	at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
	at android.view.View.measure(View.java:19734)
	at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1293)
	at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
	at android.widget.ScrollView.onMeasure(ScrollView.java:340)
	at android.view.View.measure(View.java:19734)
	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120)
	at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
	at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
	at android.view.View.measure(View.java:19734)
	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120)
	at android.support.v7.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:400)
	at android.view.View.measure(View.java:19734)
	at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)
	at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
	at android.view.View.measure(View.java:19734)
	at com.android.layoutlib.bridge.impl.RenderSessionImpl.measureView(RenderSessionImpl.java:589)
	at com.android.layoutlib.bridge.impl.RenderSessionImpl.doLayout(RenderSessionImpl.java:379)
	at com.android.layoutlib.bridge.impl.RenderSessionImpl.renderAndBuildResult(RenderSessionImpl.java:534)
	at com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:422)
	at com.android.layoutlib.bridge.BridgeRenderSession.render(BridgeRenderSession.java:104)
	at mono.android.DesignerSession.renderInternal(DesignerSession.java:342)
	... 6 more