androidbroadcast / ViewBindingPropertyDelegate

Make work with Android View Binding simpler
https://proandroiddev.com/make-android-view-binding-great-with-kotlin-b71dd9c87719
Apache License 2.0
1.42k stars 102 forks source link

java.lang.IllegalStateException Fragment's view can't be accessed. Fragment isn't added #100

Closed final-class closed 2 years ago

final-class commented 2 years ago

Hello, version 1.5.6, crashlytics reports new crashes:

Fatal Exception: java.lang.IllegalStateException: Fragment's view can't be accessed. Fragment isn't added at by.kirich1409.viewbindingdelegate.LifecycleViewBindingProperty.getValue(ViewBindingProperty.kt:87) at by.kirich1409.viewbindingdelegate.FragmentViewBindingProperty.getValue(FragmentViewBindings.kt:63) at by.kirich1409.viewbindingdelegate.FragmentViewBindingProperty.getValue(FragmentViewBindings.kt:52)

In fragment i declare like this: private val binding by viewBinding(FragmentFirstBinding::bind)

image

kirich1409 commented 2 years ago

The issue has full informatio in crash log. You try to access viewbinding when Fragment isn't added and has no view. Check state of Fragment before update views