thellmund / Android-Week-View

Display highly customizable calendar views in your Android app
Apache License 2.0
188 stars 98 forks source link

Crash com.alamkanak.weekview.ViewStateFactoryKt.resolveColor #253

Closed bardss closed 3 years ago

bardss commented 3 years ago

Describe the bug I am using your Android-Week-View fork on production app. Users apps are crashing in because of missing resources (probably).

Firebase Crashlytics logs:

Fatal Exception: android.view.InflateException: Binary XML file line #10: Error inflating class com.alamkanak.weekview.WeekView at android.view.LayoutInflater.createView(LayoutInflater.java:640) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750) at android.view.LayoutInflater.rInflate(LayoutInflater.java:813) at android.view.LayoutInflater.inflate(LayoutInflater.java:511) at android.view.LayoutInflater.inflate(LayoutInflater.java:415) at android.view.LayoutInflater.inflate(LayoutInflater.java:366)

and

Caused by android.content.res.Resources$NotFoundException: File res/drawable/tw_screen_background_selector_dark.xml from color state list resource ID #0x108098e at android.content.res.Resources.twLoadColorStateList(Resources.java:4179) at android.content.res.Resources.loadColorStateList(Resources.java:4117) at android.content.res.TypedArray.getColor(TypedArray.java:397) at com.alamkanak.weekview.ViewStateFactoryKt.resolveColor(ViewStateFactoryKt.java) at com.alamkanak.weekview.ViewStateFactoryKt.resolveColor$default(ViewStateFactoryKt.java) at com.alamkanak.weekview.ViewStateFactoryKt.getWindowBackground(ViewStateFactoryKt.java) at com.alamkanak.weekview.ViewStateFactoryKt.access$getWindowBackground$p(ViewStateFactoryKt.java) at com.alamkanak.weekview.ViewStateFactory.create(ViewStateFactory.java) at com.alamkanak.weekview.WeekView$viewState$2.invoke(WeekView.java) at com.alamkanak.weekview.WeekView$viewState$2.invoke(WeekView.java) at kotlin.SynchronizedLazyImpl.getValue(SynchronizedLazyImpl.java) at com.alamkanak.weekview.WeekView.getViewState(WeekView.java) at com.alamkanak.weekview.WeekView.(WeekView.java) at com.alamkanak.weekview.WeekView.(WeekView.java) at com.alamkanak.weekview.WeekView.(WeekView.java) at java.lang.reflect.Constructor.newInstance(Constructor.java) at java.lang.reflect.Constructor.newInstance(Constructor.java:288) at android.view.LayoutInflater.createView(LayoutInflater.java:614) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750) at android.view.LayoutInflater.rInflate(LayoutInflater.java:813) at android.view.LayoutInflater.inflate(LayoutInflater.java:511) at android.view.LayoutInflater.inflate(LayoutInflater.java:415) at android.view.LayoutInflater.inflate(LayoutInflater.java:366)

and

com.alamkanak.weekview.ViewStateFactoryKt.resolveColor (ViewStateFactoryKt.java) com.alamkanak.weekview.ViewStateFactoryKt.resolveColor$default (ViewStateFactoryKt.java) com.alamkanak.weekview.ViewStateFactoryKt.getWindowBackground (ViewStateFactoryKt.java) com.alamkanak.weekview.ViewStateFactoryKt.access$getWindowBackground$p (ViewStateFactoryKt.java) com.alamkanak.weekview.ViewStateFactory.create (ViewStateFactory.java) com.alamkanak.weekview.WeekView$viewState$2.invoke (WeekView.java) com.alamkanak.weekview.WeekView$viewState$2.invoke (WeekView.java)

Additional context

thellmund commented 3 years ago

Oh, sorry about that. WeekView defaults to the theme’s windowBackground if you don’t provide a (header/day/timeColumn)BackgroundColor, but wrongly assumes that it is a color instead of a drawable.

I pushed a fix on master and will create a new release. Let me know if there are any issues remaining.

thellmund commented 3 years ago

It’s available now. I’ll close this issue, but feel free to reopen if anything comes up.