Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
740 views
in Technique[技术] by (71.8m points)

android - Firebase Database Permission denied with read/write permissions set to true

I'm having trouble writing to my Firebase database in my simple Android app. I've set my database rules to be public:

{
  "rules": {
    ".read": true,
    ".write": true
  }
}

Created a simple class Message:

import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;

public class Message {
    FirebaseDatabase database = FirebaseDatabase.getInstance();
    DatabaseReference dbRef = database.getReference();
    public String sender;
    public String message;

    public Message(){}

    public Message(String sender, String message) {
        this.sender = sender;
        this.message = message;
    }
}

And set a button to perform the onClick method writeNewMessage with these being the significant lines of code:

int counter = 0;

public void writeNewMessage(View view) {

        counter += 1;
        Message messageToWrite = new Message("John", "Simple message: " + counter);
        String messageId = String.valueOf(counter);

        dbRef.child("users").child(messageId).setValue(messageToWrite);
    }

When running, I receive the error:

W/RepoOperation: setValue at /users/1 failed: DatabaseError: Permission denied

I know this question seems simple and likely to have been repeated, but I have yet to find any that asks this problem without having their error be involved in authentication or some other component. The simplicity of the problem is what confuses me the most.

EDIT: I've also found this error as well:

Failed to load module descriptor class: Didn't find class "com.google.android.gms.dynamite.descriptors.com.google.firebase.auth.ModuleDescriptor"
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...