Firebase Auth | The Debug vs Release Signature Problem

tl;dr
1. Update Firebase console with SHA1 of your release keystore.
2. Re-download google-config.json file.
3. Place your release keystore in the same folder as your gradle file and update gradle with the code below.
4. Tadaa!

Authenticating a user can be frustratingly tricky at times. I use Firebase all the time to do all server related tasks - I used to create my own Python Flask server prior to this. You literally have to write no server side code, and it's all for free.

All steps at the Firebase Auth documentation are straightforward, except for the part that requires you to add the google-config.json with correctly configured SHA1 key. I got stuck at this one point, and I'm certain most developers will at the same place. It took me hours to do this the right way.

Here's what you do :
Firebase Auth requires SHA1 fingerprint of your release keystore.
Run the keytool command given in the docs.

keytool -exportcert -list -v -alias alias_name -keystore path/to/keystore/location

You are asked to enter your SHA1 fingerprint in the Firebase console - copy it from the output from the above command. Now re-download your google-config.json file and replace the old one. Remember to do this. I wasted an hour before realizing I forgot to replace my old config file.

Now, here's the tricky part. While debugging by hitting the play button in Studio, the app uses debug.keystore, located in the hidden .android/ folder of your home directory. So even though your Firebase console is configured properly, your app isn't being signed with the correct keystore! So, when you try to check if your code is correct, it won't authenticate irrespective, because the two SHA1's don't match.
You can check the SHA1 fingerprint your app is signed with using this Youtube video.
Check the SHA1 fingerprint and the location of the keystore. It's certainly signing your app with the debug keystore, which doesn't match the one you configured in the Firebase console!

So here's what you do. Change the signingConfigs in the gradle file. This will make sure your app is signed with release keystore even while debugging. (View SO answer here.)

android {
    ...
    signingConfigs {
        debug {
            storeFile file("release.keystore")
            storePassword "******"
            keyAlias "******"
            keyPassword "******"
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }
}

Place your keystore in the folder your google-services.json is located. If your app is open sourced/on github, you definitely don't want your password out to the world to use. Check out the other answers in the SO answer above - make another config file that stores your credentials and is referenced by your build gradle, and add this config file to the list of .gitignore.

Remember to remove the above lines from your gradle file, as it contains your precious keystore credentials. Also remove your keystore file from your app's directory while releasing it to the play store. Don't forget!
My Github issue on Firebase's Friendly chat demonstration app. These guys are great. :)

Hope this helps!

Comments

  1. This comment has been removed by the author.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Thanks a lot. You helped me in tons.

    ReplyDelete
  4. "signingConfig signingConfigs.release" replace release with debug as you have debug name container in signingConfigs part.

    ReplyDelete
  5. Thank you very much for this post. Your posts are the useful thing which we all are looking for that kind information.
    digital marketing services in india

    ReplyDelete

  6. Health Is God aims to deliver the best possible health reviews of the supplement collections and other wellness production that range from skincare to brain, muscle, male enhancement and brain health conditions. You, the user are of utmost importance to us, and we are committed to being the portal that sustains your healthy lifestyle. Visit for more- Health is God

    ReplyDelete
  7. I think this is a real great article post.Really looking forward to read more. Visit at
    Crazy Video Hub

    ReplyDelete
  8. Fantastic article to go through,I would appreciate the writer's mind and the skills he has presented this great article to get its look in better style.
    Fmovies

    ReplyDelete
  9. It is a great job, I like your posts and wish you all the best. and I hope you continue this job well.
    NutraT line

    ReplyDelete
  10. "I like this post,And I guess that they having fun to read this post,they shall take a good site to make a information,thanks for sharing it to me.
    Read more here:
    kim kardashian sex tape
    porn sex video hd
    mia khalifa sex video
    sunny leone sexy movie"

    ReplyDelete
  11. A million of thanks for publish this helpful content!!! I was turning crazy with this problem in my app...

    ReplyDelete
  12. Hello, I am thomus jons thank you for this informative post. That is a great job. Wish you more success.Thank you so much and for you all the best. Takes Down
    123movies

    ReplyDelete

Post a Comment

Popular posts from this blog

One Year at Tonbo Imaging

I'm not an Android Dev Anymore