Jetpack Navigation: Getting Started

Aug 10 2021 · Kotlin 1.4, Android 11, Android Studio 4.2.1

Part 1: Set Up Navigation

03. Add Dependencies

Episode complete

Play next episode

About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 02. Understand the Project Structure Next episode: 04. Create a Navigation Graph
Transcript: 03. Add Dependencies

You’ll add Dependencies for Navigation Architecture component in this episode. To do so, open in the browser.

In the left navigation panel, locate Navigation Component, expnad it and click on Getting Started Scrool to Set up your environment section. Copy the latest version of Navigation library.

Switch to Android studio, open the starter project for this episode and click on Project level build.gradle and paste the navigation version here.

Switch to Browser. Copy the dependencies for Kotlin.

implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"

Swtich to Android studio , click on Module’s build.gradle

Under TUTORIAL DEPENDENCIES here, paste the dependencies.

implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"

Click on Sync Now.

You added dependencies for Basic Navigation. In order to pass data between destinations, you will add Safe Args plugin.

Switch to Browser. Click on Pass Data between destinations in the left panel.

Scroll to Use Safe Args to pass data with type safety section. To add Safe Args to your project, include the folliwing classpath in your top level build.gradle file. Copy this line.

Swtich to Android studio , click on Project level build.gradle. Include the classpath here.

classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version" Switch to browser, now Copy the SafeArgs plugin id for Kotlin.

Switch to AS and open Module’s build.gradle.

Scroll to the top. Type apply plugin and paste the plugin id here.

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

Click on Sync Now.

Congratulations! You’ve added all the dependencies required for the course.