Flutter Firebase App Setup

The following guide is designed to get you up and running with Flutter and Firebase on both iOS and Android.

Refer to the [official FlutterFire setup instructions](https://firebase.google.com/docs/flutter/setup).

Create your Flutter App

Create your app and open it in your IDE (VS Code).

command line
flutter create my_app
code my_app

Install Dependencies

Below are the dependencies you will need for most FlutterFire apps, assuming you are using Firestore and Google SignIn. RxDart is optional, but highly recommended for working with realtime data sources in Firebase.

file_type_light_yaml pubspec.yaml
    sdk: flutter

  firebase_core: ^0.4.0
  firebase_analytics: ^1.0.4

  cloud_firestore: ^0.8.2+3

  firebase_auth:  ^0.6.6
  google_sign_in: ^3.2.4

  rxdart: 0.22.0 # optional

Note: You can find the latest FlutterFire package versions.

Android Setup

Project ID and SHA1 Certificate

First, you need to decide on a project ID for your app using the following pattern <com>.<brand>.<app>. For example, the app for Fireship would be io.fireship.lessonapp.

Next, generate an SHA1 certificate to allow Firebase to provision an OAuth2 client and API key when using Google Sign-in and/or dynamic links.

Mac/Linux users can use the command below. Windows users refer the the official instructions.

command line
keytool -exportcert -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore

# password: android

obtain the sha1 certificate for android firebase

Download and save the google-services.json

Next, go to the Firebase Console and register your app by clicking Add Firebase to your app Android. Enter your project ID and SHA1 certificate from the previous step.

Download the google-services.json file to the android/app directory. At this point, you can skip all remaining steps in the Firebase console (Flutter does this stuff automatically).

google services location in flutter project

Update the build.gradle files

Now we need to register our Google services in the Gradle build files.

file_type_gradle android/build.gradle
buildscript {
   dependencies {
       // ...
       classpath 'com.google.gms:google-services:3.2.1'   // <-- here

Next, update your project ID and register the Google services plugin at the bottom of gradle build file in the app directory.

file_type_gradle android/app/build.gradle
    defaultConfig {
        applicationId "io.fireship.lessonapp" // <-- update this line
        minSdkVersion 21 // <-- you might also need to change this to 21
        // ...

// ... bottom of file
apply plugin: 'com.google.gms.google-services' // <-- add

That’s it. Try executing flutter run with an Android device emulated or plugged-in to verify the setup worked.

iOS Setup

The iOS setup is less tedious and can be completed in one step.

Register and Download the GoogleService-Info.plist

Click add your app to iOS then download the GoogleService-Info.plist file into the ios/Runner/Runner directory from XCode.

add ios to your flutterfire project


At this point, you should be able to serve the app by running flutter run.

  • Run flutter doctor and resolve any detected issues
  • Open the app in Android Studio or XCode and build it. Inspect the logs.
  • If your app crashes at startup without logs it may be because you changed the id in the AndroidManifest.xml file. Look at this Github issue

Q&A Chat