[MaterialCalendarGridView] NullPointerException in onDraw in 1.3.0
See original GitHub issueDescription: I’m receiving a similar bug to https://github.com/material-components/material-components-android/issues/1338, but using version “1.3.0”
I don’t have steps to reproduce, but It occurred on different devices with different android versions. Maybe there is a trick with language, most users are using ‘fr’.
Expected behavior: expect the app will not crash
Source code:
private fun showDatePicker(from: DateTime, to: DateTime, onSubmit: (DateTime, DateTime) -> Unit) {
val datePicker = MaterialDatePicker.Builder.dateRangePicker()
datePicker.setSelection(Pair(from.millis, to.millis))
val dialog = datePicker.build()
dialog.addOnPositiveButtonClickListener {
onSubmit(DateTime(it.first), DateTime(it.second))
}
dialog.show(parentFragmentManager, dialog.javaClass.simpleName)
}
Android API versions: 29, 28, 27, 26
Material Library version: 1.3.0
Devices: Huawei P20 Xiaomi Redmi 9 Samsung Galaxy S7 Samsung Galaxy S7 edge Samsung Galaxy A41 Samsung Galaxy Note 10 Samsung Galaxy S9 OnePlus 6
Stacktrace:
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getLeft()' on a null object reference
at com.google.android.material.datepicker.MaterialCalendarGridView.horizontalMidPoint(MaterialCalendarGridView.java)
at com.google.android.material.datepicker.MaterialCalendarGridView.onDraw(MaterialCalendarGridView.java:221)
at android.view.View.draw(View.java:23187)
at android.widget.AbsListView.draw(AbsListView.java:7190)
at android.view.View.updateDisplayListIfDirty(View.java:22062)
at android.view.View.draw(View.java:22917)
at android.view.ViewGroup.drawChild(ViewGroup.java:5230)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4987)
at android.view.View.updateDisplayListIfDirty(View.java:22048)
at android.view.View.draw(View.java:22917)
at android.view.ViewGroup.drawChild(ViewGroup.java:5230)
at androidx.recyclerview.widget.RecyclerView.drawChild(RecyclerView.java)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4987)
at android.view.View.draw(View.java:23190)
at androidx.recyclerview.widget.RecyclerView.draw(RecyclerView.java)
at android.view.View.updateDisplayListIfDirty(View.java:22062)
at android.view.View.draw(View.java:22917)
at android.view.ViewGroup.drawChild(ViewGroup.java:5230)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4987)
at android.view.View.updateDisplayListIfDirty(View.java:22048)
at android.view.View.draw(View.java:22917)
at android.view.ViewGroup.drawChild(ViewGroup.java:5230)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4987)
at android.view.View.updateDisplayListIfDirty(View.java:22048)
at android.view.View.draw(View.java:22917)
at android.view.ViewGroup.drawChild(ViewGroup.java:5230)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4987)
at android.view.View.updateDisplayListIfDirty(View.java:22048)
at android.view.View.draw(View.java:22917)
at android.view.ViewGroup.drawChild(ViewGroup.java:5230)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4987)
at android.view.View.updateDisplayListIfDirty(View.java:22048)
at android.view.View.draw(View.java:22917)
at android.view.ViewGroup.drawChild(ViewGroup.java:5230)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4987)
at android.view.View.updateDisplayListIfDirty(View.java:22048)
at android.view.View.draw(View.java:22917)
at android.view.ViewGroup.drawChild(ViewGroup.java:5230)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4987)
at android.view.View.updateDisplayListIfDirty(View.java:22048)
at android.view.View.draw(View.java:22917)
at android.view.ViewGroup.drawChild(ViewGroup.java:5230)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4987)
at android.view.View.updateDisplayListIfDirty(View.java:22048)
at android.view.View.draw(View.java:22917)
at android.view.ViewGroup.drawChild(ViewGroup.java:5230)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4987)
at android.view.View.updateDisplayListIfDirty(View.java:22048)
at android.view.View.draw(View.java:22917)
at android.view.ViewGroup.drawChild(ViewGroup.java:5230)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4987)
at android.view.View.draw(View.java:23190)
at com.android.internal.policy.DecorView.draw(DecorView.java:1154)
at android.view.View.updateDisplayListIfDirty(View.java:22062)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:588)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:594)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:667)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:4296)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:4080)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3348)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2225)
I going to try the latest release 1.4.0-alpha01 of the library. But I can’t reproduce this issue by myself, so the only way is to receive crash information from Firebase, it’s painful. Maybe someone faced the same issue, will be thankful for any help.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:10 (1 by maintainers)
I’ve used the same solution. Opened PR to this issue is based on fix which I used on prod, hope it will be rewived soon.
@vladyslavkhimich checkout this one. Additionally, I highly recommend you to read this issue 🙂 Cheers 🥳