Step #2: Adding the Plugin Dependency
In that same buildscript
closure, you will see a list of dependencies:
dependencies {
classpath "com.android.tools.build:gradle:7.0.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"
}
These represent sources of Gradle plugins, for helping us do more interesting things when we build our app.
Part of the Navigation component is a plugin, so we need to add another dependency to the buildscript
roster. So, add this line to that dependencies
closure:
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
This pulls in the androidx.navigation:navigation-safe-args-gradle-plugin
artifact, for the version number that we specified. We use string interpolation to add our nav_version
value into the dependency, which is why this string uses double-quotes; in Gradle (and the Groovy language it is built upon), a single-quoted string cannot use string interpolation.
The banner should still be there, asking you to “Sync Now”. Continue to hold off, as we need to make changes to another Gradle file.
Prev Table of Contents Next
This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.