Firebase database doesnt work after publishing app to play store

心不动则不痛 提交于 2020-12-07 15:55:31

问题


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


回答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




回答2:


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




回答3:


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.




回答4:


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>



回答5:


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.** {
  *;
}


来源:https://stackoverflow.com/questions/45721120/firebase-database-doesnt-work-after-publishing-app-to-play-store

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!