Navigation component app:clearTask and app:launchSingleTop crash
See original GitHub issueComponent used: Navigation Version used: alpha01, alpha02 Devices/Android versions reproduced on: All
App crash when using app:clearTask=“true” or app:launchSingleTop=“true” in nav_graph.xml
Some times crash is gone after second app start. Some times it crashes on second call to this action (for example I opened fragment with app:launchSingleTop=“true” then go back using findNavController().navigateUp() and opened it again -> crash)
java.lang.IllegalArgumentException: navigation destination indicaonline.delivery:id/action_mainFragment_to_orderDetailsFragment is unknown to this NavController
at androidx.navigation.NavController.navigate(NavController.java:633)
at androidx.navigation.NavController.navigate(NavController.java:592)
at androidx.navigation.NavController.navigate(NavController.java:654)
at package.ui.main.MainFragment.openOrderDetails(MainFragment.kt:215)
at package.ui.main.MainFragment.onItemClick(MainFragment.kt:203)
at eu.davidea.viewholders.FlexibleViewHolder.onClick(FlexibleViewHolder.java:122)
at android.view.View.performClick(View.java:6597)
at android.view.View.performClickInternal(View.java:6574)
at android.view.View.access$3100(View.java:778)
at android.view.View$PerformClick.run(View.java:25881)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6649)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:826)
<action
android:id="@+id/action_mainFragment_to_orderDetailsFragment"
app:destination="@id/orderDetailsFragment"
app:launchSingleTop="true">
<argument
android:name="orderId"
android:defaultValue="-1" />
</action>
this is single activity app
to open fragment I use
viewModel.someLiveData.observe(this, EventObserver {
findNavController().navigate(R.id.action_assignFragment_to_registerPinFragment)
})
or
btnButton.setOnClickListener {
val email = etEmail.text.toString()
val action = LoginFragmentDirections
.action_loginFragment_to_forgotPasswordFragment().setEmail(email)
findNavController().navigate(action)
}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:16 (1 by maintainers)
Top Results From Across the Web
How to manage proper navigation without using clearTask as ...
While using navigation architecture as from here , here clearTask is deprecated. My scenario is this: There are 2 screens Login and Registration ......
Read more >Navigation | Android Developers
Navigation is a framework for navigating between 'destinations' within an Android application that provides a consistent API whether ...
Read more >A fix for “Navigation action cannot be found in the current ...
The crash occurs because the first invocation of findController.navigate() takes the app to a different screen/destination, on the second ...
Read more >[Solved]-Move to MainActivity with Jetpack Navigation-kotlin
The storyboard will contain all the fragments which you need in the navigation and the navigation directions as well. The navigation directions is...
Read more >Application crashes when navigating twice through the same ...
ZygoteInit.main(ZygoteInit.java:807) Component used: ... P3, Crash caused by navigating twice via the same action in a subgraph ... app:clearTask="true"
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Issue still exists in alpha03
Since clearTask is deprecated, this issue can be closed?
However, the problem still persists in that the current Navigation RC01 library does not clear the back stack using PopUpTo if you are trying to clear a nested graph.
If you are in a nested graph, you can’t pop to a destination outside the nested graph and only the start destination.