Update: Google changed behaviour of uploading APK, check answer below!
Release APK and debug APK has different SHA1 and different API keys for google services. Both of them must be added in Firebase Console -> Project settings. Then download google-services.json from here, add it to project and recompile with release keystore using option "Build signed APK". That should work
When you upload an apk to the play store then play store creates a new SHA1 key called "App signing certificate". You get that SHA1 and save in your console or firebase account (as you need).
New SHA1 will be found at Released Management->App Sigining on your play console.
The problem was created when Google Play App Signing was enabled for my app. Google Play App Signing changes the SHA-1 certificate fingerprint (from what is in my keystore) to their own SHA-1 certificate fingerprint.
Click your application >> Settings [Gearbox Icon to the right of project overview] (top of the screen) >> Project Settings >> General [Tab] >> Add Fingerprint
There are three types of SHA1 is required for an app lifecycle when you are using firebase
-debug SHA1
-release SHA1
-signing SHA1 (it getting from play store)
You need to add signing SHA1 to firebase after publish your application here i am attaching two screen shots please have a look . The red marked certificates is must be required, so copy it from playstore and paste it on firbase
1- Upload certificate ( your app certificate provided when generating signed apk)
2- App signing certificate ( because you enabled Google Play App Signing, so they provided new certificate details for your published apk)
you need to change uploaded certificate details with new details
provided by google play where ever you used it before. such as
Integrating google sign in (change SHA-1 of OAuth client),
facebook login (change key Hash (generate key hash using SHA-1
use this link or copy the key hash provided by facebook login
error screen), firebase etc.
If you enabled "Google Play App Signing" when publishing your app, you are now probably dealing with two fingerprints:
The one coming from your local keystore (keytool -exportcert -keystore path-to-production-keystore -list -v), known as the "upload cert".
The new one generated by Google when you enabled Signing (the "signing certificate").
The conflict with this situation, is that you may end up with two OAuth 2.0 client IDs:
The one that you created before publishing your app (and before enabling google signing), which is indeed the "right" one.
A NEW one created by Google when you enabled Google Signing.
You can verify this fact from: Google Play Console -> Games Services -> Select your App -> Games Details -> API Console project -> Credentials -> OAuth 2.0 client IDs
SOLUTION
In order for Google Sign-in (and all related Games Services features) to work, I had to correct the fingerprint for my pre-existing OAuth2 Client ID (the one that I created before publishing my app).
Look for the "right" OAuth 2.0 client ID: Google Play Console -> Games Services -> Select your App -> Linked Apps --> Select your App --> Take note of the "OAuth2 Client ID" at the bottom.
Look for the "Signing" certificate: Google Play Console -> Games Services -> Select your App -> Game Details -> API Console project -> Credentials -> OAuth 2.0 client IDs --> "Android client for XXXXXX (auto created by Google Service)" --> Take note of the value (xx:xx:xx:etc....) Comment: In order to reuse this value in my other OAuth 2.0 client ID, I had to replace it with some dummy number. Otherwise, you will get error: "Certificate already used in some other project".
Go to your pre-existing OAuth2 Client ID: Google Play Console -> Games Services -> Select your App -> Games Details -> API Console project -> Credentials -> OAuth 2.0 client IDs --> Select "OAuth 2.0 client ID" from step 1. Update certificate value with the one from step 2.
This solved my issue. Multiplayer is working perfectly in my app (Match4App).
In case of anyone facing this issue after Aug 2020. New SHA1 can be found at Setup->App Signing on your play console.
Everything else is the same as @PrinkalKumar as answered.
If someone is not able to solve this issue then just open Setup > app integrity
in the console and then copy the SHA1 and paste in your firebase console.
All answers specify either an outdated version of the Play console, or don't specify how to do it in the Firebase console.
So here goes my answer :
Get your SHA in your Google console by navigating to Release > Setup > App integrity in the menu, then clicking "App signing" tab. Copy the SHA-1.
In your Firebase console, go to Project settings > General tab. At the very bottom of the page, click "Add fingerprint". Paste the previously copied SHA-1 and save.