I experience some errors while trying to push data into my firebase realtime database. I checked a couple of tutorials and according to all of them i am doing nothing wrong. Unfortunately I can not update the database from my android studio emulator device.
I activated debug mode and stepped through every single process and saw that my code actually works because the database responses with the child id when pushing to it.
package com.example.fbconnect;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
public class MainActivity extends AppCompatActivity {
Button btnsaves;
Member member;
DatabaseReference myRef;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnsaves=(Button)findViewById(R.id.button);
btnsaves.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
myRef = FirebaseDatabase.getInstance().getReference("Member");
String id = myRef.push().getKey();
member = new Member("MSmith", 12, id);
myRef.child(id).setValue(member);
Toast.makeText(MainActivity.this, "Success", Toast.LENGTH_SHORT).show();
}
});
}
}
When debugging to this line
String id = myRef.push().getKey();
I see, that the database answered with a code. But it will not set the new value or update the value of existing database Childs.
After activating the debug mode I recognised some rare lines in android studio that may lead to the problem:
E/FirebaseInstanceId: Topic sync or token retrieval failed on hard failure exceptions: AUTHENTICATION_FAILED. Won't retry the operation.
I am definitely sure that I did not activate any authentication in my firebase. Normally everybody should be able to read and write (I am aware of this but I am desperate to get this database connection working).
Can you please help me?
