Add Firebase to Flutter on Windows

Aryan Vij
2 min readMay 17, 2022

--

One thing I despise the most is having to dig around on github and StackOverflow to search for answers to constant errors when setting up something such as Firebase. Why would it not work if there is already a tutorial?? I wish I knew..

Here I will go through step by step on how to add Firebase to your Flutter project on Windows.

Before you can start adding Firebase to Flutter, you need to ensure that you have a flutter project already set up. For that, you can visit this.

Step 1: Install Firebase CLI

  • Firstly, we will have to install Node.js. Visit this website and download the LTS version. Follow the installation process and don't make any changes. Ensure that nodejs folder is installed in this directory (C:\Program Files\nodejs).
  • After installation, we will have to add a few things to our Path. Go to Environment Variables and add these two directories to your Path.
  1. C:\Program Files\nodejs
  2. C:\Users\{Your_Username}\AppData\Roaming\npm
  • Next, Install the Firebase CLI via npm by running the following command:
     > npm install -g firebase-tools

This command should enable the globally available firebase command.

If it doesn’t work — try to go to :

C:\Users\{Your_Username}\AppData\Roaming\npm

and ensure that the firebase.cmd is these. If not, retry the previous command by running Command Prompt as Administrator.

  • Log into Firebase using google account. Run this command:
> firebase login
  • Install FlutterFire CLI:
dart pub global activate flutterfire_cli

Step 2: Configure your apps to use Firebase

For the remaining steps, you may continue following google’s tutorial.

If you face errors when running flutterfire, ensure that the directory:

C:\Users\{Your_Username}\AppData\Local\Pub\Cache\bin

is added to your Path.

The main issues I personally faced was that several things had to be added to path manually. After adding directories to your Path environment if you realise the commands still don’t run, restart your terminal or VSCode (if you are using the terminal on that).

Hope this was helpful!

Key things to setup Firebase for android app

Remember to add SHA1 and SHA256 keys in firebase.
Go inside your application path.

Then cd \android

Then run .\gradlew signingReport

This will give the SHA1 and SHA256 keys.

Also make sure that you are running your application on a AVM (virtual device) that has playstore enabled. Take note of this when creating your VM in android studio. This is needed for Google Authentication.

--

--

Aryan Vij
Aryan Vij

Written by Aryan Vij

Everything startups and building...

Responses (2)