Fixed
Status Update
Comments
pi...@googlemail.com <pi...@googlemail.com> #2
I have the same bug.
I attached an example app where i can reproduce this error:
Click path: FAB Button -> Home Tab -> Dashboard Tab -> FAB Button -> Back Button -> FAB Button
On the last FAB Button Click i get an exception:
java.lang.IllegalArgumentException: navigation destination com.example.navbug:id/action_itemFragment_to_twoFragment is unknown to this NavController
at androidx.navigation.NavController.navigate(NavController.java:669)
at androidx.navigation.NavController.navigate(NavController.java:628)
at androidx.navigation.NavController.navigate(NavController.java:616)
at com.example.navbug.ItemFragment$onViewCreated$2.onClick(ItemFragment.kt:59)
at android.view.View.performClick(View.java:6294)
at android.view.View$PerformClick.run(View.java:24770)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
I attached an example app where i can reproduce this error:
Click path: FAB Button -> Home Tab -> Dashboard Tab -> FAB Button -> Back Button -> FAB Button
On the last FAB Button Click i get an exception:
java.lang.IllegalArgumentException: navigation destination com.example.navbug:id/action_itemFragment_to_twoFragment is unknown to this NavController
at androidx.navigation.NavController.navigate(NavController.java:669)
at androidx.navigation.NavController.navigate(NavController.java:628)
at androidx.navigation.NavController.navigate(NavController.java:616)
at com.example.navbug.ItemFragment$onViewCreated$2.onClick(ItemFragment.kt:59)
at android.view.View.performClick(View.java:6294)
at android.view.View$PerformClick.run(View.java:24770)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
se...@google.com <se...@google.com>
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 791a3ffbae3efc6c0cfaa568b9d303eef0a523e0
Author: Daniel Santiago Rivera <danysantiago@google.com>
Date: Thu Aug 02 09:27:01 2018
Fix back stack inconsistency when detecting back pressed.
FragmentNavigator's back stack was becoming inconsistent with the
FragmentManager's back stack due to in-between multiple pending
operations callbacks occurring that would cause the difference between
the new count and the final count to be equal and thus causing the
amount of pending operations not to be decreased.
This changes takes a slightly different strategy, instead of counting
pending operations, we just flag that we have pending operations and we
don't consider them done until the FragmentManager's back stack is equal
to the Navigator's back stack. Consuming back stack callbacks as long
as there are pending operations so that we don't accidentally detect a
back press. Since a back press causes a popBackStackImmediate() we have
confidence pending operations will be executed causing the Navigator to
reset the flag to later then detect the back press pop.
Bug: 111884848
Bug: 111907708
Test: FragmentNavigatorTest, additionally, manually verified fix works
on both sample projects provided.
Change-Id: I51be4d6a974ecbeeaa1f63d764edabb230ae85e2
M navigation/fragment/src/androidTest/java/androidx/navigation/fragment/FragmentNavigatorTest.java
M navigation/fragment/src/main/java/androidx/navigation/fragment/FragmentNavigator.java
https://android-review.googlesource.com/725219
https://goto.google.com/android-sha1/791a3ffbae3efc6c0cfaa568b9d303eef0a523e0
Branch: androidx-master-dev
commit 791a3ffbae3efc6c0cfaa568b9d303eef0a523e0
Author: Daniel Santiago Rivera <danysantiago@google.com>
Date: Thu Aug 02 09:27:01 2018
Fix back stack inconsistency when detecting back pressed.
FragmentNavigator's back stack was becoming inconsistent with the
FragmentManager's back stack due to in-between multiple pending
operations callbacks occurring that would cause the difference between
the new count and the final count to be equal and thus causing the
amount of pending operations not to be decreased.
This changes takes a slightly different strategy, instead of counting
pending operations, we just flag that we have pending operations and we
don't consider them done until the FragmentManager's back stack is equal
to the Navigator's back stack. Consuming back stack callbacks as long
as there are pending operations so that we don't accidentally detect a
back press. Since a back press causes a popBackStackImmediate() we have
confidence pending operations will be executed causing the Navigator to
reset the flag to later then detect the back press pop.
Bug: 111884848
Bug: 111907708
Test: FragmentNavigatorTest, additionally, manually verified fix works
on both sample projects provided.
Change-Id: I51be4d6a974ecbeeaa1f63d764edabb230ae85e2
M navigation/fragment/src/androidTest/java/androidx/navigation/fragment/FragmentNavigatorTest.java
M navigation/fragment/src/main/java/androidx/navigation/fragment/FragmentNavigator.java
da...@google.com <da...@google.com>
da...@google.com <da...@google.com> #4
A fix for this issue will be available in alpha05.
ar...@gmail.com <ar...@gmail.com> #5
Bug still exist on alpha05.
il...@google.com <il...@google.com> #6
Re #5 - if you're still running into an issue, please file a new issue with a sample project that reproduces your issue.
am...@gmail.com <am...@gmail.com> #7
Bug still exist on alpha11.
il...@google.com <il...@google.com> #8
Re #7 - if you're still running into an issue, please file a new issue with a sample project that reproduces your issue.
me...@gmail.com <me...@gmail.com> #9
this bug is still present in 2.3.0
Description
Version used: 1.0.0-alpha04
Devices/Android versions reproduced on: (does not depend on device)
Let's say, my back stack is A->B. When I click 'back' button, the last fragment is getting popped (fragment A gets displayed), but this is done by the FragmentManager's transaction handling behavior. Inside NavController back stack does not get updated. Thus, if I then try to navigate via action, I get an exception saying that the action is not found (because the top of back stack is still fragment B).