Gradle & Code Quality

Android Version Catalogs: Share Coordinates Without Hiding Dependencies

A Gradle version catalog centralizes dependency aliases and version declarations. It improves consistency, but it does not by itself force every resolved dependency to use the version written in the catalog.

By , FounderUpdated 3 min read

Keep the catalog readable

An illustrative gradle/libs.versions.toml structure is:

TOML · REFERENCE EXAMPLE
[versions]
example = "1.2.3"

[libraries]
example-client = { module = "com.example:client", version.ref = "example" }

The coordinate is a placeholder, not a real dependency recommendation. A module can refer to the generated alias through the catalog accessors supported by the project.

The Gradle catalog guide explains aliases, bundles and plugin declarations.

Separate catalog versions from resolved versions

Mechanism Purpose
Version catalog Centralize declarations and aliases
Platform or BoM Align compatible module versions
Constraint Influence dependency selection
Lockfile Record resolved versions for reproducibility

A transitive constraint or platform can affect the selected version. Inspect the actual configuration with dependencies or dependencyInsight before claiming that changing a catalog entry changed every runtime artifact.

Choose aliases that expose intent

Prefer stable, descriptive names tied to the library's role or coordinate. Avoid aliases so generic that reviewers cannot tell whether they refer to a plugin, runtime library or test dependency.

Bundles are convenient, but a large bundle can hide unnecessary dependencies. A small module should not inherit an entire application stack merely because one alias is easy to type.

Migrate without changing everything at once

Move existing coordinates into the catalog while preserving versions and scopes, then verify that the resolved graph remains equivalent. Upgrade versions in a separate review where practical. This separates structural migration errors from dependency compatibility regressions.

Use APKLint with the complete context

The Gradle Dependency Checker can review declarations, but aliases may require the accompanying catalog to interpret. A snippet containing only libs.some.alias does not reveal the coordinate or version. Keep the catalog, module usage and resolved report together when diagnosing missing or unexpected libraries.

Connect a catalog alias to its module declaration

Using the illustrative example-client alias above, the corresponding Kotlin dependency declaration is implementation(libs.example.client). The hyphenated alias becomes a generated accessor path. Keep the catalog and its usage in the same review so a reader can trace the alias to the coordinate and version reference. The Gradle catalog documentation explains accessor generation and reserved names.

If an accessor is unresolved, check the TOML syntax, catalog name and alias spelling before changing the artifact version. The failure may happen while generating build accessors, before dependency resolution even requests a library. A second catalog uses its own accessor root, so an alias defined in a differently named catalog is not automatically available through libs.

Verify a migration without mixing in an upgrade

For a controlled migration, list every original coordinate, requested version and configuration. Move one family into the catalog and replace the declarations with aliases while preserving those values. Generate the same runtime and test reports before and after. An unchanged selected graph is useful evidence that the refactor preserved dependency selection; it does not require changing the project's locked versions merely to make the TOML look tidy.

Review bundles individually. For example, an application bundle containing client, UI and diagnostics libraries may be convenient for the app module, but a small background-processing library might need only the client. Give that module the single alias rather than inheriting unnecessary UI dependencies. Catalog organization should make the dependency boundary easier to see.

When a later upgrade is intentional, review both the version entry and the consumers sharing it. A common version key can update several artifacts at once. If those artifacts are not actually released as a compatible family, sharing the key may obscure independent requirements. Keep plugin aliases distinct from library aliases, and verify the supported usage location for each. Finally, retain the resolved reports or lockfile diff with the upgrade so the requested catalog change can be compared with the versions Gradle actually selected.

Sources and further reading

  1. Gradle: Version catalogs
  2. Android Developers: Add build dependencies

Reference review: 29 September 2026. Examples illustrate the workflow; check your installed versions, release artifact and account-specific Console requirements before applying them. This guide is not a claim that APKLint executed your project or verified your private account.

APKLint

Android inspection tools and practical release guides. About APKLint · Report a correction