0

I have a problem. I've coded app in android studio. After publishing app to play store, firebase database doesn't work at all. I added SHA1 key to firebase console project settings, what can be wrong?

Firebase console screenshot

Any help appreciated.

I took SHA1 key from here:

SHA1 key screenshot

Jon Saw
  • 7,599
  • 6
  • 48
  • 57

5 Answers5

1

there different SHA1 keys for debug and release version you are most likely using debug SHA1 key

generate relase SHA1 key using below code and add it to console firebase will work

keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

tutorial here

akshay_shahane
  • 4,423
  • 2
  • 17
  • 30
1

I found solution, it's very weird though. The variables in class where i stored all the data enter image description here were not private. After i add private modifier to all variables problem was solved enter image description here

0

You would be aware of that release APK and debug APK has different SHA1 and different API keys for google services. So you need to add both of them on Firebase inside your Project Setting. After doing this you need to redownload the google-services.json file and put it in your project at the right palce. Create a fresh release build with your keystore and publish you app on Google Play store.

Hope it helps.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
  • hi Alex, could you please help this one? it seems similar https://stackoverflow.com/questions/72445017/firebase-cloud-messaging-is-not-working-after-publishing-android-app-in-play-sto – Alexa289 May 31 '22 at 09:15
  • @Alexa289 I'll take a look and if I'll know the answer, I'll write to you. – Alex Mamo May 31 '22 at 09:25
0

You will need to register the SHA-1 or SHA-256 keys of your RELEASE-APK which is different from the DEBUG-APK on your firebase project settings using => add finger print option.

DEBUG APK & HOW TO GENERATE DEBUG - SHA FINGERPRINT KEYS

  • Debug keystore is generated by default when you either run your app using the RUN button in Android Studio or when you build a debug apk.
  • Debug-keystore uses android both as the keystore name and the alias name by default in order to generate the SHA keys.
  • And the location of the debug-keystore is C:\Users\USERNAME\ .android by default.
  • So, you simply need open CMD and point it to C:\Program Files\Java\bin directory and use this command to generate the debug SHA fingerprint ( if you want to generate the keys to a txt file i.e. in D: directory and in a text file called sha.txt add this to the end of the command below: > D:\sha.txt: )

keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android


RELEASE APK & HOW TO GENERATE RELEASE-SHA FINGERPRINT KEYS

  • Release keystore is generated when you generate a release apk using Build => Generate signed Apk/Bundle option in Android Studio.
  • When you do so for the first time you are asked to create a new keystore, where you specify many details most notably: Keystore Path & Name, Password, Alias and Password (for key).
  • From the above mentioned parameters we will need Keystore Path & Name and Alias for the command, plus the keystore password which is asked for, after the command is executed.
  • Now execute the following command keeping the above parameters in view.
  • ( if you want to generate the keys to a txt file i.e. in D: directory and in a text file called sha.txt add this to the end of the command below: > D:\sha.txt: )
keytool -list -v -keystore <keystore_path\your_keystore_name> -alias <your_alias_name>
Sajid2405
  • 308
  • 6
  • 14
0

For those who still facing similar problem.

Things to consider as per firebase checklist

  1. Add your app release SHA1 fingerprint to firebase project settings for Authentication
  2. Configure your pro guard rules when using Firebase Realtime Database in your app along with ProGuard, you need to consider how your model objects will be serialized and deserialized after obfuscation. If you use DataSnapshot.getValue(Class) or DatabaseReference.setValue(Object) to read and write data, you will need to add rules to the proguard-rules.pro file:

Add this global rule

-keepattributes Signature

# This rule will properly ProGuard all the model classes in
# the package com.yourcompany.models. Modify to fit the structure
# of your app.
-keepclassmembers class com.yourcompany.models.** {
  *;
}
Ally
  • 783
  • 6
  • 14