Scaling a multi-module Android project is difficult when dependency versions are scattered across
dozens of build.gradle files. Gradle Version Catalogs (libs.versions.toml)
provide a type-safe, centralized way to manage your stack.
Creating the TOML File
Create a file named gradle/libs.versions.toml. This file will hold all your versions,
libraries, and plugins in a structured format.
[versions]
kotlin = "1.9.0"
retrofit = "2.9.0"
[libraries]
retrofit-core = { group = "com.squareup.retrofit2", name = "retrofit", version.ref = "retrofit" }
Type-Safe Usage
In your build.gradle.kts, you no longer use string literals for dependencies. Instead,
you call them via the generated libs accessor, which provides auto-completion and
prevents typos.
dependencies {
implementation(libs.retrofit.core)
}
The Verification Bonus
By centralizing versions, you ensure that every module uses the exact same version of a library, avoiding runtime crashes caused by dependency conflicts (duplicate classes or incompatible ABIs).
Summary
Ditch the ext.versions blocks and move to Version Catalogs. It's the modern, robust way
to handle dependencies in Android. Clean builds await!