问题
I am building an app with Firebase Authentication and Realtime Database. Before yesterday, it was working cool in my device while testing. But I am not able to even login with Firebase now, but the app is working on other devices of my friends.
What is the actual issue here ? Is there any limitation for testing app your own real device? Is some kind of limitation exceeded ?
I tried uninstalling the app and reinstalling, removing user account from firebase database. But still no work.
Thanks!!
回答1:
I faced the same issue and found the solution.
The Google Sign in works fine on emulators or on connected test devices but not on actual devices that downloads the your firebase app from google play store. This is because the apk file generated by your android studio is signed by default debug certificate fingerprint where as the application you publish on google play store is signed by different certificate finger print.
Both the certificate finger print should be whitelisted in firebase console otherwise the google sign in will not authenticate the user.
So to resolve this issue follow two steps.
Generate the release certificate fingerprint with following command on MAC
MAC: keytool -exportcert -list -v
\
-aliasyour-key-name
-keystorepath-to-production-keystore
you will get output like following :
keytool -exportcert -list -v \ -alias aliasName -keystore /pathToKeystore/keyStore.jks Enter keystore password: Creation date: 27 May, 2017 Entry type: PrivateKeyEntry Certificate chain length: 1 Certificate fingerprints: MD5: 11:D0:F1:F6:26:F3:44:77:88 SHA1: D6:44:55:66:77:88:99:55:HH:AC:DB:17:8A
Where SHA1: is your fingerprint key, copy it.
For more info on how to generate fingerprint on MAC/WINDOWS visit https://developers.google.com/android/guides/client-auth
- Paste above SHA1 key to your firebase "Project Settings" and save. Google sign in should work fine now.
To read more on how this works visit https://developer.android.com/studio/publish/app-signing.html
来源:https://stackoverflow.com/questions/38194637/firebase-for-android-not-working-in-my-test-device-suddenly