Version catalogs and convention plugins

Runtime, build and Gradle Mid-level Kotlin 2.0+ API 24+ Reviewed By Best Latest Apps

Pick the fix

Twenty modules each declare compileSdk, Kotlin options and Compose setup by copy-paste, and they've drifted. Fix?

Options
Hint 1 of 1

Where do shared Gradle rules go in modern builds?

Choose an answer, then open Show answer below to check it.

Show answer

Answer: A A convention plugin in build-logic that each module applies

Correct. One source of truth, applied by id.

Why not the others?
  • B A root subprojects { } block. Works but harms isolation and configuration caching.
  • C A shared text file each build includes. Fragile and untyped.
  • D Merge into one module. Loses the benefits of modules.

30-second answer

Put versions and coordinates in a version catalog, gradle/libs.versions.toml, and refer to them as libs.androidx.room.runtime. Use BOMs for families like Compose and Firebase. Put shared build setup (compileSdk, Kotlin options, Compose, test setup) in convention plugins in an included build-logic build, so each module applies one plugin instead of copying blocks.

Practise saying it · 25 s. No recording, just a timer

Explain catalogs and convention plugins.

Say your answer out loud, then check which of these points you covered:

  • libs.versions.toml
  • BOMs
  • Convention plugins in build-logic
  • Avoid subprojects blocks

Deep dive

Catalogs give typed accessors and one place to upgrade.

Dependabot and Renovate understand version catalogs.

Convention plugins are better than subprojects { } blocks, which hurt configuration caching.

A BOM aligns versions so you omit them on individual artifacts.

A version catalog
[versions]
room = "2.8.5"

[libraries]
androidx-room-runtime = { module = "androidx.room:room-runtime", version.ref = "room" }
androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" }
compose-bom = { module = "androidx.compose:compose-bom", version = "2026.09.00" }

Common mistakes

  • Hard-coded versions in every module.
  • Copy-pasted android { } blocks.
  • Cross-project configuration in the root build file.

Senior take & follow-ups

Mention catalog, BOM and convention plugins as three layers.

Follow-up questions

Think of your answer first, then open the hint.

  1. What does a BOM do?

    Show hint

    Pins compatible versions for a family of libraries.

  2. Why avoid subprojects { }?

    Show hint

    It couples projects and breaks isolation and caching.

Suggest a fix if something here is wrong or out of date.