Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IllegalStateException FragmentViewBindingProperty.getLifecycleOwner #105

Closed
galaxi76 opened this issue Sep 21, 2022 · 1 comment
Closed
Assignees

Comments

@galaxi76
Copy link

Fragment doesn't have view associated with it or the view has been destroyed

by.kirich1409.viewbindingdelegate.FragmentViewBindingProperty.getLifecycleOwner (FragmentViewBindings.kt:65)
by.kirich1409.viewbindingdelegate.FragmentViewBindingProperty.getLifecycleOwner (FragmentViewBindings.kt:34)
by.kirich1409.viewbindingdelegate.LifecycleViewBindingProperty.getValue (ViewBindingProperty.kt:76)
by.kirich1409.viewbindingdelegate.FragmentViewBindingProperty.getValue (FragmentViewBindings.kt:42)
by.kirich1409.viewbindingdelegate.FragmentViewBindingProperty.getValue (FragmentViewBindings.kt:34)
com.xxx.MainFragment.getBinding (MainFragment.kt:53)
com.xxx.MainFragment.onSaveInstanceState (MainFragment.kt:216)

90% occurrence in background

@kirich1409
Copy link
Collaborator

This is normal behaviour, because Fragment's view has been destroyed.
Try to add check

if (view != null) {
   // Do something with viewBinding
}

@kirich1409 kirich1409 self-assigned this Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants