SHA certificate firebase Debug/Release

Here are the answer to your questions.

  1. It will work only if you still have the debug SHA certificate fingerprint for debug mode. Otherwise, it won't work.
  2. Yes, you should put in your Firebase Console, both debug and release SHA certificate fingerprints.
  3. Yes indeed, if you put the debug and release SHA certificate fingerprint in the Firebase Console and if you download the google-services.json file again and put it in the right place in your project, your database connection will still work either on release and debug mode.

You have to create two separate projects for Debug and Release in firebase console.

  • Put the respective SHA key in those project.
  • You have two different google-services.json file.

Now you have to create two bulidType in the app build.gradle file. Ex.

buildType{
    release{
   //define your keys here 
    }
    
    debug{
   //define your keys here 
   
    }

}

In projects src create two folders called debug and release

project-->src-->create folder debug and release 

put your google-services.json file in the respective folder

Gradle will automatically pick your account based on build type.


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 Dec 2021:

  1. First generate 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.

enter image description here

  1. 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.

enter image description here

  1. Download the google services json and plug it into Android Studio. Test your app (debug verion) in the emulator, and it should work fine since the debug key has been set in Firebase and in the google services json.

  2. Now for production app, ie release version - 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".

enter image description here

  1. 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. Test your app debug version in the emulator, and it should continue working fine.

  2. Generate a release APK and test that on a local device etc - this should also work fine. 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.