Firebase Bill of Materials
Back in the days, Time was old and everything was simple. Life seemed pleasant and we no need to worry about Firebase versions. The came the versioning where we had to maintain a version for each module of Firebase SDK’s.
The most trouble part is we need to be sure whether each module version is supported by other, else it would throw build exceptions. This is some serious headache to us and the compiler.
Well, It’s time and the good old days are back. Thanks to the feature called Bill of Material(BoM).Where you can now use a single version for all the Firebase modules.
How does this work?
We need to add the Firebase gradle dependency for BoM in the app/build.gradle
file. That’s it. End of the story. You can now add all the Firebase modules you need as per your requirement.No need to mention module version, if you use a specific module version it overrides the version contained in BoM. BoM internally check the compatibility of the version and it pick the right version for you. Piece of cake right?
Let’s get started,
Check if the gradle version is greater than 5.0 . BoM support is automatically enabled. Just copy and paste the BoM dependencies in app/build.gradle
dependencies {
// Import the platform
implementation platform('com.google.firebase:firebase-bom:21.0.0')
// When using a BoM, dependencies don't require a specified version
// If you do specify a version, it overrides the library version specified in the BoM
implementation 'com.google.firebase:firebase-core'
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-firestore'
}
For earlier version of Gradle, We need to manually enable the BoM feature.,
- Add
enableFeaturePreview('IMPROVED_POM_SUPPORT')
to yoursettings.gradle
file. - Import the BoM like a normal library without the playform modifier.
When you want to update the Firebase module version just update the BoM verision.
Note : This feature is still in development. You can track and report issues here
Thanks. Happy Coding.