Is it possible to use two google-services.json files in an Android project? I know that there is a possibility to use multiple google-services.json files for multiple flavors, but is it possible to somehow merge two files with different project_info and use them simultaneously for a project?
Below is the example of two files which I want to use in one project and one flavor (one for Analytics and another one for Ads).
First google-services.json
{
"project_info": {
"project_number": "XXXXXXXXXXXX",
"project_id": "project-one"
},
"client": [
(...)
],
"configuration_version": "1"
}
Second google-services.json
{
"project_info": {
"project_number": "YYYYYYYYYYYY",
"firebase_url": "https://project-two.firebaseio.com",
"project_id": "project-two",
"storage_bucket": "project-two.appspot.com"
},
"client": [
(...)
],
"configuration_version": "1"
}
Also I have the same question regarding GoogleService-Info.plist files for an iOS project.
There is no way to use two google-services. json files in a single Android app. The file name is the same between them and they need to be in the same location. So one will overwrite the other in that case.
Add your GoogleService-Info. plist file is something you can download from your Firebase's project settings. Drag your GoogleService-Info. plist to the Runner folder.
Yes, It is possible to use more than one FirebaseApp. But you have to use the FirebaseApp configuration by code for the second configuration. google-services.json & GoogleService-Info.plist use to crate default FirebaseApp. For the second configuration use class func configure(name: String, options: FIROptions)(Swift) & public static FirebaseApp initializeApp (Context context, FirebaseOptions options, String name)(Android).
iOS demo code:-
let options = FirebaseOptions(googleAppID: "1:XXXXXXXXXXXXXX:ios:XXXXXXXXXXXXXXXXXX", gcmSenderID: "XXXXXXXXXXXXX")
options.apiKey = "XXXXXXXXXXXXXXXXXXXXXXXXX"
options.projectID = "App-XXXXX"
FirebaseApp.configure(name: "AppAnalytics", options: options)
Add FirebaseOptions data/values from google-services.json & GoogleService-Info.plist files.
Please refer to the below link for more details:
iOS: https://firebase.google.com/docs/reference/swift/firebasecore/api/reference/Classes/FirebaseApp https://firebase.google.com/docs/reference/swift/firebasecore/api/reference/Classes/FirebaseOptions
Android: https://firebase.google.com/docs/reference/android/com/google/firebase/FirebaseApp#initializeApp(android.content.Context,%20com.google.firebase.FirebaseOptions,%20java.lang.String)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With