I have next navigation action:
<action
android:id="@+id/openNext"
app:destination="@id/nextFragment"
app:popUpTo="@id/firstFragment"
app:popUpToInclusive="false" />
As you can see, I want to clear back stack, when I navigate to NextFragment.
I use this action in code as usual: findNavController().navigate(openNext()). But I get an exception "No destination with ID...".
I check if I really missed this destination:
try {
Log.d("testTag", "entryId: ${R.id.nav_graph_included}")
val entry = findNavController().getBackStackEntry(R.id.nav_graph_included)
Log.d("testTag", "entry: ${entry?.destination?.displayName} ${entry?.destination?.id}")
findNavController().navigate(openNext())
} catch (e: Exception) {
Log.d("testTag", "Exception: ${e.message}")
}
I get really paradoxical log output:
D/testTag: entryId: 2131363179
D/testTag: entry:com.example.app:id/nav_graph_included 2131363179
D/testTag: Exception: No destination with ID 2131363179 is on the NavController's back stack. The current destination is …
So actually I have this destination but Navigation component throws an exception. How can it be? And how can I fix this problem?