Start Using the Bill of Materials in 2023 for compose

Start Using the Bill of Materials in 2023 for compose

I was learning jetpack compose and came across an awesome version management tool in android called BOM which stands for Bill of Management.

This is only used in native-compose projects. This lets you manage other library versions automatically by specifying only the BOM version. The way it works is quite simple. Each version of BOM is associated with a particular version of all other libraries and when we call a version of BOM, it automatically specifies the versions of all other libraries.

A simple example is shown below:

dependencies {
    // Import the Compose BOM
    implementation platform('androidx.compose:compose-bom:2022.12.00')

    // Override Material Design 3 library version with a pre-release version
    implementation 'androidx.compose.material3:material3:1.1.0-alpha01'

    // Import other Compose libraries without version numbers
    // ..
    implementation 'androidx.compose.foundation:foundation'
}

Let's clear some commonly asked questions:

Q1: Does the BOM automatically add all the Compose libraries to my app?

No, it only take care of the version of the application and not the library itself. It can only specify versions automatically.

Q2: Why BOM usage is recommended in modern Native Development?

The major advantage is by changing the BOM version to latest-version, it automatically changes the versions of all other libraries to latest-versions.

Q3: Am I forced to use the BOM?

Not at all. You can ignore this completely and define the libraries in your very way. Your app will work fine without any issues.

Refer this if you want to see the BOM version catalogs.

Did you find this article valuable?

Support LearnDroid by becoming a sponsor. Any amount is appreciated!