After reading through dozens of resources and help, etc, I found that answers quickly get outdated due to Gooogle's incessant need to keep changing the methods and UI. And Google itself does a poor job of showing 1 simple method to achieve something, instead of multiple alternates, which just end up adding confusion.
Certificate is required not just for database (as the OP asked), but also for Google signin, etc.
So for all such cases here are the steps current as of Oct 2022. Note that there are 3 different keys, depending on what one wants to achieve:
A. Debug key
B. Release key
C. App signing key
- First generate A. debug key from Android Studio using various methods. 2 are listed here: https://developers.google.com/android/guides/client-auth - via keytool and via Gradle signing report. I've found that the Gradle signing report is easy to use for getting the SHA1 key.

- Add this debug key to Firebase Console when setting up the app for the 1st time. Else enter this key under existing app settings: Firebase | < project > | Project settings | Your apps | Android app | SDK setup and configuration | Add fingerprint.

Download the google services json and plug it into Android Studio. Test your app (debug version) in the emulator, and it should work fine since the debug key has been set in Firebase and in the google services json.
Now for production app, ie release version - use B or C.
- B. Release key: Use the keytool command to generate the SHA1 key from the release / upload keystore in Android Studio. Add the key to Firebase Console under the same app using "Add fingerprint". Download the google services json again and plug it into Android Studio. Generate a release APK and test that on a local device etc - this should also work fine since the release key has been set in Firebase and in the google services json.
Finding the keytool path itself leads down another rabbit hole. One might see these resources: What’s keytool, why can’t it be found, and why does Firebase even want a “SHA-1”? and 'keytool' is not recognized as an internal or external command.
- C. App signing key: Create (or locate) your publisher account on Google Play Console. Create (or locate) the app and set it up for Google Play signing, which is anyway the default since Aug 2021. Under Release | Setup | App integrity | Play App Signing | App signing key certificate - copy the "SHA-1 certificate fingerprint".

Add the key to Firebase Console under the same app using "Add fingerprint". Download the google services json again and plug it into Android Studio. Generate an App bundle. If this is the 1st time the app will be published on Play store, then I suggest releasing under "Internal testing" track first to test it live across multiple devices.