IllegalArgumentException: navigation destination xxx is unknown to this NavController

后端 未结 30 2380
遇见更好的自我
遇见更好的自我 2020-11-27 11:28

I am having issue with the new Android Navigation Architecture component when I try to navigate from one Fragment to another, I get this weird error:

30条回答
  •  情话喂你
    2020-11-27 12:14

    This happened to me, my issue was I was clicking a FAB on tab item fragment. I was trying to navigate from one of tab item fragment to another fragment.

    But according to Ian Lake in this answer we have to use tablayout and viewpager, no navigation component support. Because of this, there is no navigation path from tablayout containing fragment to tab item fragment.

    ex:

    containing fragment -> tab layout fragment -> tab item fragment -> another fragment
    

    Solution was to create a path from tab layout containing fragment to intended fragment ex: path: container fragment -> another fragment

    Disadvantage:

    • Nav graph no longer represent user flow accurately.

提交回复
热议问题