Live App is unable to write data into Firebase database Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Live App is unable to write data into Firebase database without wasting too much if your time.

The question is published on by Tutorial Guruji team.

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.

Answer

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.

We are here to answer your question about Live App is unable to write data into Firebase database - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji