-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Summary:
Currently, OneBusAway Android has a file /onebusaway-android/google-services.json that the ES SDK uses, presumably for some type of Firebase service.
I'm in the process of adding another Firebase service to OBA Android. As part of that I'd need to add a google-services.json in the /onebusaway-android directory for this Firebase service (Cloud Firestore), but I can't because the one for the ES SDK already exists.
From this Firebase link, it looks like you can configure multiple Firebase projects within the same app - https://firebase.google.com/docs/configure/#use_multiple_projects_in_your_application
I'm proposing that the ES SDK /google-services.json be removed from the OBA app and replaced by passing credentials to the ES SDK via the /onebusaway-android/src/main/res/raw/embedded_social_config file, and then the ES SDK can manually init Firebase within the SDK using these credentials. From the above link, the manual init would look something like:
// Manually configure Firebase Options
FirebaseOptions options = new FirebaseOptions.Builder()
.setApplicationId("1:27992087142:android:ce3b6448250083d1") // Required for Analytics.
.setApiKey("AIzaSyADUe90ULnQDuGShD9W23RDP0xmeDc6Mvw") // Required for Auth.
.setDatabaseUrl("https://myproject.firebaseio.com") // Required for RTDB.
.build();
// Initialize with secondary app.
FirebaseApp.initializeApp(this /* Context */, options, "secondary");
// Retrieve secondary app.
FirebaseApp secondary = FirebaseApp.getInstance("secondary");
// Get the database for the other app.
FirebaseDatabase secondaryDatabase = FirebaseDatabase.getInstance(secondary);
This design makes sense to me for three reasons:
- It puts all ES SDK config in the same file (
embedded_social_config) - It seems a little strange to have the default
google-services.jsonin an app belong to an SDK - If an app wants to adopt the ES SDK, and they already use Firebase, with the current ES SDK design they'd need to move their default Firebase config to a secondary manual config. It's less friction to adopt if the dev doesn't need to change their Firebase config at all to adopt ES SDK.
Steps to reproduce:
Try to configure the OneBusAway Android app with a new Firebase project:
- Go to Firebase web console
- Create new project
- When a
google-services.jsonfile is generated by the Firebase console, follow the instructions to add it to the OBA Android project at/onebusaway-android/google-services.json
Expected behavior:
ES SDK shouldn't block me from adding a Firebase project to the OBA Android app - ideally there shouldn't be an existing /onebusaway-android/google-services.json file that's not owned by the OBA app.
Observed behavior:
/onebusaway-android/google-services.json already exists in OBA Android from the ES SDK configuration.
A workaround would be to set up a secondary OBA Firebase project with a manual configuration for the OBA Android app as discussed at:
https://firebase.google.com/docs/configure/#use_multiple_projects_in_your_application
Device, Android, and Embedded Social SDK version:
// Embedded Social SDK version
implementation('com.acrowntest.test:sdk:0.7.1:release@aar') {
transitive = true;
}
App = OBA Android with master branch at OneBusAway/onebusaway-android@8eeda85