Interview frequency: …
Short answer
They provide a central, unified place to manage the versions of libraries and plugins across all project modules, with support for autocomplete and strict type checking in kts files.
Explanation
In large multi-module projects, repeating library names caused version conflicts and difficulty upgrading. The libs.versions.toml file divides dependencies into four sections: [versions] for versions, [libraries] for libraries, [bundles] for grouping related libraries into a single variable, and [plugins] for Gradle plugins, which entirely prevents typos.
Code example
// 1. File gradle/libs.versions.toml:
[versions]
retrofit = "2.11.0"
[libraries]
retrofit-core = { group = "com.squareup.retrofit2", name = "retrofit", version.ref = "retrofit" }
// 2. Use in build.gradle.kts:
dependencies {
implementation(libs.retrofit.core)
}Common mistakes
- Pinning different versions of the same library by hand inside some submodules, bypassing the version catalog.