问题
I am coming from reading all the answers in IllegalArgumentException: navigation destination xxx is unknown to this NavController with no luck. I am getting this when the activity is recreated from either a manual recreate() call or coming back from a process death.
I have an Activity
that changes its Fragments
using Navigation
.
Fragment A has a FAB that navigates to Fragment B when clicked.
floatingActionButton = view.findViewById<FloatingActionButton>(R.id.floating_action_button).apply {
setOnClickListener {
findNavController().navigate(R.id.action_fragmentA_to_fragmentB,
null,
null,
FragmentNavigatorExtras(this to "shared_element_container"))
}
}
Works fine but when the FAB is clicked after the activity is recreated I get a crash.
回答1:
Turns out I had accidentally given the same id to a nested graph and a fragment.
来源:https://stackoverflow.com/questions/61689860/java-lang-illegalargumentexception-navigation-destination-actionid-is-unknown