Search code examples
androidfirebasegoogle-play-console

Live App is unable to write data into Firebase database


I just got my game go live on google play store but when my friend installed it from play store, the app stops when he submits his score. So I tried manually inserting a score into the firebase database and checked the score page of my game. It displays the score so that confirms my game having access and is able to read from the firebase db. However, it crashes when my friend submits his score (writing the score into the db).

Is it because there's an issue with writing into firebase db from a signed bundle? Because local testing and unsigned bundle both work.

This is how I insert into firebase db:

databaseReference.push().setValue(new UserRecord(name, score));

This is what my object looks like:

import com.google.firebase.database.IgnoreExtraProperties;`

@IgnoreExtraProperties
public class UserRecord {

    public String name;
    public int score;

    public UserRecord() {
        // Default constructor required for calls to DataSnapshot.getValue(User.class)
    }

    public UserRecord(String name, int score) {

        this.name= name;
        this.score= score;
    }
}

Any idea? Thank you.


Solution

  • Do you have firebase crashlytics on the app? If so check on firebase console what the error could be. If the app were not writing to the database only I would say it is probably the signing keys, but since it crashes, I would suggest you look at the pojo classes, if you use any. If you use it to update to firebase and you have minifyEnabled true, you have to add @Keep to the class so, the method firebase needs are not deleted. But then again, without seeing the actual code, we can't really help much.