As you're developing your Android project using Firebase, you might discover concepts that are unfamiliar or specific to Firebase. This page aims to answer those questions or point you to resources to learn more.
If you have questions about a topic not covered on this page, feel free to visit one of our online communities. We'll also update this page with new topics periodically, so check back to see if we've added the topic you want to learn about!
Firebase Assistant plugin for Android Studio
The Firebase Assistant is an Android Studio plugin that registers your Android app with a Firebase project and adds the necessary Firebase config files, plugins, and dependencies to your Android project — all from within Android Studio!
Follow the instructions in the Android getting started page to use the Firebase Assistant. Make sure that you're using the most up-to-date versions of both Android Studio and the Firebase Assistant (go to File > Check for updates).
When you select specific Firebase products to add to your app, the Firebase
Assistant automatically declares the required dependencies in your
app/build.gradle
file. However, to use Firebase features that are beyond the
current capabilities of the Firebase Assistant, you may want to make some manual
changes to these dependencies:
If you want to use the Firebase Android BoM, update the dependencies in your module (app-level) Gradle file (usually
app/build.gradle
) to import the BoM platform. You'll also need to remove the versions from each Firebase library dependency line.If you want to use a Kotlin extensions library, modify the dependency line added to your module (app-level) Gradle file (usually
app/build.gradle
) to use thektx
version of the Firebase library instead.
Google services — plugin and config file
As part of adding Firebase to your Android project, you need to add the
google-services
plugin and a
configuration file to
your project.
If you add Firebase to your Android project via the Firebase console, the Management REST API, or the Firebase CLI, you must manually add the plugin and config file to your project. However, if you use the Firebase Assistant, these tasks are automatically done for you during setup.
Visit the Android documentation to learn about how the Google services plugin and config file work together.
Firebase Android BoM (Bill of Materials)
The Firebase Android BoM (Bill of Materials) enables you to manage all your Firebase library versions by specifying only one version — the BoM's version.
When you use the Firebase BoM in your app, the BoM automatically pulls in the individual library versions mapped to BoM's version. All the individual library versions will be compatible. When you update the BoM's version in your app, all the Firebase libraries that you use in your app will update to the versions mapped to that BoM version.
To learn which Firebase library versions are mapped to a specific BoM version, check out the release notes for that BoM version. If you need to compare the library versions mapped to one BoM version compared to another BoM version, use the comparison widget below.
Learn more about Gradle's support for BoM platforms.
Here's how to use the Firebase Android BoM to declare dependencies in your
module (app-level) Gradle file (usually app/build.gradle
). When using the
BoM, you don't specify individual library versions in the dependency lines.
dependencies { // Import the BoM for the Firebase platform implementation platform('com.google.firebase:firebase-bom:33.5.1') // Declare the dependencies for the desired Firebase products without specifying versions // For example, declare the dependencies for Firebase Authentication and Cloud Firestore implementation 'com.google.firebase:firebase-auth' implementation 'com.google.firebase:firebase-firestore' }
Here are some frequently asked questions about using the Firebase Android BoM:
Here's how to override a library version designated in the BoM:
Maintain the line to import the BoM platform.
In the library's dependency line, specify the desired library version. For example, here's how to declare dependencies if you want to use v18.0.0 of App Indexing no matter what version is designated in the BoM, but you want to use the BoM's versions for Authentication and Cloud Firestore:
dependencies { // Import the BoM for the Firebase platform implementation platform('com.google.firebase:firebase-bom:33.5.1') // Declare the dependency for the App Indexing library and specify a version // This specified library version overrides the version designated in the BoM. implementation 'com.google.firebase:firebase-appindexing:18.0.0' // Declare the dependencies for the other Firebase libraries without specifying versions // These libraries will use the versions designated in the BoM. implementation 'com.google.firebase:firebase-auth' implementation 'com.google.firebase:firebase-firestore' }
No. To actually add and use Firebase libraries in your app, you must declare
each library as a separate dependency line in your module (app-level) Gradle
file (usually app/build.gradle
).
Using the BoM ensures that the versions of any Firebase libraries in your app are compatible, but the BoM doesn't actually add those Firebase libraries to your app.
Yes! When you declare your specific Firebase library dependency lines, just use the KTX library name, like so:
dependencies { // Import the BoM for the Firebase platform implementation platform('com.google.firebase:firebase-bom:33.5.1') // Declare the dependencies for the desired Firebase products, without specifying versions // For example, declare the dependencies for Firebase Authentication and Cloud Firestore implementation 'com.google.firebase:firebase-auth-ktx' implementation 'com.google.firebase:firebase-firestore-ktx' }
No. The Firebase Android BoM only manages library versions for Firebase libraries. The only exception is the inclusion of the Google Mobile Ads SDK because it's so commonly used in Firebase apps.
Even though each Firebase library is versioned independently, they are built together to ensure that the latest release of each library is compatible with the others.
By using the BoM to manage your app's Firebase library versions, you don't need to track which version of a Firebase library is compatible with another Firebase library.
Even if you only use one Firebase library in your app right now, we still recommend using the BoM because you never know when you might want to use another Firebase library!
Yes, you can still use the BoM! For Gradle 5.0 and later, BoM support is automatically enabled. However, for earlier versions of Gradle, you just need to enable the BoM feature and import the BoM a bit differently.
To your
settings.gradle
file, addenableFeaturePreview('IMPROVED_POM_SUPPORT')
.To your module (app-level) Gradle file (usually
app/build.gradle
), import the BoM like a normal library (without theplatform
modifier), like so:dependencies { // Import the Firebase BoM implementation 'com.google.firebase:firebase-bom:33.5.1' // Declare the dependencies for the desired Firebase products, without specifying versions // For example, declare the dependencies for Firebase Authentication and Cloud Firestore implementation 'com.google.firebase:firebase-auth' implementation 'com.google.firebase:firebase-firestore' }
Visit the Firebase Android SDK repo on GitHub.
Compare Firebase BoM versions
Kotlin extensions (KTX) library modules
Firebase Kotlin extensions (KTX) library modules are small companions to the main Firebase library modules, and you can use them to write beautiful and idiomatic Kotlin code.
To use a KTX library module in your app, change your dependency to include the
-ktx
suffix. Each KTX module automatically has a dependency on the main
library module, so there's no need to include both dependencies in your app.
dependencies { // Import the BoM for the Firebase platform (learn more) implementation platform('com.google.firebase:firebase-bom:33.5.1')// Declare the main module implementation 'com.google.firebase:firebase-analytics'// Declare the KTX module instead (which automatically has a dependency on the main module) implementation 'com.google.firebase:firebase-analytics-ktx' }
Each KTX module provides different syntactic extensions of the main module. For example, the Analytics KTX module makes it simpler to log events:
Before (using the main module)
val analytics = FirebaseAnalytics.getInstance(); val bundle = Bundle(); bundle.putString(FirebaseAnalytics.Param.ITEM_ID, id); bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, name); bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "image"); analytics.logEvent(FirebaseAnalytics.Event.SELECT_ITEM, bundle);
After (using the KTX module instead)
firebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_ITEM) { param(FirebaseAnalytics.Param.ITEM_ID, id) param(FirebaseAnalytics.Param.ITEM_NAME, name) param(FirebaseAnalytics.Param.CONTENT_TYPE, "image") }
All the Firebase products offer a KTX module except for Firebase ML and App Indexing.
If you haven't yet, check out the API reference docs for the KTX modules.
Feature modules and Play Feature Delivery
As of May 2021 (Firebase BoM v28.0.0), Firebase Android SDKs can be used in dynamic feature modules which are installed separately from your base application module.
To enable support for dynamic feature modules, add the following dependency
to your base module's build.gradle
file:
dependencies {
implementation 'com.google.firebase:firebase-dynamic-module-support:16.0.0-beta03'
}
Now that you've added dynamic module support, you can add Firebase SDK dependencies (with or without the Firebase BoM) to feature modules of your app and use them as you normally would.
For example, if your application uses Realtime Database to power a specific realtime
feature you could add the firebase-database
dependency to the build.gradle
of the feature module rather than the base module. This will reduce download
size for most users.
Be aware of the following caveats when using Firebase SDKs in feature modules:
Products such as Dynamic Links or Firebase In-App Messaging which rely on the Analytics
first_open
event may miss this event when used in a dynamic feature module.When using Cloud Firestore and Authentication together, you should always include them both in the same module. If this is not possible, then make sure that Authentication is loaded before Cloud Firestore; otherwise, some Cloud Firestore operations may have an incorrect authentication state.
When using
firebase-crashlytics-ndk
as a dependency of a dynamic feature module, you need to set theunstrippedNativeLibsDir
property in your app'sbuild.gradle
file, as described in the Crashlytics NDK documentation.
For more information on feature modules and Play Feature Delivery, visit Overview of Play Feature Delivery.
Google services Gradle plugin vs Google Play services vs Google Play Store
Several pieces of the Google, Firebase, and Android ecosystem have similar naming conventions. Here's a brief explanation for each:
- Google services Gradle plugin
- A Gradle plugin (
com.google.gms.google-services
) that runs at build time to ensure that your app has the right configuration to access Firebase and Google APIs - Despite its name, this plugin has no relation to Google Play services (see next entry) and has no impact on your app's capabilities at runtime.
- This plugin also processes the
google-services.json
file that you add to your app as part of setting up Firebase. Learn more about the Google services Gradle plugin. - Google Play services
- An invisible background service that runs on an Android device and provides several common Google APIs (like Google Maps and Google Sign In) to apps on the device
- By centralizing these common APIs into a single service, it reduces the size of other apps and allows a device to receive automatic security updates and feature enhancements without an OS update. Learn more about Google Play services.
- Google Play Store
- A store to download apps, movies, books, and more on an Android device
- As a developer, you manage the distribution, releases, etc. for your app via the Google Play Console. If a device has the Google Play Store, it's also running Google Play services (see previous entry). Learn more about the Google Play Store for developers.
- Google Play Games services
- A set of APIs for mobile game developers
- Learn more about Google Play Games services and how to integrate Firebase with your Google Play Games services project.
Open source resources for Firebase Android SDKs
Firebase supports open source development, and we encourage community contributions and feedback.
Firebase Android SDKs
Most Firebase Android SDKs are developed as open source libraries in our public Firebase GitHub repository. We're actively working to move the remaining privately developed Firebase libraries to our public GitHub soon!
Quickstart samples
Firebase maintains a collection of quickstart samples for most Firebase APIs on Android. Find these quickstarts in our public Firebase GitHub quickstart repository.
You can open each quickstart as an Android Studio project, then run them on a mobile device or a virtual device (AVD). Or you can use these quickstarts as example code for using Firebase SDKs.
Other topics of interest
- Dependencies of Firebase Android SDKs on Google Play services
- Link your Firebase app to Google Play
- Integrate with your Play Games services project