androidfirebaseandroid-gradle-pluginbuild.gradlemaven-bom

How to ensure all firebase SDKs are the compatible version?


Currently we have a lot of firebase version.

firebase_core_version = '16.0.6'
firebase_perf_version = '16.2.2'
firebase_messaging_version = '17.3.4'
...

implementation "com.google.firebase:firebase-core:$firebase_core_version"
implementation "com.google.firebase:firebase-perf:$firebase_perf_version"
implementation "com.google.firebase:firebase-messaging:$firebase_messaging_version"
...

But they each have different version number and sometimes they are conflicting or resolved to unexpected versions by transitive includes. Or other module declares different version for same library... That steals my time.

Is there any solutions for this?


Solution

  • Gradle has "BoM" feature that is available from 5.0. and it enables you free from version hell.

    implementation platform('com.google.firebase:firebase-bom:20.0.1')
    implementation 'com.google.firebase:firebase-perf'
    implementation 'com.google.firebase:firebase-messaging'
    implementation 'com.google.firebase:firebase-appindexing'
    implementation 'com.google.firebase:firebase-config'
    

    You may notice that only new import firebase-bom has version and any other libraries don't have version.

    This is because BoM dependency contains all firebase version inside it (of course they are compatible!).
    So your module always import firebase-bom then version conflict will be gone.

    firebase-bom is currently experimental but it works for me. https://firebase.google.com/docs/android/setup#firebase-bom

    I hope androidx (jetpack) also have this!

    There is also okhttp-bom available. https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp-bom