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.

Crash in DialogFragment. ID does not reference a View inside this View

See original GitHub issue

I am using this library 1.4.5 version. With this function public inline fun <F : Fragment, T : ViewBinding> Fragment.viewBinding( crossinline vbFactory: (View) -> T, @IdRes viewBindingRootId: Int ) And working in activity and fragment. When using in DialogFragment. The app crash when I try to use viewBinding instance in onViewCreated callback. After some investigated, found the dialog contentView will be set in onActivityCreated which is called after onViewCreated. But the delegate will get the view from dialog inside.

Is that a bug? Please give some suggestions, thanks.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
kirich1409commented, May 6, 2021

DialogFragment can be used as usual Fragment that will be added as View in layout or can be shown as Dialog. A ViewBinding require a View. I will think how it can be done better. Right now DialogFragment implementation isn’t good a don’t work everywhere. Let’s discuss how to do that better

2reactions
outofdatecommented, Apr 29, 2021

Yeah, we got the same issue, as we are accessing bindings in onViewCreated. After some digging we find out the same reason - dialog window view is without our view, as it is added in onActivityCreated of DialogFragment.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does my NavController cannot find an ID that I already ...
The Logcat says failed because the java file, ID does not reference a View inside this Activity. But I clearly typed the ID: ......
Read more >
Interact programmatically with the Navigation component
When you navigate to a destination that takes the full view of the NavHost (such as a <fragment> destination), the previous destination has...
Read more >
id does not reference a view inside this activity
resource reference: In Java: R.id.name In XML: @[package:]id/name syntax: Why does it say "ID does not reference a view inside this activity" Does...
Read more >
Using DialogFragment | CodePath Android Cliffnotes
Use onCreateView when the entire view of the dialog is going to be defined via custom XML. Use onCreateDialog when you just need...
Read more >
Android DialogFragment - DigitalOcean
No more IllegalStateExceptions and leaked window crashes. ... onCreateView - Here you can create a Dialog using a custom view defined.
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