firebase / firebase/firebase-android-sdk
Database SDK should warn when it builds databaseUrl from projectId
- Dominant language
- Java
- Stars
- 2.6k
- Forks
- 710
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 34
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:
1. Create a new project
2. Add an Android app
3. Download `google-services.json`
4. 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:
```java
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:
https://github.com/firebase/codelab-friendlychat-android/issues/137
#### Relevant Code:
See above
Contributor guide
Assessment
This issue has not been assessed yet.