Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase android not working outside testing devices

I have this new app and have added Firebase Firestore and Cloud Firestore. User can sign up with email and pass, and log in successfully. Then user can enter birthday in myprofile and update the info.

The problem is this, it works fine in Emulator. It works fine in testing device. But when I release the app and download it with another android phone, it stops working. I have picture of database for 2 different situations.

First one:

1

I used real device and downloaded app from store to sign up a user: My user1

Second one:

2

is a sign up from Emulator device same version. My user2

Problem when sign up is from a downloaded app:

a "aJ3vfJUiNFQXbQ394SHbGUlV7eu2"
b "My name"
c "[email protected]"
d ""
e "" 

Correct one from Emulator:

birthday ""
email "[email protected]"
id "ldYDz3GAo6YOUNiIGZyMg3lwVXH3"
image ""
userName "My name 2" 
like image 895
Javad Ghahri Avatar asked Aug 29 '26 08:08

Javad Ghahri


1 Answers

When you make release builds for android typically proguard is used to obfuscate your code - this means renaming all your classes to things like A, B, C and all your variables to things like a, b, c, d, e. It looks like thats what could be happening here. You are uploading a data object like this:

data class PersonInfo(
    var birthday: String = "",
    var email: String = "",
    var id: String = "",
    var image: String = "",
    var userName: String = "" 
)

And proguard is obfuscating it to be something like:

data class A(
    var a: String = "",
    var b: String = "",
    var c: String = "",
    var d: String = "",
    var e: String = "" 
)

To tell proguard to not obfuscate a specific class you can add a rule in proguard-rules.pro (which should be located in you /app/ folder) like this:

-keep class your.package.name.ClassName

This should preserve the original class and fix your issue (assuming the issue was from proguard as I suspect)

like image 114
Quinn Avatar answered Aug 31 '26 20:08

Quinn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!