java.lang.IllegalArgumentException: navigation destination {actionId} is unknown to this NavController when Activity is recreated?

有些话、适合烂在心里 提交于 2021-01-29 05:06:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!