Exploring Firebase Bill of Materials (BoM)
Tags: firebase, android, gradle, gradle5
Published: 2019-03-19 18:08:27

---
title: Exploring Firebase Bill of Materials (BoM)
published: true
description: Use the same version for all Firebase Android SDKs
tags: ["Firebase", "Android", "Gradle", "Gradle 5"]
---

*Portuguese version available in [developingwith.firebaseapp.com](https://developingwith.firebaseapp.com/Exploring-Firebase-Bill-Of-Materials/)*

Once upon a time, in a not so distant past, one could easily add the Firebase SDK to their Android Project not worrying about different versions for each module. Every module (core, auth, firestore, storage, etc) would use the same version, so our `build.gradle (app)` file would look like this:

```groovy
    implementation 'com.google.firebase:firebase-core:12.0.0'
    implementation 'com.google.firebase:firebase-firestore:12.0.0'
    implementation 'com.google.firebase:firebase-auth:12.0.0'
```

Or even better, we could declare the firebase version in the `build.gradle (project)`:

```groovy
buildscript {
    ext.firebase_version = '12.0.0'
    // ... Other configurations
}
```

and then use it in the `build.gradle (app)`:

```groovy
    implementation 'com.google.firebase:firebase-core:$firebase_version'
    implementation 'com.google.firebase:firebase-firestore:$firebase_version'
    implementation 'com.google.firebase:firebase-auth:$firebase_version'
```

But the happiness in this Kingdom didn't last long. After some time, some modules started getting updates more frequently than others, forcing the sdk developers to bump their versions and thus having different versions for each module.

Well, if you wish you had lived in that fairy-tale, I have good news for you! Thanks to the feature **Bills of Material (BoM)** introduced in [Gradle 5.0](https://docs.gradle.org/current/userguide/upgrading_version_4.html#rel5.0:bom_import) you can now use a single version for all the Firebase Android SDK modules.

Bills of Material (BoM) allows the SDK developers to specify (in a bill) which module versions are known to work with each other and then set a version to this bill.

So every time the Firebase Team publishes a new bill, you can be sure that you'll be using the latest versions(at time the BoM was published) of every module.

You can find the latest BoM version in the [Firebase Android Release Notes](https://firebase.google.com/support/release-notes/android).

---

# Getting Started

## Upgrading to Gradle 5.0
Since the BoM feature was introduced in gradle 5.0, you'll probably want to upgrade your gradle version (if you haven't already).

To upgrade to gradle 5.0 and add Firebase BoM to your Android Project, follow these steps:

1. Upgrade to version 4.10 first and check for any errors deprecation warnings. It's better to fix all errors and warnings before upgrading to a newer version.

2. Upgrade to version 5.0 using this command in your project root folder:
```shell
./gradlew wrapper --gradle-version 5.0
```

3. Sync your project and add the dependencies to your gradle file:
```groovy
dependencies {
    // Import the BoM
    implementation platform('com.google.firebase:firebase-bom:16.0.0')

    // Import the modules not minding their versions. Hooray!
    implementation 'com.google.firebase:firebase-core'
    implementation 'com.google.firebase:firebase-firestore'
    implementation 'com.google.firebase:firebase-auth'

    // ... Other dependencies
}
```

One more project sync and that's it! You no longer need to worry about different versions for each module.

## With Gradle 4.6.x or higher

If you're not planning to upgrade to Gradle 5.0, you can still take advantage of this feature, because it has been in experimental mode since gradle 4.6.x, you just need to enable it:
1. Open your project's `settings.gradle` file and add the line `enableFeaturePreview('IMPROVED_POM_SUPPORT')`:

```groovy
include ':app'
enableFeaturePreview('IMPROVED_POM_SUPPORT')
```

2. Sync your project and add the dependencies to your gradle file:
```groovy
dependencies {
    // Import the BoM
    implementation 'com.google.firebase:firebase-bom:16.0.0'

    // Import the modules not minding their versions. Hooray!
    implementation 'com.google.firebase:firebase-core'
    implementation 'com.google.firebase:firebase-firestore'
    implementation 'com.google.firebase:firebase-auth'

    // ... Other dependencies
}
```
One more project sync and that's it!

---


# Notes
Please note that:

- If you specify a module version and you use a Firebase BoM, then the specified module version overrides the version contained in the BoM.

- Firebase BoM is still an experimental feature, which means there might be some issues. If you want to report an issue or provide feedback, consider doing so in the [Firebase Android SDK Issue Tracker](https://github.com/firebase/firebase-android-sdk/issues).