[MaterialCalendarGridView] NullPointerException in onDraw
See original GitHub issueDescription: MaterialDatePicker crashes when using setSelection
and MaterialCalendar
as materialCalendarFullscreenTheme
. The crash happens when swiping to the left after the dialog shows up.
Source code:
<item name="materialCalendarFullscreenTheme">@style/ThemeOverlay.MaterialComponents.MaterialCalendar</item>
MaterialDatePicker.Builder.dateRangePicker()
.setSelection(new Pair(1485129600000l, 1590537600000l))
.build()
.show(getSupportFragmentManager(), "...");
Expected behavior: no crash
Android API version: 29
Material Library version: 1.2.0-alpha06
Device: Device on which the bug was encountered here Galaxy A10 Pixel 2 P10 lite OnePlus 7 Pro
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getRight()' on a null object reference
at com.google.android.material.datepicker.MaterialCalendarGridView.onDraw(MaterialCalendarGridView.java:158)
at android.view.View.draw(View.java:21609)
at android.widget.AbsListView.draw(AbsListView.java:4514)
at android.view.View.updateDisplayListIfDirty(View.java:20471)
at android.view.View.draw(View.java:21336)
at android.view.ViewGroup.drawChild(ViewGroup.java:4413)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4174)
at android.view.View.updateDisplayListIfDirty(View.java:20462)
at android.view.View.draw(View.java:21336)
at android.view.ViewGroup.drawChild(ViewGroup.java:4413)
at androidx.recyclerview.widget.RecyclerView.drawChild(RecyclerView.java:5030)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4174)
at android.view.View.draw(View.java:21612)
at androidx.recyclerview.widget.RecyclerView.draw(RecyclerView.java:4429)
at android.view.View.updateDisplayListIfDirty(View.java:20471)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4397)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4370)
at android.view.View.updateDisplayListIfDirty(View.java:20431)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4397)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4370)
at android.view.View.updateDisplayListIfDirty(View.java:20431)
at android.view.View.draw(View.java:21336)
at android.view.ViewGroup.drawChild(ViewGroup.java:4413)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4174)
at android.view.View.updateDisplayListIfDirty(View.java:20462)
at android.view.View.draw(View.java:21336)
at android.view.ViewGroup.drawChild(ViewGroup.java:4413)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4174)
at android.view.View.updateDisplayListIfDirty(View.java:20462)
at android.view.View.draw(View.java:21336)
at android.view.ViewGroup.drawChild(ViewGroup.java:4413)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4174)
at android.view.View.updateDisplayListIfDirty(View.java:20462)
at android.view.View.draw(View.java:21336)
at android.view.ViewGroup.drawChild(ViewGroup.java:4413)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4174)
at android.view.View.updateDisplayListIfDirty(View.java:20462)
at android.view.View.draw(View.java:21336)
at android.view.ViewGroup.drawChild(ViewGroup.java:4413)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4174)
at android.view.View.updateDisplayListIfDirty(View.java:20462)
at android.view.View.draw(View.java:21336)
at android.view.ViewGroup.drawChild(ViewGroup.java:4413)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4174)
at android.view.View.updateDisplayListIfDirty(View.java:20462)
at android.view.View.draw(View.java:21336)
at android.view.ViewGroup.drawChild(ViewGroup.java:4413)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4174)
at android.view.View.draw(View.java:21612)
at com.android.internal.policy.DecorView.draw(DecorView.java:815)
at android.view.View.updateDisplayListIfDirty(View.java:20471)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:580)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:586)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:659)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:3876)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3676)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2998)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1935)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8023)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1163)
at android.view.Choreographer.doCallbacks(Choreographer.java:986)
at android.view.Choreographer.doFrame(Choreographer.java:902)```
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
NullPointerException when creating a custom View with ...
When implementing a view, implement onDraw(android.graphics.Canvas) instead of overriding this method. If you do need to override this method, ...
Read more >Static Analysis - Cuckoo Sandbox
Allows the app to view information about network connections such as which networks exist and are connected. android.permission.REQUEST_INSTALL_PACKAGES ...
Read more >NullPointerException - Android Developers
NullPointerException objects may be constructed by the virtual machine as if stack trace was ... Constructs a NullPointerException with no detail message.
Read more >Fix "java.lang.NullPointerException" in Android Studio
It is a run-time exception that arises when an application or a program tries to access the object reference(accessing methods) which has a...
Read more >java.lang.NullPointerException @ SurfaceControl.java line 89 ...
NullPointerException : Attempt to invoke direct method 'void android.view.SurfaceControl. ... onDraw(ActivityThread.java:4175) at android.view.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m receiving similar crashes, using version “1.3.0”
I don’t have steps to reproduce it, but they occurred on different devices (HUAWEI, Xiaomi, Samsung, OnePlus) with different android versions (10, 9, 8.1, 8.0). Maybe there is a trick with language, most users are using ‘fr’.
source:
stack trace:
I just experienced this on the android Emulator with API level 29 as well