-
Notifications
You must be signed in to change notification settings - Fork 339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Data retrieval code won't work if the *beta* Europe server is chosen for Realtime DB #137
Comments
@adamk90 can you explain a little more about your situation? Did you create a brand new project and select the European region when making your first Realtime Database instance? Or did you add a europe instance to a new project. Sharing the contents of your |
Hi, This issue also happened to me. I created a new Firebase project and downloaded the google-services.json file following the initial instructions. After adding it to the project I created a European Realtime Database but it was impossible to read/write data from the DB. Debugging the app I noticed the instance was pointing to the US location. Re-downloading the google-services.json file fixed the issue. The new version of the file contains a key-value "firebase_url" with the specific URL of the European server. Hope this can help in some way. Thanks, |
@jjmrive thank you for sharing! It looks like what we need to do is change the codelab instructions to have you create a Realtime Database instance before you download the For my own future reference here's what my {
"project_info": {
"project_number": "54947790386",
"project_id": "overground-test",
"storage_bucket": "overground-test.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:54947790386:android:9a54efb6c1d417cb8e062b",
"android_client_info": {
"package_name": "com.google.foo"
}
},
"oauth_client": [
{
"client_id": "54947790386-tagmgkg24kah1krulstn75p18ndophdu.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyDL_JX6a367eCohpKasBaTV9HOQmqb4Rlw"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "54947790386-tagmgkg24kah1krulstn75p18ndophdu.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
} And here's what it looked like after I created RTDB in Europe: {
"project_info": {
"project_number": "54947790386",
"firebase_url": "https://overground-test-default-rtdb.europe-west1.firebasedatabase.app",
"project_id": "overground-test",
"storage_bucket": "overground-test.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:54947790386:android:9a54efb6c1d417cb8e062b",
"android_client_info": {
"package_name": "com.google.foo"
}
},
"oauth_client": [
{
"client_id": "54947790386-tagmgkg24kah1krulstn75p18ndophdu.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyDL_JX6a367eCohpKasBaTV9HOQmqb4Rlw"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "54947790386-tagmgkg24kah1krulstn75p18ndophdu.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
} |
Here's the part of the SDK where it assumes it can use the Project ID: 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);
} |
Hi,
The provided code won't work if european (Belgium) server is chosen for realtime db, because it does not sits on the default url. I don't know how to solve this properly, but a workaround is to modify the Firebase DB reference initiation like this:
mFirebaseDatabaseReference = FirebaseDatabase.getInstance("url-to-europe-db").getReference();
Maybe this should be stated in codelabs, because gave a few hours to debug :)
thanks,
adam
The text was updated successfully, but these errors were encountered: