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)
}
Also having this issue.
I'm having this issue too. I need to be able to clear the back stack after the user completes a login/register screen. If I add ClearTask to the navigation action, I am unable to navigate back without having the app crash.
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.
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
Issue still exists in alpha03
I had the same issue when using button.setOnClickListener(Navigation.createNavigateOnClickListener(R.id.fragToNavigateTo)
I just switched my logic to this:
button.setOnClickListener{
activity?.let { it1 -> Navigation.findNavController(it1, R.id.my_host_fragment).navigate(R.id.superDuperFragment) }
}
and the IllegalArgumentException went away.
navigation destination NAME is unknown to this NavController issue still exists alpha07
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.
in alpha07 we could still use clear task it seems to be completely gone in 08
Same here, app always crash when I return to a fragment one second time. Any solution for this?
The given solution is to select inclusive on the action and point your popTo to your nav graph root
The given solution is to select inclusive on the action and point your popTo to your nav graph root
Thank you. Your answer was promising, but the app still crash after navigate one second time to the same fragment.
@GorkemKarayel @CurtesMalteser i have same bug in version 1.0.0apha09 but to me this bug caused because i called twice time findNavigation().navigation.popBackStack() example :
` view.setOnClickListener {
if (it.findNavController().popBackStack()) {
it.findNavController().popBackStack()
} else {
(context as Activity).finish()
}
}`
and i fixed when i call just one time example:
` view.setOnClickListener {
if (it.findNavController().popBackStack()) {
} else {
(context as Activity).finish()
}
}`
If the back button still has the desired functionality you could call
getActivity().getSupportFragmentManager().popBackStack()
On Fri, 21 Dec 2018, 13:30 CurtesMalteser, notifications@github.com wrote:
The given solution is to select inclusive on the action and point your
popTo to your nav graph rootThank you. Your answer was promising, but the app still crash after
navigate one second time to the same fragment.—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/googlesamples/android-architecture-components/issues/405#issuecomment-449388938,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMC8C3eDUsh0sU1Ehduy9yn4c-0xqT9qks5u7OKDgaJpZM4U7PEA
.
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.
Please feel free to file issues against Navigation on the issue tracker if you're still encountering issues.
Most helpful comment
Issue still exists in alpha03