The project_info object contains general information about your The google-services.json file has the following basic structure: When product flavors are in use these more complicated directory structures are You to maintain a separate Firebase project for your production APKs. Note: Providing a google-services.json file in the release directory allows All of the following directory structures are valid: Of version 2.2.0 the plugin supports build type and product flavor The google-services.json file is generally placed in theĪpp/ directory (at the root of the Android Studio app module). You can see the result of this step by running Plugin in your app/adle file, like so:Īpply plugin: '-services' This step requires that you apply the Google Services Gradle See Adding the JSON File more information.Īdd dependencies for basic libraries required for the services you haveĮnabled. Resources that can be used in your application'sĬode. Process the google-services.json file and produce Android.The google-services plugin has two main functions: ConclusionĪs we have seen, we can use the new FlutterFire CLI to configure our Firebase project with just one command.Īnd if we want to add flavors to the mix, Very Good CLI makes our life easier.As part of enabling Google APIs or Firebase services in your AndroidĪpplication you may have to add the google-services plugin to yourĬlasspath ':google-services:4.3.15' In particular, see this comment from this open issue in the Flutterfire client. Sweet, isn't it? □ Note about using Firebase Analytics & CrashlyticsĬertain Firebase services still require some platform-specific configuration to work correctly. main_development.dart import 'package:firebase_core/firebase_core.dart' import 'package:flutter/material.dart' import 'package:my_test_app_flavors/app/view/app.dart' import 'package:my_test_app_flavors/firebase_options_dev.dart' Future main () async Īnd once this is done, we can choose a flavor and run the app on iOS, Android, or web: VS Code launch flavors For consistency, we could name the Firebase projects like so:Īnd then, we can use the FlutterFire CLI generate the correct Dart initialization file for each Flutter flavor, with this command: How to add Firebase to a Flutter app with FlutterFire CLIīut this time, we have to create one Firebase project for each Flutter flavor.Well, we can use the FlutterFire CLI tool to generate correct Firebase configuration for our project, as I have explained in my previous article: Very Good CLI helps us with the Flutter side of things. □ Setting up multiple Firebase environments dartĪlternatively, we can choose the flavor directly from VSCode, as Very Good CLI has already generated multiple launch configurations for us: VS Code launch flavorsīut the best part is that the Xcode and Android projects are already configured to run with multiple flavors, meaning that we don't have to mess about with Xcode schemes or gradle files. dart # Run production flutter run - flavor production - target lib / main_production. dart # Run staging flutter run - flavor staging - target lib / main_staging. # Run development flutter run - flavor development - target lib / main_development.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |