Google is committed to advancing racial equity for Black communities. See how.

Navigation

Navigation is a framework for navigating between 'destinations' within an Android application that provides a consistent API whether destinations are implemented as Fragments, Activities, or other components.

Latest Update Current Stable Release Next Release Candidate Beta Release Alpha Release June 24, 2020 2.3.0 - - -

Declaring dependencies

To add a dependency on Navigation, you must add the Google Maven repository to your project. Read Google's Maven repository for more information.

Add the dependencies for the artifacts you need in the build.gradle file for your app or module:

dependencies { def nav_version = "2.3.0" // Java language implementation implementation "androidx.navigation:navigation-fragment:$nav_version" implementation "androidx.navigation:navigation-ui:$nav_version" // Kotlin implementation "androidx.navigation:navigation-fragment-ktx:$nav_version" implementation "androidx.navigation:navigation-ui-ktx:$nav_version" // Feature module Support implementation "androidx.navigation:navigation-dynamic-features-fragment:$nav_version" // Testing Navigation androidTestImplementation "androidx.navigation:navigation-testing:$nav_version" }

Safe Args

To add Safe Args to your project, include the following classpath in your top level build.gradle file:

buildscript { repositories { google() } dependencies { def nav_version = "2.3.0" classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version" } }

You must also apply one of two available plugins.

To generate Java language code suitable for Java or mixed Java and Kotlin modules, add this line to your app or module's build.gradle file:

apply plugin: "androidx.navigation.safeargs"

Alternatively, to generate Kotlin code suitable for Kotlin-only modules add:

apply plugin: "androidx.navigation.safeargs.kotlin"

You must have android.useAndroidX=true in your gradle.properties file as per Migrating to AndroidX.

For information on using Kotlin extensions, see the ktx documentation.

For more information about dependencies, see Add Build Dependencies.

Feedback

Your feedback helps make Jetpack better. Let us know if you discover new issues or have ideas for improving this library. Please take a look at the existing issues in this library before you create a new one. You can add your vote to an existing issue by clicking the star button.

Create a new issue

See the Issue Tracker documentation for more information.

Version 2.3.0

Note: This version is dependent on the Java 8 programming language. Please read Use Java 8 language features to learn how to use it in your project.

Version 2.3.0

June 24, 2020

androidx.navigation:navigation-*:2.3.0 is released. Version 2.3.0 contains these commits.

Major changes since 2.2.0

Feature Module integration : The navigation-dynamic-features-runtime and navigation-dynamic-features-fragment artifacts allow you to navigate to destinations that are defined in feature modules, automatically handling the installation of the feature modules as needed. See Navigate with feature modules for more information.

: The and artifacts allow you to navigate to destinations that are defined in feature modules, automatically handling the installation of the feature modules as needed. See Navigate with feature modules for more information. Navigation Testing : The navigation-testing artifact provides a TestNavHostController that allows you to set the current destination and verify the back stack after navigation operations. See Test Navigation for more information.

: The artifact provides a that allows you to set the current destination and verify the back stack after navigation operations. See Test Navigation for more information. Returning a Result : The NavBackStackEntry associated with each destination on the Navigation back stack now allows you to access a SavedStateHandle suitable for storing small amounts of saved state that should be associated with a particular back stack entry. See Returning a result to the previous Destination for more information.

: The associated with each destination on the Navigation back stack now allows you to access a suitable for storing small amounts of saved state that should be associated with a particular back stack entry. See Returning a result to the previous Destination for more information. NavigationUI support for Openable : All usages of DrawerLayout in NavigationUI have been replaced with the more generic Openable interface added in CustomView 1.1.0 and implemented by DrawerLayout in DrawerLayout 1.1.0 .

: All usages of in have been replaced with the more generic interface added in CustomView and implemented by in DrawerLayout . Action and Mime Type support in deep links: Deep linking has been expanded to support app:action and app:mimeType in addition to the app:uri previously available. NavController now supports navigating by any combination of these fields via the new NavDeepLinkRequest class. See Navigate using NavDeepLinkRequest for more information.

Note: Support for adding an action and mime type in the visual editor is available in Android Studio 4.1 Canary 10 and higher.

Known Issues

Support for deep link actions and mime types is not yet available in Manifest Merger. Until that work is completed, any generated <intent-filter> elements from the <nav-graph> element in your manifest won't include your mime type in its <data> element or your custom <action> . You must manually add an appropriate <intent-filter> to your manifest.

Version 2.3.0-rc01

June 10, 2020

androidx.navigation:navigation-*:2.3.0-rc01 is released. Version 2.3.0-rc01 contains these commits.

Bug Fixes

Fixed a NullPointerException when replacing an instance of a destination with no arguments with another instance with arguments with singleTop . (b/158006669)

when replacing an instance of a destination with no arguments with another instance with arguments with . (b/158006669) All destination is unknown exceptions thrown by NavController now have additional debugging information to help determine the state of the NavController . (b/157764916)

Version 2.3.0-beta01

May 20, 2020

androidx.navigation:navigation-*:2.3.0-beta01 are released. Version 2.3.0-beta01 contains these commits.

Bug Fixes

Fixed an issue where the Lifecycle of the NavBackStackEntry would not be properly updated after process death. (b/155218371)

of the would not be properly updated after process death. (b/155218371) OnDestinationChangedListener instances registered before calling setGraph() are now properly sent the restored destination after a process death. (b/155218371)

instances registered before calling are now properly sent the restored destination after a process death. (b/155218371) When using singleTop , the NavBackStackEntry now correctly has its arguments updated and the updated arguments are sent to all OnDestinationChangeListener instances. (b/156545508)

Dependency Updates

Version 2.3.0-alpha06

April 29, 2020

androidx.navigation:navigation-*:2.3.0-alpha06 is released. (Version 2.3.0-alpha06 contains these commits.)

New Features

Deep linking has been expanded to support app:action and app:mimeType in addition to the app:uri previously available. NavController now supports navigating by any combination of these fields via the new NavDeepLinkRequest class. (b/136573074, b/135334841)

Note: <intent-filter> elements won't include your mime type in its <data> element or your custom <action> . You can add the attributes manually to the <deeplink> element in XML and manually add an <intent-filter> to your manifest, respectively. Support for deep link actions and mime types is not yet available in Android Studio or in Manifest Merger . Until those are completed, you won't see the new attributes in the visual editor and any generatedelements won't include your mime type in itselement or your custom. You can add the attributes manually to theelement in XML and manually add anto your manifest, respectively.

API Changes

Greatly expanded the Kotlin DSL support for Dynamic Navigation destinations. (b/148969800)

Bug Fixes

Fixed an issue where deep link Intents would be ignored when using a nested start destination. (b/154532067)

Version 2.3.0-alpha05

April 15, 2020

androidx.navigation:navigation-*:2.3.0-alpha05 is released. Version 2.3.0-alpha05 contains these commits.

New Features

For dynamic graph includes using <include-dynamic> , you no longer need to specify app:graphPackage and a default one will be used by adding moduleName suffix to the applicationId after a dot. If you do need to customize your graphPackage , an ${applicationId} placeholder is now supported. (b/152696768)

, you no longer need to specify and a default one will be used by adding suffix to the after a dot. If you do need to customize your , an placeholder is now supported. (b/152696768) The Navigation Graph Kotlin DSL now exposes a defaultArguments Map for actions, mirroring the ability to set default values on <action> elements in Navigation XML files. (b/150345605)

Bug Fixes

From Navigation 2.2.2: Fixed an IllegalStateException when deep linking to the start destination of your graph when you have multiple NavHostFragment instances in your Activity. (b/147378752)

Dependency updates

Version 2.3.0-alpha04

March 18, 2020

androidx.navigation:navigation-*:2.3.0-alpha04 is released. Version 2.3.0-alpha04 contains these commits.

New Features

Added support for feature module activity and fragment destinations in the Navigation Kotlin DSL. (b/148969800)

API Changes

The DynamicExtras class no longer uses a builder pattern and can now be constructed directly. (aosp/1253671)

class no longer uses a builder pattern and can now be constructed directly. (aosp/1253671) DynamicActivityNavigator now takes a Context in its constructor rather than an Activity . (aosp/1250252)

Bug Fixes

NavigationUI no longer ignores empty labels (i.e., a destination with android:label=”” ) and now correctly sets the title to an empty string. (b/148679860)

Dependency Updates

The Navigation Dynamic Features artifacts now depend on Play Core 1.6.5 . (b/149556401)

Version 2.3.0-alpha03

March 4, 2020

androidx.navigation:navigation-*:2.3.0-alpha03 is released. Version 2.3.0-alpha03 contains these commits.

API Changes

Instead of relying on the concrete DrawerLayout class, AppBarConfiguration now uses the Openable interface introduced in CustomView 1.1.0-alpha02 (which DrawerLayout implements as of DrawerLayout 1.1.0-alpha04 ), allowing you to use custom implementations of Openable with NavigationUI . (b/129030452)

Bug Fixes

The navigation-common-ktx ProGuard rules now correctly only keep the NavArgs classes that are used rather than all NavArgs instances. (b/150213558)

Dependency changes

Navigation has reverted its dependency on Core 1.2.0 and now depends on Core 1.1.0 to avoid forcing developers to move to a newer dependency when Navigation does not depend on any new APIs in Core 1.2.0 .

Version 2.3.0-alpha02

February 19, 2020

androidx.navigation:navigation-*:2.3.0-alpha02 is released. Version 2.3.0-alpha02 contains these commits.

New Features

The NavBackStackEntry now allows you to access a SavedStateHandle suitable for storing small amounts of saved state that should be associated with a particular back stack entry. See Returning a result for an example use case. (b/79672220)

API Changes

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)

Bug Fixes

navigateUp() now passes the current destination’s arguments and the KEY_DEEP_LINK_INTENT to the previous destination when launching your app on your own task stack. (b/147456890)

Dependency changes

Navigation now depends on Core 1.2.0 .

Version 2.3.0-alpha01

February 5, 2020

androidx.navigation:navigation-*:2.3.0-alpha01 is released. Version 2.3.0-alpha01 contains these commits.

New features

The new navigation-testing artifact provides a TestNavHostController class. This class provides an alternative to using a mock NavController when testing Navigation that allows you to set the current destination and verify the back stack after navigation operations. (b/140884273)

artifact provides a class. This class provides an alternative to using a mock when testing Navigation that allows you to set the current destination and verify the back stack after navigation operations. (b/140884273) The new navigation-dynamic-features-fragment (and its transitive dependency, navigation-dynamic-features-runtime ) allows you to include destinations or entire navigation graphs (via <include-dynamic> ) from feature modules, providing seamless installation of on-demand feature modules when navigating to those destinations. See Navigate with feature modules for more information. (b/132170186)

Bug fixes

From Navigation 2.2.1 : Deep links without query parameters now correctly ignore any query parameters rather than appending them to trailing {argument} elements or not matching the deep link. (b/147447512)

: Deep links without query parameters now correctly ignore any query parameters rather than appending them to trailing elements or not matching the deep link. (b/147447512) From Navigation 2.2.1 : The navigation-ui ProGuard rules for DrawerArrowDrawable have been updated to ensure that android.enableJetifier=true is not required. (b/147610424)

: The ProGuard rules for have been updated to ensure that is not required. (b/147610424) From Navigation 2.2.1 : The navigation-common-ktx module now has a unique manifest package name instead of sharing the same manifest package name as navigation-runtime-ktx . (aosp/1141947)

Dependency updates

Version 2.2.2

Note: This version is dependent on the Java 8 programming language. Please read Use Java 8 language features to learn how to use it in your project.

Version 2.2.2

April 15, 2020

androidx.navigation:navigation-*:2.2.2 are released. Version 2.2.2 contains these commits.

Bug Fixes

Fixed an IllegalStateException when deep linking to the start destination of your graph when you have multiple NavHostFragment instances in your Activity. (b/147378752)

when deep linking to the start destination of your graph when you have multiple instances in your Activity. (b/147378752) NavigationUI no longer ignores empty labels (i.e., a destination with android:label=”” ) and now correctly sets the title to an empty string. This was previously released in Navigation 2.3.0-alpha04. (b/148679860)

no longer ignores empty labels (i.e., a destination with ) and now correctly sets the title to an empty string. This was previously released in Navigation 2.3.0-alpha04. (b/148679860) The navigation-common-ktx ProGuard rules now correctly only keep the NavArgs classes that are used rather than all NavArgs instances. This was previously released in Navigation 2.3.0-alpha03. (b/150213558

Dependency updates

Navigation now depends on Fragment 1.2.4 . (aosp/1277325)

Version 2.2.1

Note: This version is dependent on the Java 8 programming language. Please read Use Java 8 language features to learn how to use it in your project.

Version 2.2.1

February 5, 2020

androidx.navigation:navigation-*:2.2.1 is released. Version 2.2.1 contains these commits.

Bug fixes

Deep links without query parameters now correctly ignore any query parameters rather than appending them to trailing {argument} elements or not matching the deep link. (b/147447512)

elements or not matching the deep link. (b/147447512) The navigation-ui ProGuard rules for DrawerArrowDrawable have been updated to ensure that android.enableJetifier=true is not required. (b/147610424)

ProGuard rules for have been updated to ensure that is not required. (b/147610424) The navigation-common-ktx module now has a unique manifest package name instead of sharing the same manifest package name as navigation-runtime-ktx . (aosp/1141947)

Dependency updates

Version 2.2.0

Note: This version is dependent on the Java 8 programming language. Please read Use Java 8 language features to learn how to use it in your project.

Version 2.2.0

January 22, 2020

androidx.navigation:navigation-*:2.2.0 is released. Version 2.2.0 contains these commits.

Important changes since 2.1.0

NavBackStackEntry : You can now call NavController.getBackStackEntry() , passing in the ID of a destination or navigation graph on the back stack. The returned NavBackStackEntry provides a Navigation-driven LifecycleOwner , ViewModelStoreOwner (the same returned by NavController.getViewModelStoreOwner() ), and SavedStateRegistryOwner , in addition to providing the arguments used to start that destination.

: You can now call , passing in the ID of a destination or navigation graph on the back stack. The returned provides a Navigation-driven , (the same returned by ), and , in addition to providing the arguments used to start that destination. Lifecycle ViewModel SavedState Integration : SavedStateViewModelFactory is now the default factory used when using by navGraphViewModels() or the ViewModelProvider constructor with a ViewModelStoreOwner returned by NavController.getBackStackEntry() or NavController.getViewModelStoreOwner() .

: is now the default factory used when using or the constructor with a returned by or . Query Parameter Support for Deep Links : Deep links with query parameters now support reordered query parameters; arguments that have a default value or are nullable are now optional when matching deep links.

: Deep links with query parameters now support reordered query parameters; arguments that have a default value or are nullable are now optional when matching deep links. Improved Animation Support: NavHostFragment now uses FragmentContainerView from Fragment 1.2.0, fixing animation z-ordering issues and window insets dispatching to Fragments.

Version 2.2.0-rc04

December 18, 2019

androidx.navigation:navigation-*:2.2.0-rc04 is released. Version 2.2.0-rc04 contains these commits.

Bug fixes

Adjusted the default fade animations used by navigation-ui to match the adjusted fade animations in Fragment 1.2.0-rc04 . (b/145769814)

Version 2.2.0-rc03

December 4, 2019

androidx.navigation:navigation-*:2.2.0-rc03 is released. Version 2.2.0-rc03 contains these commits.

Bug fixes

Fixed an issue with deep link parsing when using query parameters and an argument as the last part of the path that prevented more than one character of the final path argument from being parsed. (b/144554689)

Fixed an issue with deep link parsing where optional parameters would receive "@null" instead of null . (b/141613546)

instead of . (b/141613546) NavHostFragment now correctly restores the graph after a configuration change when used with FragmentContainerView . (b/143752103)

Dependency changes

Navigation now depends on Lifecycle 2.2.0-rc03 , Lifecycle ViewModel SavedState 1.0.0-rc03 , Activity 1.1.0-rc03 , and Fragment 1.2.0-rc03 where appropriate.

Version 2.2.0-rc02

November 7, 2019

androidx.navigation:navigation-*:2.2.0-rc02 is released. Version 2.2.0-rc02 contains these commits.

Dependency changes

Navigation now depends on androidx.lifecycle 2.2.0-rc02 .

Version 2.2.0-rc01

October 23, 2019

androidx.navigation:navigation-*:2.2.0-rc01 is released with no changes since 2.2.0-beta01 . Version 2.2.0-rc01 contains these commits.

Version 2.2.0-beta01

October 9, 2019

androidx.navigation:navigation-*:2.2.0-beta01 is released. Version 2.2.0-beta01 contains these commits.

New features

NavDestination and its subclasses now override toString() to provide more helpful information when debugging. (b/141264986)

Behavior changes

Extra query parameters are now ignored when matching deep links rather than causing the match to fail. (b/141482822)

Bug fixes

Fixed an issue where arguments in a deep link’s path would be ignored if query parameters were also specified. (b/141505755)

The navArgs() Kotlin extension on Activity now has a better error message when there are no extras. (b/141408999)

Kotlin extension on now has a better error message when there are no extras. (b/141408999) Safe Args generated Directions Java classes now contain default values. (b/141099045)

Java classes now contain default values. (b/141099045) Safe Args generated Args Java classes now contain default values. (b/140123727)

Java classes now contain default values. (b/140123727) When using a Toolbar , NavigationUI no longer animates the text change when moving between two top level destinations. (b/140848160)

Version 2.2.0-alpha03

September 18, 2019

androidx.navigation:navigation-*:2.2.0-alpha03 is released. Version 2.2.0-alpha03 contains these commits.

Behavior changes

Calling setViewModelStore() after calling setGraph now results in an IllegalStateException . This should always be set by the NavHost as part of the initial setup to ensure that all NavBackStackEntry instances have a consistent storage for ViewModel instances. (aosp/1111821)

Bug fixes

Fixed a ConcurrentModificationException when using ViewModel instances attached to multiple different navigation graph scoped ViewModelStore instances. (aosp/1112257)

Version 2.2.0-alpha02

September 5, 2019

androidx.navigation:navigation-*:2.2.0-alpha02 is released. The commits included in this version can be found here.

New features

Deep links with query parameters now support reordered query parameters; arguments that have a default value or are nullable are now optional when matching deep links. (b/133273839)

You can now call NavController.getBackStackEntry() , passing in the ID of a destination or navigation graph on the back stack. The returned NavBackStackEntry provides a Navigation-driven LifecycleOwner , ViewModelStoreOwner (the same returned by NavController.getViewModelStoreOwner() ), and SavedStateRegistryOwner , in addition to providing the arguments used to start that destination. (aosp/1101691, aosp/1101710)

Bug fixes

Fixed an issue where adding a NavHostFragment to ViewPager2 failed with an IllegalArgumentException . (b/133640271)

to failed with an . (b/133640271) NavInflater now avoids calling getResourceName() unnecessarily, speeding up inflation time by up to 40%. (b/139213740)

Version 2.2.0-alpha01

August 7, 2019

androidx.navigation:navigation-*:2.2.0-alpha01 is released. The commits included in this version can be found here.

New features

SavedStateViewModelFactory is now the default factory used when using by navGraphViewModels() or the ViewModelProvider constructor with a ViewModelStoreOwner returned by NavController.getViewModelStoreOwner() . (b/135716331)

API changes

From Navigation 2.1.0-rc01 : The deprecated getViewModelStore() API on NavController introduced in 2.1.0-alpha02 has been removed. (aosp/1091021)

Bug fixes

NavHostFragment now uses FragmentContainerView , fixing animation z-ordering issues and window insets dispatching to Fragments. (b/137310379)

Version 2.1.0

Version 2.1.0

September 5, 2019

androidx.navigation:navigation-*:2.1.0 is released. The commits included in this version can be found here.

Important changes since 2.0.0

Scoping ViewModels to a navigation graph : You can now create ViewModels that are scoped at the navigation graph level using the by navGraphViewModels() property delegate for Kotlin users using the -ktx libraries or by using the getViewModelStoreOwner() API added to NavController . See Share UI-related data between destinations for more information.

: You can now create ViewModels that are scoped at the navigation graph level using the property delegate for Kotlin users using the libraries or by using the API added to . See Share UI-related data between destinations for more information. Dialog destinations : You can now create <dialog> destinations that will show a DialogFragment when you navigate to them. NavHostFragment supports dialog destinations by default. See Create a destination from a DialogFragment for more information.

: You can now create destinations that will show a when you to them. supports dialog destinations by default. See Create a destination from a DialogFragment for more information. Navigating by Uri : You can now navigate using a Uri , which uses the <deepLink> you’ve added to a destination to navigate there. See Navigate using Uri for more information.

: You can now using a , which uses the you’ve added to a destination to navigate there. See Navigate using Uri for more information. NavHostController: APIs used specifically for constructing a custom NavHost have been moved to NavHostController , allowing implementations to connect their NavController to the hosting LifecycleOwner , OnBackPressedDispatcher , and ViewModelStore .

Version 2.1.0-rc01

August 7, 2019

androidx.navigation:navigation-*:2.1.0-rc01 is released. The commits included in this version can be found here.

API changes

The deprecated getViewModelStore() API on NavController introduced in 2.1.0-alpha02 has been removed. (aosp/1091021)

Version 2.1.0-beta02

July 19, 2019

androidx.navigation:*:2.1.0-beta02 is released. The commits included in this version can be found here.

Note: This version is dependent on the Java 8 programming language. Please read Use Java 8 language features to learn how to use it in your project.

Bug fixes

Removed unintentional jacoco dependency that was introduced in 2.1.0-beta01 . (b/137782950)

Version 2.1.0-beta01

July 17, 2019

androidx.navigation:*:2.1.0-beta01 is released. The commits included in this version can be found here.

Caution: This version contains an unintentional dependency on org.jacoco:org.jacoco.agent:0.8.3 , which can cause a build failure. Please update to the latest version, in which this dependency has been removed.

Note: This version is dependent on the Java 8 programming language. Please read Use Java 8 language features to learn how to use it in your project.

New features

NavigationUI now animates the removal of the Up button when using setupWithNavController() with a Toolbar or CollapsingToolbarLayout . (b/131403621)

Bug fixes

Fixed a timing issue when using multiple NavHostFragments with the same container with findNavController() . (b/136021571)

Version 2.1.0-alpha06

July 2, 2019

androidx.navigation:*:2.1.0-alpha06 is released. The commits included in this version can be found here.

Note: This version is dependent on the Java 8 programming language. Please read Use Java 8 language features to learn how to use it in your project.

New features

The app:navGraph attribute used by NavHostFragment has now been moved to the navigation-runtime artifact. Custom navigators that can be added via XML should use this attribute to gain integration with the Navigation Editor’s Host panel. (b/133880955)

API changes

The getViewModelStore() API on NavController has been deprecated in favor of the new getViewModelStoreOwner() method that returns a ViewModelStoreOwner . (aosp/987010)

API on has been deprecated in favor of the new method that returns a . (aosp/987010) The implementation of floating window destinations, such as <dialog> destinations, has been generalized into a marker interface, FloatingWindow , that all <dialog> destinations now implement. NavigationUI methods for interacting with the top app bar now ignore FloatingWindow destinations. (b/133600763)

Behavior changes

Navigation now correctly keeps its state in sync with what is seen on the screen when using a <dialog> destination. As a consequence, Navigation now automatically pops <dialog> destinations when you navigate to a non-dialog and non-activity destination, such as a <fragment> destination. (b/134089818)

Bug fixes

Navigation now suppresses the animation that occurs when recreating the activity when handling a deep link, fixing a visual flash. (b/130362979)

Fixed a bug where the Navigation back stack would be out of sync when popping a Fragment as the initial fragment is being added. (b/133832218)

Version 2.1.0-alpha05

June 5, 2019

androidx.navigation:*:2.1.0-alpha05 is released. The commits included in this version can be found here.

API changes

Host related APIs on NavController have been renamed and moved to a new subclass of NavController , NavHostController . (aosp/966091)

have been renamed and moved to a new subclass of , . (aosp/966091) The NavController setHostOnBackPressedDispatcherOwner() method has been replaced with NavHostController ’s setOnBackPressedDispatcher() method and now requires that you call setLifecycleOwner() prior to calling it. (aosp/965409)

method has been replaced with ’s method and now requires that you call prior to calling it. (aosp/965409) NavHostController now contains a enableOnBackPressed(boolean) method that replaces the NavHostOnBackPressedManager class that was previously returned by setHostOnBackPressedDispatcherOwner() . (aosp/966091)

Bug fixes

Fixed an issue where the back stack was not correct after navigating by URI. (b/132509387)

Deep links automatically handled by NavController now only trigger once. (b/132754763)

Version 2.1.0-alpha04

May 16, 2019

androidx.navigation:*:2.1.0-alpha04 is released. The commits included in this version can be found here.

Bug fixes

NavHostFragment correctly respects app:defaultNavHost when intercepting the system Back button events, fixing a regression in Navigation 2.1.0-alpha03 . b/132077777

correctly respects when intercepting the system Back button events, fixing a regression in Navigation . b/132077777 DialogFragmentNavigator now correctly handles popBackStack() and navigateUp() operations. b/132576764

now correctly handles and operations. b/132576764 Fixed an IllegalStateException: unknown destination during restore issue when repeatedly navigating between nested graphs. b/131733658

Version 2.1.0-alpha03

May 7, 2019

androidx.navigation:*:2.1.0-alpha03 is released. The commits included in this version can be found here.

Known Issues

NavHostFragment continues to intercept the system Back button despite using app:defaultNavHost="false" b/132077777

New features

You can now create <dialog> destinations that will show a DialogFragment when you navigate to them. NavHostFragment supports dialog destinations by default. b/80267254

destinations that will show a when you to them. supports dialog destinations by default. b/80267254 In addition to calling navigate with a resource id or a NavDirections instance, you can now navigate via a Uri , which uses the <deepLink> you’ve added to a destination to navigate to the correct destination. b/110412864

Behavior changes

The default animations provided by NavigationUI have been sped up from 400ms to 220ms to match the default animation speed of activities and fragments. b/130055522

API changes

The createFragmentNavigator() method of NavHostFragment has been deprecated and its functionality moved to the new onCreateNavController() method to make it more clear that this is the correct entry point of adding custom Navigators when subclassing NavHostFragment . b/122802849

method of has been deprecated and its functionality moved to the new method to make it more clear that this is the correct entry point of adding custom Navigators when subclassing . b/122802849 A hasDeepLink() method has been added to NavDestination to allow you to check if a given Uri can be handled by that destination or, in the case of a NavGraph , any destination in the navigation graph. b/117437718

Bug fixes

Default arguments are now correctly passed to OnDestinationChangedListener instances. b/130630686

instances. b/130630686 NavHostFragment now intercepts system Back events using the OnBackPressedDispatcher , fixing an issue when doing conditional navigation in Fragment lifecycle methods upon returning to a Fragment. b/111598096

now intercepts system Back events using the , fixing an issue when doing conditional navigation in Fragment lifecycle methods upon returning to a Fragment. b/111598096 For Safe Args, an android:defaultValue=”@null” with an unspecified app:argType is now properly inferred as a string argument. b/129629192

Version 2.1.0-alpha02

April 3, 2019

androidx.navigation:*:2.1.0-alpha02 is released. The commits included in this version can be found here.

New features

You can now create ViewModels that are scoped at a navigation graph level via the by navGraphViewModels() property delegate for Kotlin users or by using the getViewModelStore() API added to NavController . b/111614463

API changes

You can now add an app:targetPackage to an <activity> destination to limit the matching package name. It supports app:targetPackage="${applicationId}" for restricting the package to your own application id. b/110975456

Bug fixes

The android:name for <activity> destinations is no longer parsed into a Class at inflation time, preventing ClassNotFoundExceptions when using dynamic features. b/124538597

Version 2.1.0-alpha01

March 19, 2019

This is the first alpha release of Navigation 2.1.0 .

Dependency changes

Navigation now depends on androidx.core:core:1.0.1 and androidx.fragment:fragment:1.1.0-alpha05 . This release also removes the dependency on androidx.legacy:legacy-support-core-utils:1.0.0 . b/128632612

API Changes

A new Navigation.createNavigateOnClickListener(NavDirections) method has been added as an alternative to creating a click listener with a resource ID and Bundle. b/127631752

method has been added as an alternative to creating a click listener with a resource ID and Bundle. b/127631752 FragmentNavigator.instantiateFragment is now deprecated. The default implementation now uses FragmentFactory to instantiate Fragments. b/119054429

Bug Fixes

Navigation no longer sends a null Bundle when there are arguments attached to a destination, fixing an issue when using android:defaultValue="@null" . b/128531879

when there are arguments attached to a destination, fixing an issue when using . b/128531879 Safe Args now depends on KotlinPoet 1.1.0, fixing an issue with extremely long package names. b/123654948

Version 2.0.0

Version 2.0.0

March 14, 2019

Navigation 2.0.0 is released with no changes from 2.0.0-rc02 .

Version 2.0.0-rc02

March 6, 2019

Navigation 2.0.0-rc02 provides new artifacts with the androidx.navigation group ID and changes its dependencies to the AndroidX equivalents.

The behavior of 2.0.0-rc02 is identical to behavior to Navigation 1.0.0-rc02 and no changes to your code should be required to update from 1.0.0-rc02 besides updating your dependencies to match the new dependencies.

Your project must have migrated to AndroidX to use 2.X releases of Navigation. Navigation 1.0 stable will be the last release using the Support Library dependencies; all future development beyond 1.0 will be based on AndroidX and build upon the 2.0 stable release.

Pre-AndroidX Dependencies

For the pre-AndroidX versions of Navigation, include these dependencies:

dependencies { def nav_version = "1.0.0" implementation "android.arch.navigation:navigation-fragment:$nav_version" // For Kotlin use navigation-fragment-ktx implementation "android.arch.navigation:navigation-ui:$nav_version" // For Kotlin use navigation-ui-ktx }

For Safe args, add the following classpath in your top level build.gradle file

buildscript { repositories { google() } dependencies { classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0" } }

Version 1.0.0

Version 1.0.0

March 14, 2019

Navigation 1.0.0 is released with no changes from 1.0.0-rc02 .

Version 1.0.0-rc02

February 26, 2019

This is the second release candidate for Navigation's 1.0.0 stable release. This release contains a number of bug fixes.

Bug Fixes

Fixed an issue where popBackStack() would be ignored if the root graph did not have an ID b/126251695

would be ignored if the root graph did not have an ID b/126251695 navigateUp() now correctly handles navigating back to your app's task when called after handling a deep link without FLAG_ACTIVITY_NEW_TASK b/126082008

now correctly handles navigating back to your app's task when called after handling a deep link without b/126082008 Fixed an issue with ActivityNavigator.applyPopAnimationsToPendingTransition not applying the correct pop exit animation b/126237567

not applying the correct pop exit animation b/126237567 Kotlin code generated by Safe Args now properly escapes Kotlin keywords such as in and fun in the package name associated with the R class. b/126020455

Version 1.0.0-rc01

February 21, 2019

This is a release candidate for Navigation's 1.0.0 stable release. This release contains one bug fix.

Bug Fixes

Fixed an issue when using Fragments and singleTop navigation operations b/124294805

Version 1.0.0-beta02

February 12, 2019

This release includes a number of minor improvements and important bug fixes.

New Features

You can now use 0 as an android:defaultValue for reference arguments. b/124248602

Behavior changes

Exact deep link matches are now prioritized over deep links with .* or argument matches. b/123969518

Bug Fixes

popBackStack() and navigateUp now correctly return false when popping the last destination on the back stack, fixing a regression introduced in 1.0.0-beta01 . b/123933201

and now correctly return when popping the last destination on the back stack, fixing a regression introduced in . b/123933201 Navigation now correctly sets the ClassLoader during restoration of saved instance state, avoiding issues when using custom classes in Navigator saved state or in arguments sent to a NavDestination . b/123893858

during restoration of saved instance state, avoiding issues when using custom classes in saved state or in arguments sent to a . b/123893858 Safe Args generated NavArgs classes no longer crash when restoring a Parcelable[] argument from saved instance state. b/123963545

argument from saved instance state. b/123963545 Safe Args now properly cleans up unnecessary generated Kotlin classes. b/124120883

Version 1.0.0-beta01

February 4, 2019

This is the first beta release of Navigation; moving forward, the Navigation API is expected to stay stable until the next version unless there is a critical problem. This release contains some bug fixes and behavior changes.

Behavior changes

Navigation now ensures that argument default values are treated identically at runtime and through Safe Args. As a consequence, only arguments with an app:argType="reference" can have a default value point to another resource (for example, @color/colorPrimary ). Attempting to use a reference default value with a different app:argType will result in an exception when parsing the navigation XML. b/123551990

can have a default value point to another resource (for example, ). Attempting to use a reference default value with a different will result in an exception when parsing the navigation XML. b/123551990 Safe Args now depends on Android Gradle Plugin 3.3.0 aosp/888413

Safe Args now depends on Kotlin 1.3.20 aosp/888414

Bug Fixes

Safe Args can now be used in library and feature modules on all versions of the Android Gradle Plugin. b/121304903

Fixed a regression that would cause a single popBackStack() operation to pop all copies of a destination off the top of the back stack, rather than just a single destination at a time. b/123552990

operation to pop all copies of a destination off the top of the back stack, rather than just a single destination at a time. b/123552990 Fixed an issue where the FragmentNavigator state would desynchronize with the NavController 's state, causing an IllegalStateException when attempting to restore the back stack. b/123803044

state would desynchronize with the 's state, causing an when attempting to restore the back stack. b/123803044 Fixed an issue where the NavigationUI handled back arrow would not appear when using ProGuard with obfuscation. b/123449431

handled back arrow would not appear when using ProGuard with obfuscation. b/123449431 The code generated by Safe Args now properly handles using an app:argType pointing to a static inner class in the format .OuterClass$InnerClass . b/123736741

pointing to a static inner class in the format . b/123736741 The Java code generated by Safe Args now properly handles global actions and deeply nested destinations. b/123347762

Version 1.0.0-alpha11

January 23, 2019

This is a hotfix release of 1.0.0-alpha10 that fixes an issue with Safe Args.

Bug Fixes

Fixes an issue where Safe Args would fail to import the Directions class associated with global actions. b/123307342

Version 1.0.0-alpha10

January 23, 2019

Known Issues

Safe Args fails to import the Directions class associated with global actions. b/123307342

This release contains breaking API changes; please see the Breaking Changes section below.

New Features

Kotlin users can now use the by navArgs() property delegate to lazily get a reference to a Safe Args generated NavArgs class in an Activity or Fragment . b/122603367

property delegate to lazily get a reference to a Safe Args generated class in an or . b/122603367 Safe Args now allows you to generate Kotlin code by applying the androidx.navigation.safeargs.kotlin plugin. The Kotlin code is built specifically for Kotlin only modules, using default arguments and immutable classes over the builder pattern that is still available via the previous androidx.navigation.safeargs plugin. b/110263087

Behavior Changes

Matching deep links are now biased towards the deep link that has the most matching arguments. b/118393029

Calling setGraph() on a NavController will now reset the back stack. b/111450672

on a will now reset the back stack. b/111450672 Unknown deep links no longer throw an IllegalStateException , but are ignored, fixing issues with nested or multiple NavHostFragment s. b/121340440

Breaking Changes

The NavOptions.applyPopAnimationsToPendingTransition() method for applying pop animations to an Activity has been moved to ActivityNavigator . b/122413117

method for applying pop animations to an Activity has been moved to . b/122413117 Safe Args now avoids duplicating identical classes for actions without arguments. The return type for no argument methods in generated NavDirections classes is now NavDirections . b/123233147

. b/123233147 Safe Args generated Directions classes no longer have a public constructor - you should only be interacting with the generated static methods. b/123031660

Safe Args generated NavDirections classes no longer have a public constructor - they should only be generated via the static methods in the generated Directions classes. b/122963206

classes no longer have a public constructor - they should only be generated via the static methods in the generated Directions classes. b/122963206 The returned Bundle from NavDirections ' getArguments() is now marked as @NonNull rather than @Nullable . b/123243957

Bug Fixes

NavDeepLinkBuilder now correctly handles multiple simultaneous PendingIntent s to the same destination by using the arguments you pass in to determine the uniqueness. b/120042732

now correctly handles multiple simultaneous s to the same destination by using the arguments you pass in to determine the uniqueness. b/120042732 NavController now correctly handles popBackStack() operations when using a nested NavHostFragment or other child Fragments with a back stack. b/122770335

now correctly handles operations when using a nested or other child Fragments with a back stack. b/122770335 NavigationUI now correctly sets the content description of the Up button. b/120395362

now correctly sets the content description of the Up button. b/120395362 Safe Args generated Directions classes now correctly handle global actions that have the same id as an action on a destination. b/122962504

Safe Args generated NavDirections classes now correctly have equal hashCode() values when equals() would return true. b/123043662

classes now correctly have equal values when would return true. b/123043662 FragmentNavigator now throws a better error message if you attempt to do custom FragmentTransactions on the NavHostFragment 's FragmentManager . You should always use getChildFragmentManager() . b/112927148

Version 1.0.0-alpha09

December 18, 2018

This release contains breaking API changes; please see the Breaking Changes section below.

We have chosen not to continue development of the android.arch.navigation:navigation-testing artifact. While it has proven helpful for internal testing of NavController , we strongly recommend alternate testing strategies, such as mocking the NavController instance in order to verify that the correct navigate() calls are being done. This approach is discussed in detail in the Single Activity talk at AndroidDevSummit 2018 and we'll be working on additional documentation specifically around testing with Navigation.

New Features

MenuItem s with menuCategory="secondary" will no longer pop the back stack when used with NavigationUI methods. b/120104424

s with will no longer pop the back stack when used with methods. b/120104424 AppBarConfiguration now allows you to set a fallback OnNavigateUpListener instance which will be called when navController.navigateUp() returns false . b/79993862 b/120690961

Breaking Changes

When using an <argument> with an argType="reference" , Navigation no longer parses the reference, instead providing the raw resource ID itself. b/111736515

with an , Navigation no longer parses the reference, instead providing the raw resource ID itself. b/111736515 onNavDestinationSelected() now pops back to the start destination of your navigation graph by default, making them consistent with the setup methods. Add menuCategory="secondary" to your MenuItem to avoid popping the back stack. aosp/852869

now pops back to the start destination of your navigation graph by default, making them consistent with the methods. Add to your to avoid popping the back stack. aosp/852869 The fromBundle() methods of generated Args classes now take a non-null Bundle instead of a nullable Bundle aosp/845616

Bug Fixes

Arguments are now properly parsed from deep links as the correct argType instead of always as strings b/110273284

instead of always as strings b/110273284 Navigation now correctly exports its public resources b/121059552

Safe Args is now compatible with Android Gradle Plugin 3.4 Canary 4 and higher b/119662045

Version 1.0.0-alpha08

December 6, 2018

This release contains breaking API changes; please see the Breaking Changes section below.

New Features

Destination labels, when used with NavigationUI methods, will now automatically replace {argName} instances in your android:label with the correct argument b/80267266

methods, will now automatically replace instances in your with the correct argument b/80267266 Navigation now depends on Support Library 28.0.0 b/120293333

Breaking Changes

OnNavigatedListener has been renamed to OnDestinationChangedListener b/118670572

has been renamed to b/118670572 OnDestinationChangedListener now also passes the Bundle of arguments aosp/837142

now also passes the of arguments aosp/837142 The app:clearTask and app:launchDocument attributes and their associated methods have been removed. Use app:popUpTo with the root of your graph to remove all destinations from your back stack. b/119628354

and attributes and their associated methods have been removed. Use with the root of your graph to remove all destinations from your back stack. b/119628354 ActivityNavigator.Extras now uses a Builder pattern and adds the ability to set any Intent.FLAG_ACTIVITY_ flags aosp/828140

now uses a pattern and adds the ability to set any flags aosp/828140 NavController.onHandleDeepLink has been renamed to handleDeepLink aosp/836063

has been renamed to aosp/836063 Many classes and methods not meant for subclassing, such as NavOptions , NavInflater , NavDeepLinkBuilder , and AppBarConfiguration , have been made final aosp/835681

, , , and , have been made aosp/835681 The deprecated NavHostFragment.setGraph() method has been removed aosp/835684

method has been removed aosp/835684 The deprecated NavigationUI.navigateUp(DrawerLayout, NavController) method has been removed. aosp/835684

method has been removed. aosp/835684 Fragment creation has been moved to FragmentNavigator , making it easier to delegate Fragment creation to a FragmentFactory . b/119054429

, making it easier to delegate Fragment creation to a . b/119054429 The constructor for NavGraphNavigator no longer takes a Context aosp/835340

no longer takes a aosp/835340 NavigatorProvider is now a class, rather than an interface. The NavigatorProvider returned by getNavigatorProvider() has not changed its functionality. aosp/830660

returned by has not changed its functionality. aosp/830660 NavDestination.navigate() has been removed. Call navigate() on the Navigator instead. aosp/830663

has been removed. Call on the instead. aosp/830663 Significant refactoring of Navigator , removing the need for OnNavigatorNavigatedListener and instead having navigate return the NavDestination that was navigated to.

, removing the need for and instead having return the that was navigated to. Navigator instances can no longer send pop events to the NavController . Consider using a OnBackPressedCallback to intercept back button presses and call navController.popBackStack() . aosp/833716

Bug Fixes

popUpTo now works consistently when the destination is a <navigation> element b/116831650

now works consistently when the destination is a element b/116831650 Fixed a number of bugs that resulted in an IllegalArgumentException when using nested graphs b/118713731 b/113611083 b/113346925 b/113305559

when using nested graphs b/118713731 b/113611083 b/113346925 b/113305559 The dataPattern attribute of <activity> destinations will now populate arguments from non-String arguments by calling toString() b/120161365

Safe Args

Safe Args supports Serializable objects, including Enum values. Enum types can set a default value by using the enum literal without the class name (e.g. app:defaultValue="READ" ) b/111316353

) b/111316353 Safe Args supports arrays of all supported types b/111487504

Safe Args now ignores subfolders of resource directories b/117893516

Safe Args adds @Override annotations where appropriate b/117145301

Version 1.0.0-alpha07

October 29, 2018

New Features

A new AppBarConfiguration class allows you to customize which destinations are considered top-level destinations. See the updated documentation for details. b/117333663

You can now pass arguments to the start destination of your graph b/110300470

Deep links now support custom schemes with periods, hyphens, and plus signs. b/112806402

Breaking Changes

The navigation-testing-ktx module has been folded into the navigation-testing artifact and will no longer be published.

module has been folded into the and will no longer be published. The navigation-testing artifact now has a dependency on the Kotlin standard library. The API has been changed to be more consistent with Kotlin conventions, but you can continue to use it for tests written in Java.

artifact now has a dependency on the Kotlin standard library. The API has been changed to be more consistent with Kotlin conventions, but you can continue to use it for tests written in Java. Metadata manifest registered navigation graphs are no longer supported. b/118355937

Actions can no longer be attached to <activity> destinations. aosp/785539

Bug Fixes

Deep links now correctly parse query parameters. b/110057514

Activity destinations now correctly apply all enter and exit animations. b/117145284

Fixed crash that occurs after configuration changes when using custom Navigators. b/110763345

Safe Args

Safe args now have a fixed dependency on Android Gradle Plugin 3.2.1. b/113167627

Directions can now be generated for inner classes. b/117407555

Fixed an issue with generating Directions to an <include> graph. b/116542123

Version 1.0.0-alpha06

September 20, 2018

New Features

Shared Element Transitions for Fragment and Activity destinations are now supported b/79665225. For more information, see Implement navigation with the Navigation Architecture Component

Selecting an item in NavigationView will now close any containing bottom sheet b/112158843

API Changes

Breaking Change: The Navigator navigate() method now takes a Navigator.Extras parameter.

The Navigator method now takes a parameter. NavController's getGraph() method is now NonNull b/112243286

Bug Fixes

NavigationUI.setupWithNavController() no longer leaks views if used with views from individual destinations b/111961977

no longer leaks views if used with views from individual destinations b/111961977 Navigator onSaveState() is now only called once b/112627079

Safe Args

Navigation destination Directions classes now extend their parent's Directions class if it exists b/79871405

Directions and Args classes now have a useful toString() implementation b/111843389

Version 1.0.0-alpha05

August 10, 2018

Bug Fixes

Fix a bug which cause incorrect backstack behavior. b/111907708

Fix a bug in equals() of Generated Args classes. b/111450897

of Generated Args classes. b/111450897 Fix a build failure in Safe Args. b/109409713

Fix a conversion from resource identifiers to java names b/111602491

Fix error messages about nullability in Safe Args plugin.

Add missing nullability annotations.

Version 1.0.0-alpha04

July 19, 2018

Navigation 1.0.0-alpha04 and the associated Safe Args gradle plugin contains a number of API changes, behavior changes, and bug fixes.

API / Behavior Changes

NavHostFragment will always set the current Fragment as the primary navigation fragment, ensuring that child fragment managers are popped before the outer NavController is popped b/111345778

Safe Args

Breaking Change: app:type has been changed to app:argType to avoid conflicts with other libraries such as ConstraintLayout 2.0.0-alpha1 b/111110548

has been changed to to avoid conflicts with other libraries such as ConstraintLayout 2.0.0-alpha1 b/111110548 Error messages from Safe Args are now clickable b/111534438

Args classes now confirms that NonNull attributes are actually not null b/111451769

attributes are actually not null b/111451769 Additional NonNull annotations have been added to NavDirections and Args generated classes b/111455455 b/111455456

Bug Fixes

Fixed an issue with the system back button after deep linking to a fragment destination b/111515685

Version 1.0.0-alpha03

July 12, 2018

Navigation 1.0.0-alpha03 and the associated Safe Args gradle plugin contains a number of API changes, behavior changes, and bug fixes.

API / Behavior Changes

A NavigationUI.setupWithNavController method for Toolbar has been added b/109868820

A NavigationUI.setupWithNavController method for CollapsingToolbarLayout has been added b/110887183

popBackStack() now returns false when the back stack is empty or when the given destination ID is not in the back stack b/110893637

FragmentNavigator now ignores navigation operations after FragmentManager has saved state, avoiding “Can not perform this action after onSaveInstanceState” exceptions b/110987825

Safe Args

Breaking Change: Non-alphanumeric characters in action and argument names will be replaced by camel casing in the respective NavDirections method names E.g. DemoController.index will become setDemoControllerIndex b/79995048 E.g. action_show_settings will become actionShowSettings b/79642240

Non-alphanumeric characters in action and argument names will be replaced by camel casing in the respective NavDirections method names Breaking Change: Arguments are now considered non-null by default. To allow null values on string and parcelable arguments, add app:nullable="true" b/79642307

Arguments are now considered non-null by default. To allow null values on string and parcelable arguments, add b/79642307 You can now use app:type="long" with defaultValues in the form of “123L” b/79563966

with defaultValues in the form of “123L” b/79563966 Parcelable arguments are now supported, using a fully qualified class name for app:type . The only default value supported is "@null" b/79563966

. The only default value supported is b/79563966 Args classes now implement equals() and hashCode() b/79642246

and b/79642246 The Safe Args plugin can now be applied to library projects b/80036553

The Safe Args plugin can now be applied to feature projects b/110011752

Bug Fixes

Fixed issues when navigating during Fragment lifecycle methods b/109916080

Fixed issues when navigating through nested graphs multiple times b/110178671

Fixed issues when using setPopUpTo with the first destination in the graph b/109909461

with the first destination in the graph b/109909461 Fixed issue where all app:defaultValue values were being passed as Strings b/110710788

values were being passed as Strings b/110710788 aapt2 bundled with Android Gradle Plugin 3.2 Beta 01 now adds keep rules for every android:name attribute in Navigation XML files b/79874119

attribute in Navigation XML files b/79874119 Fixed memory leak when replacing the default FragmentNavigator b/110900142

Version 1.0.0-alpha02

June 7, 2018

Behavior Changes

FragmentNavigator now uses setReorderingAllowed(true) . b/109826220

Navigation now URLDecodes arguments parsed from deep links URLs. b/79982454

Bug Fixes

Fixed an IllegalStateException when calling navigate from Fragment lifecycle methods. b/79632233

Navigation now depends on Support Library 27.1.1 to fix flickering when using animations. b/80160903

Fixed an IllegalArgumentException when using defaultNavHost="true" as a child fragment. b/79656847

Fixed a StackOverflowError when using NavDeepLinkBuilder. b/109653065

Fixed an IllegalArgumentException when navigating back to a nested graph. b/80453447

Fixed an issue with overlapping Fragments when using launchSingleTop . b/79407969

Navigation now builds the correct synthetic back stack for nested graphs. b/79734195

NavigationUI will now highlight the correct item when using a nested graph as a MenuItem . b/109675998

API Changes

The clearTask attribute for actions and the associated API in NavOptions has been deprecated. b/80338878

The launchDocument attribute for actions and the associated API in NavOptions has been deprecated. b/109806636

Version 1.0.0-alpha01

May 8, 2018