Fixed
Status Update
Comments
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #2
Fixed internally and will be available in navigation 2.8.0-alpha02
.
il...@google.com <il...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-main
commit db700c8e99e354fbc35cf4bbd5f6f811deb587a0
Author: Clara Fok <clarafok@google.com>
Date: Wed Jan 31 16:19:02 2024
Fix NavGraph ViewModel destroyed too soon
The NavGraph entry when popped gets stored into savedState bundle but the entry's ViewModel is cleared from the ViewModelStore because we did not track the entry's saveState. We used to only track the saveState on FragmentNavigator and ComposeNavigator. Now whenever we pop, the base NavControllerNavigatorState would add the entry to map of saveState so we don't destroy the VM prematurely.
Test: ./gradlew navigation:navigation-runtime:cC
Bug: 317581849
Change-Id: Ib6bb7d1d2f1af928a23a2647b1800eb4bb37d39d
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerTest.kt
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.kt
https://android-review.googlesource.com/2942087
Branch: androidx-main
commit db700c8e99e354fbc35cf4bbd5f6f811deb587a0
Author: Clara Fok <clarafok@google.com>
Date: Wed Jan 31 16:19:02 2024
Fix NavGraph ViewModel destroyed too soon
The NavGraph entry when popped gets stored into savedState bundle but the entry's ViewModel is cleared from the ViewModelStore because we did not track the entry's saveState. We used to only track the saveState on FragmentNavigator and ComposeNavigator. Now whenever we pop, the base NavControllerNavigatorState would add the entry to map of saveState so we don't destroy the VM prematurely.
Test: ./gradlew navigation:navigation-runtime:cC
Bug: 317581849
Change-Id: Ib6bb7d1d2f1af928a23a2647b1800eb4bb37d39d
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerTest.kt
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.kt
Description
Version used: alpha11
Devices/Android versions reproduced on: Android Studio 3.4 beta 2
I found a strange case, this morning, when I was trying to integrate the new alpha11 build into a project. I've replicated a minimal test case into a project and have replicated the situation.
What I see:
During build:
/Users/nealsanche/robots/Alpha11GlobalBug/app/build/generated/source/navigation-args/debug/com/robotsandpencils/testapp/tab1/Tab1FragmentDirections.java:10: error: cannot find symbol
public static com.robotsandpencils.testapp.Tab1FragmentDirections.com.robotsandpencils.testapp.NavGraphDirections.ActionGlobalGlobalFragment actionGlobalGlobalFragment() {
^
symbol: class com
location: class Tab1FragmentDirections
/Users/nealsanche/robots/Alpha11GlobalBug/app/build/generated/source/navigation-args/debug/com/robotsandpencils/testapp/tab2/Tab2FragmentDirections.java:26: error: cannot find symbol
public static com.robotsandpencils.testapp.Tab2FragmentDirections.com.robotsandpencils.testapp.NavGraphDirections.ActionGlobalGlobalFragment actionGlobalGlobalFragment() {
^
symbol: class com
location: class Tab2FragmentDirections
/Users/nealsanche/robots/Alpha11GlobalBug/app/build/generated/source/navigation-args/debug/com/robotsandpencils/testapp/tab3/Tab3FragmentDirections.java:26: error: cannot find symbol
public static com.robotsandpencils.testapp.Tab3FragmentDirections.com.robotsandpencils.testapp.NavGraphDirections.ActionGlobalGlobalFragment actionGlobalGlobalFragment() {
^
symbol: class com
location: class Tab3FragmentDirections
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
3 errors
FAILURE: Build failed with an exception.
All I did was right click on the GlobalFragment and generated a 'global' action from the menu.