-
-
Notifications
You must be signed in to change notification settings - Fork 132
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
Nested Destination NavGraph with default one being the "deeper #578
Comments
I've read this comment and I just double-checked.
|
Hi @lucanicoletti , I'm sorry it took me so long to get back to you. I hope you found a workaround in the mean time 🙏 Let me start by making something clear:
This is not adding screens. Differently from official compose navigation library, the screens are added when you pass one NavGraph to the DestinationsNavHost, since that nav graph has information needed to add all its nested graphs and destinations. Besides this, it's really hard for me to understand exactly what's happening, but it does sound like a complicated setup, probably unwarranted. Maybe you can show me the contents of your NavGraphs generated object. Let me know if this helps! |
No worries for the late reply. As you've guessed, I found a "solution". I would like to contribute more, but I'm unsure with what I can share. |
No, that’s not needed. anyway, glad you found a solution! I’ll close this, don’t hesitate to open something if you find another issue |
I inherited an Android Project that uses this library, and so far I had no issues.
All navigations were handled correctly and I was able to add several new screens and navigate between them without problems.
Last week I had to add a
resultRecipient: ResultRecipient<MyDestination, Boolean>,
to one of the screens.It all worked well, the app was building and the navigation worked with no problems, handling the results.
Fast-forward to the day after, and the app started crashing on the navigation (to the screen where that resultRecipient was added).
The crash is caused by:
java.lang.IllegalArgumentException: Navigation destination that matches request NavDeepLinkRequest{ uri=android-app://androidx.navigation/my_screen/param1/param2 } cannot be found in the navigation graph ComposeNavGraph(0xb4ff03f7) route=show_root startDestination={Destination(0x442b361f) route=home_screen}
Trying to understand how this was possible, I found out the project is using a somewhat weird configuration.
There are 2
NavGraph
defined.One is the above
show_root
, which holds the screens that are displayed with aBottomBar
layout.Another one is the
login
, which is used for the login flow (there are two different activities that hold the two graphs).The
MainActivity
has aDestinationNavHost
that uses the defaultNavGraph
(RootNavGraph
).As follow:
the
startRoute
is defined as followThis screen holds another
DestinationsNavHost
which definesnavGraph = NavGraphs.showRoot,
(not the default one, a custom-made one).Inside this inner
DestinationsNavHost
the screens marked with theShowRootNavGraph
are added with thecomposable(Destination) { Screen() }
function.A few of those screens are lists of items, which then navigate the user to the detail page of such items, which is not marked as
ShowRootNavGraph
, and so is using the defaultRootNavGraph
, which started to crash, apparently at random.I updated the library version (which wasn't the latest released) - currently on
1.9.63
- and this solved the crash after a clean and rebuild of the project.Fast forward another few days (weekend in between), and without changing anything in the project, simply re-running the app, it now crashes again with the same stack trace.
I realise there is a problem in the graphs, but I couldn't figure out what is been done wrong, and how I could possibly fix it.
I tried removing the
resultRecipient
as it was the only thing changed on the screen/destination, but that didn't solve the thing.The text was updated successfully, but these errors were encountered: