Open
Description
[READ] Step 1: Are you in the right place?
Yep
[REQUIRED] Step 2: Describe your environment
- Android Studio version: all
- Firebase Component: Database
- Component version: 19.6.0
[REQUIRED] Step 3: Describe the problem
Steps to reproduce:
- Create a new project
- Add an Android app
- Download
google-services.json
- Create the default RTDB instance on the project, choose Europe location
Because (3) precedes (4) the json
file will not contain the firebase_url
key and therefore the RTDB SDK will try and make up the database URL:
public static FirebaseDatabase getInstance(@NonNull FirebaseApp app) {
String databaseUrl = app.getOptions().getDatabaseUrl();
if (databaseUrl == null) {
if (app.getOptions().getProjectId() == null) {
throw new DatabaseException(
"Failed to get FirebaseDatabase instance: Can't determine Firebase Database URL. "
+ "Be sure to include a Project ID in your configuration.");
}
databaseUrl = "https://" + app.getOptions().getProjectId() + "-default-rtdb.firebaseio.com";
}
return getInstance(app, databaseUrl);
}
However it doesn't print any warning when it does this, and for anyone who chooses Europe this is the wrong URL. See developer pain here:
firebase/codelab-friendlychat-android#137
Relevant Code:
See above