Search code examples
androidandroid-jetpackandroid-architecture-navigationandroid-mvvmandroid-jetpack-navigation

Why can't I access NavController.getCurrentBackStackEntry()?


On the docs it is listed as a public method that I should be able to use. However, it does not appear as a choice when I use the dot operator on my NavController field neither as a method or property. Can't get it to work on the debugger expression evaluator either. I can confirm my object is of type androidx.navigation.NavController

enter image description here


Solution

  • As per the Navigation 2.3.0-alpha02 release notes:

    Convenience methods of getCurrentBackStackEntry() and getPreviousBackStackEntry() have been added to make it easier to retrieve a NavBackStackEntry for the current and previous destinations. (b/79672220)

    So make sure you upgrade to Navigation 2.3.0-alpha02.