'Android app not writing to firebase database
I know this question has been asked before, but I've tried just about every posted solution and have been unsuccessful. I set up my Firebase realtime database with the Firebase documentation and followed everything properly. I set read and write values both to true (only for testing; will change later). This is my code:
package com.example.classfinder;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// init commit
FirebaseDatabase.getInstance().getReference().child("name").push().setValue("hello, world!");
}
}
I know my Gradle files are good since I followed the documentation to the dot and did my research. When I write to the database, nothing shows up. Let me know if you need more info to answer this question. Thanks!!
EDIT 2: Resolved by turning of wifi and using mobile data instead.
Solution 1:[1]
Here is the solution, probably. Worked for me, if you used a database in a different region, you need to specify that in google-services.json
Firebase Database connection was forcefully killed by the server: Different region #flutter
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Duje1 |