architecture-components-samples: Navigation component app:clearTask and app:launchSingleTop crash
Component 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)
}
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 6
- Comments: 16 (1 by maintainers)
Commits related to this issue
- Merge pull request #405 from DougSig/dev-todo-mvvm-live-kotlin Upgrade to Espresso 3 and fix race condition. — committed to recker115/architecture-components-samples by JoseAlcerreca 7 years ago
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.
It appears that ClearTask is deprecated. However, the recommended PopUpTo and setting Inclusive to True does not produce the same behavior as ClearTask. You can still navigate back to previous fragments.
can confirm, am using alpha07 and also without app:clearTask / app:launchSingleTop this exception is thrown randomly. sometimes everything is fine, sometimes the app just crashes.
navigation destination NAME is unknown to this NavController issue still exists alpha07
Same problem here, the issue has been reported as a bug and is said to be fixed in alpha03 https://issuetracker.google.com/issues/111007042