question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

kotlin.TypeCastException: null cannot be cast to non-null type com.kizitonwose.calendarview.ui.MonthViewHolder

See original GitHub issue

Hi Kizito!

First of all awesome lib! Kudos for it!

At the moment I’m consuming the CalendarView from an Android Java project. For testing how stable the lib behave under certain scenarios I enabled Don’t keep activities in Developer Options. After playing around, bringing the calendar view back and forth between foreground and background this exception arises: kotlin.TypeCastException: null cannot be cast to non-null type com.kizitonwose.calendarview.ui.MonthViewHolder at com.kizitonwose.calendarview.ui.CalendarAdapter.notifyMonthScrollListenerIfNeeded(CalendarAdapter.kt:196) at com.kizitonwose.calendarview.ui.CalendarAdapter$onAttachedToRecyclerView$1.run(CalendarAdapter.kt:52) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5221) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

Any idea how to fix this?

Thanks in advance!

Federico

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kizitonwosecommented, Jul 31, 2019

This issue is fixed in the fix-crash branch but has not been released yet. You can get the fix using: implementation 'com.github.kizitonwose:CalendarView:7da609173c' until version 0.2.5 is released.

0reactions
raymondbarrinuevocommented, Feb 6, 2021

hi @kizitonwose

I am still having this issue. I am using this version implementation ‘com.github.kizitonwose:CalendarView:0.3.2’

Fatal Exception: kotlin.TypeCastException: null cannot be cast to non-null type com.kizitonwose.calendarview.ui.DayBinder<com.kizitonwose.calendarview.ui.ViewContainer> at com.kizitonwose.calendarview.ui.CalendarAdapter.onCreateViewHolder(CalendarAdapter.kt:134) at com.kizitonwose.calendarview.ui.CalendarAdapter.onCreateViewHolder(CalendarAdapter.kt:29) at androidx.recyclerview.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:7078) at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6235) at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6118) at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6114) at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2303) at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1627) at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1587) at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:665) at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4134) at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3851) at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4404) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656) at android.widget.LinearLayout.onLayout(LinearLayout.java:1565) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656) at android.widget.LinearLayout.onLayout(LinearLayout.java:1565) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656) at android.widget.LinearLayout.onLayout(LinearLayout.java:1565) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at androidx.drawerlayout.widget.DrawerLayout.onLayout(DrawerLayout.java:1231) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656) at android.widget.LinearLayout.onLayout(LinearLayout.java:1565) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656) at android.widget.LinearLayout.onLayout(LinearLayout.java:1565) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656) at android.widget.LinearLayout.onLayout(LinearLayout.java:1565) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656) at android.widget.LinearLayout.onLayout(LinearLayout.java:1565) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at com.android.internal.policy.DecorView.onLayout(DecorView.java:1067) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:3427) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2894) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1942) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8595) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:988) at android.view.Choreographer.doCallbacks(Choreographer.java:765) at android.view.Choreographer.doFrame(Choreographer.java:700) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:967) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7156) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)

Read more comments on GitHub >

github_iconTop Results From Across the Web

kotlin.TypeCastException: null cannot be cast to non ... - GitHub
Hi Kizito! First of all awesome lib! Kudos for it! At the moment I'm consuming the CalendarView from an Android Java project.
Read more >
Kotlin (null cannot be cast to non-null type) Custom Calendar ...
Note the type in the error message. It isn't date which is null, but something of type CalendarAdapter , I would suspect
Read more >
Android : kotlin.TypeCastException: null cannot be cast to non ...
Android : kotlin. TypeCastException : null cannot be cast to non-null type com.midsizemango.databasekotlin.Note [ Beautify Your Computer ...
Read more >
Kotlin (null cannot be cast to non-null type) Custom Calendar ...
Note the type in the error message. It isn't date which is null, but something of type CalendarAdapter , I would suspect
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found