Step #4: Augmenting Our Dependencies

The line we added to dependencies in the top-level build.gradle file defined an artifact that contributes compile-time code, in the form of this Gradle plugin. We also need to add dependencies for runtime code, just as we have for things like RecyclerView.

So, in app/build.gradle, in its dependencies closure, add these lines:

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

The androidx.navigation:navigation-fragment-ktx artifact contains the core code for using the Navigation component to navigate between fragments. The androidx.navigation:navigation-ui-ktx contains a bit of additional code for integrating navigation with the Toolbar.

You may now go ahead and click the “Sync Now” link in the banner. Conversely, if for some reason that banner did not appear, choose “File” > “Sync Project with Gradle Files” in the Android Studio main menu.


Prev Table of Contents Next

This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.