I created multiple firebase project in one app to separate the development and production environment, so now I have 2 different generated google-services.json. I want to be able to run/build using a specific environment by specifying buildTypes as mentioned in this article on step 3. So my app folder below will follow this article.
NOTE: Why don't I use flavor? Because I already use command arguments (--dart-define).
This is snippet of my buildTypes:
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
signingConfig signingConfigs.release
}
}
I delete apply plugin: 'com.google.gms.google-services'
as stated in this documentation.
This is my app folder:
I run my project using debug build (flutter run --debug
) but I got this error:
Unhandled Exception: [core/not-initialized] Firebase has not been correctly initialized. Have you added the "google-services.json" file to the project?
I checked this documentation page on firebase flutter site, it mentioned:
await Firebase.initializeApp(
name: 'SecondaryApp',
options: const FirebaseOptions(
appId: 'my_appId',
apiKey: 'my_apiKey',
messagingSenderId: 'my_messagingSenderId',
projectId: 'my_projectId'
)
);
is my choice only passing all required data via command arguments using this approach? I'm afraid it has limitations as I use other Firebase services. Any insights would be nice, thanks.