Firebase Realtime Database connection killed: Different Region
Solution 1:
It looks like the google-services.json
file that you use doesn't contain the Realtime Database URL, probably because you downloaded it before the database was created. In such cases the SDK assumes that the database is in the US (the original region), and you get an error that there's a mismatch.
There are two possible solutions:
- Download an updated
google-services.json
from the Firebase console, and add that to your Android app. - Specify the database URL in your code instead, like this:
FirebaseDatabase.getInstance("https://vax-in-60807-default-rtdb.asia-southeast1.firebasedatabase.app")...
Both have the same result, so pick whichever one seems easiest to you.
Solution 2:
It cat still not work after the accepted answer (as in my case). If so, try:
- Clean Project
- Rebuild Project
- Invalidate Caches & Restarte
and run it again.
Solution 3:
Passing the URL into the getInstance
method should fix the issue:
DatabaseReference database = FirebaseDatabase.getInstance(“https://vax-in-60807-default-rtdb.asia-southeast1.firebasedatabase.app”).getReference();