To start, we will update our project to make use of Core KTX. To do this, we'll first need to make sure we have the google() Maven repository added to our project. To add it, use the following code:
repositories {
google()
}
Next, we'll define a constant for core-ktx in our buildSrc directory:
object Android {
object Tools {
const val androidGradle = "com.android.tools.build:gradle:3.5.0-beta04"
}
object Ktx {
const val core = "androidx.core:core-ktx:1.0.1"
}
}
We'll then add the following dependency to app/build.gradle.kts:
dependencies {
...
implementation(Deps.Android.Ktx.core)
}
Now that Core KTX is added to our project, let's explore some of the ways in which it makes developers' lives easier.