Posted by Ian Lake, Software Engineering Lead& Jisha Abubaker, Product Manager
Cohesive tooling and guidance for implementing predictable in-app navigation
Today we’re happy to announce the stable release of the Android Jetpack Navigation component.
The Jetpack Navigation component’s suite of libraries, tooling and guidance offer a robust, complete navigation framework, freeing you from the challenges of implementing navigation yourself and giving you certainty that all edge lawsuits are managed correctly.
With the Jetpack Navigation component you can:
Handle basic user actions like Up& Back buttons so that they work consistently across devices and screens.
Allow users to land on any part of your app via deep connections and build consistent and predictable navigation within your app.
Improve type safety of debates passed from one screen to another, decreasing the the possibilities of runtime accidents as users navigate in your app.
Add navigation experiences like navigation drawers and bottom navigation consistent with the Material Design guidelines.
Visualize and manipulate your navigation flows easily with the Navigation Editor in Android Studio 3.3
The Jetpack Navigation component adheres to the Principles of Navigation, providing consistent and predictable navigation no matter how simple or complex your app may be.
Simplify navigation code with Jetpack Navigation Libraries
The Jetpack Navigation component provides a framework for in-app navigation that attains it is feasible to abstract away the implementation details, keeping your app code free of navigation boilerplate.
To get started with the Jetpack Navigation component in your project, add the Navigation artifacts available on Google’s Maven storehouse in Java or Kotlin to your app’s build.gradle file:
def nav_version= 2.0.0
implementation “androidx.navigation: navigation-fragment :$ nav_version”
implementation “androidx.navigation: navigation-ui :$ nav_version”
// Kotlin KTX
implementation “androidx.navigation: navigation-fragment-ktx :$ nav_version”
implementation “androidx.navigation: navigation-ui-ktx :$ nav_version”
Note: If you have not yet migrated to androidx .*, the Jetpack Navigation stable component libraries are also available as android.arch .* artifacts in version 1.0.0.
navigation-runtime: This core library powers the navigation graph, which provides the structure of your in-app navigation: the screens or destinations that make up your app and the actions that connect them. You can control how you navigate to destinations with a simple navigate() call. These destinations may be fragments, activities or custom destinations.
navigation-fragment: This library builds upon navigation-runtime and offer out-of-the-box support for fragments as destinations. With this library, fragment transactions are now managed for you automatically.
navigation-ui: This library allows you to easily add navigation drawers, menus and bottom navigation to your app consistent with the Material Design guidelines.
Each of these libraries offer an Android KTX artifact with the -ktx suffix that builds upon the Java API, taking advantage of Kotlin-specific language features.
Tools to help you build predictable navigation workflows
Available in Android Studio 3.3 and above, the Navigation Editor lets you visually create your navigation graph, allowing you to manage user journeys within your app.
With integration into the manifest merger tool, Android Studio can automatically generate the intent filters necessary to allow deep connecting to a specific screen in your app. With this feature, you can associate URLs with any screen of your app by simply setting an attribute on the navigation destination.
Navigation often involves passing data from one screen to another. For instance, your listing screen may pass an item ID to a details screen. Many of the runtime exceptions during navigation have been attributed to a lack of form safety guarantees as you pass debates. These exceptions are hard to replicate and debug. Learn how you can provide compile day type security with the Safe Args Gradle Plugin.
Guidance to get it right on the first try
Check out our brand new situated of developer guidebooks that encompass best practices to help you implement navigation correctly:
What developers say
Here’s what Emery Coxe, Android Lead@ HomeAway, has to say about the Jetpack Navigation component:
“The Navigation library is well-designed and fully configurable, allowing us to integrate the library according to our specific needs.
With the Navigation Library, we refactored our legacy navigation drawer to subsistence a dynamic, runtime-based configuration using custom views. It allowed us to add/ remove new screens to the top-level experience of our app without creating any interdependencies between discreetly packaged modules.
We were also able to get rid of all anti-patterns in our app around top-level navigation, removing explicit casts and hardcoded hypothesis to instead rely directly on Navigation. This library is a fundamental component of modern Android development, and we intend to adopt it more broadly across our app moving forward.
Check out the migration guidebook and the developer guidebook to learn how you can get started employing the Jetpack Navigation component in your app. We also offer a hands-on codelab and a sample app.
Also check out Google’s Digital Wellbeing to find another real-world instance of in-app navigation using the Android Jetpack Navigation component.
Please continue to tell us about your experience with the Navigation component. If you have specific feedback on features or if you run into all the questions, please file a bug via one of the following links:
For issues related to the Navigation Editor: Issue Tracker
For all other Navigation-related issues: Issue Tracker
Read more: feedproxy.google.com