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.

Navigation component crashes.

See original GitHub issue

I guess this is just broken Navigation, and i’m going to post this issue at Navigation bug tracker but still.

  1. Open Plant list screen
  2. With 2 or more fingers tap different Plant items at the same time
  3. You will get exception

java.lang.IllegalArgumentException: navigation destination com.google.samples.apps.sunflower:id/action_plant_list_fragment_to_plant_detail_fragment is unknown to this NavController

Seems like after first click Navigation framework thinks you are already at Plant detail part of the nav graph. And this fragment can’t use this action. It seems just broken as for me. I’d like it opens two separate screens if you do things like this. This probably will crash you app everywhere when you can navigate with more then 1 then click listener (for example 2 buttons to register/forgot password screens)

In the current situation i have found few workarounds with this problem:

  1. We can wrap it.findNavController().navigate(direction) with tryCatch block, catch IllegalArgumentException and do nothing. But it seems just broken, don’t forget to leave a commentary in that catch block
  2. You can use Global actions only https://developer.android.com/topic/libraries/architecture/navigation/navigation-global-action But this is again will look just horrible tho. This seems acceptable if we add search into the app
  3. You can add to PlantDetailFragment in nav graph action to navigate to itself (recursive). This is horrible as well.

Offtopic: if you use recursive destination and tie ActonBar with NavController - check you home/back button. This will be broken if your recursive destination is first in nav graph.

Well, i don’t have the good looking solution for the issue quite yet. Still working

UPD: Copy of this bug at google tracker https://issuetracker.google.com/issues/118975714

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
dvrajput96commented, Jan 22, 2020

@opengamer29 you could try a different navigation library that can also make navigation from one screen to another an actual one-liner, and wouldn’t crash from tapping two plants at once

See https://github.com/Zhuinden/simple-stack-tutorials/blob/534a2c63a6827bbfd3179ac2d2dd75d863dd843e/app/src/main/java/com/zhuinden/simplestacktutorials/steps/step_5/Step5FirstFragment.kt#L19

Thanks a lot man, You just saved my day.

1reaction
Zhuindencommented, Jan 20, 2020

@opengamer29 you could try a different navigation library that can also make navigation from one screen to another an actual one-liner, and wouldn’t crash from tapping two plants at once

See https://github.com/Zhuinden/simple-stack-tutorials/blob/534a2c63a6827bbfd3179ac2d2dd75d863dd843e/app/src/main/java/com/zhuinden/simplestacktutorials/steps/step_5/Step5FirstFragment.kt#L19 😏

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stop Android Navigation Crashes - Medium
Having thousands of crashes when you're using the official android navigation system can be very frustrating. This is what our testers and ...
Read more >
Duplicate Android Navigation — Bug or Feature?
If you click two “buttons” that navigate and the second navigation action/direction is not available to the first destination, the app crashes ......
Read more >
Using Navigation's actions instead of direct fragment id ...
Using Navigation's actions instead of direct fragment id crashes ... I'm having an issue with a very simple task with Navigation component.
Read more >
Application crashes when navigating twice through the same ...
When attempting to navigate through a nested graph more than once the application ... Component used: android.arch.navigation:navigation-fragment-ktx
Read more >
Crashes - Android Developers
An Android app crashes whenever there's an unexpected exit caused by an ... Any app component, even components like broadcast receivers or ...
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