Complete guide to Integrate Flutter with Firebase (for Android)

Prathyusha
4 min readMay 8, 2021

First, Create a Flutter Application on your local machine.

Creating Flutter Application on your Local Machine.
Successful Creation of Application.

Next, Run flutter doctor on your command line.

This shows the status of your app and guides you through the local development environment for Android and iOS.

After Running Flutter Doctor.

Doctor Summary

  1. ✅ Flutter: This shows when the Flutter is Successfully Installed on your machine.
  2. ✅ Android toolchain: This shows when your application is ready to use and all the libraries are set into the correct path.
  3. ✅ Chrome: This shows when your application is available to run on the web.
  4. ✅ Android Studio: This shows when the Android Studio is Successfully installed including the SDK.
  5. ✅ VS Code: This is an IDE. It shows which IDE is connected to your application(Eg. Atom, GNOME Builder, Geany, Che, etc).
  6. ✅ Connected Devices: It shows that the virtual device is connected to your application or not. The virtual device can be created through AVD Manager in Android Studio.

And, Now your application is all set to work.

Open your application on your desired IDE and connect it to an emulator.

Visual Studio Code IDE

Connecting Firebase to the Application

  • Open Firebase Console.
  • Select Add Project
  • Name the Project you want to create and continue.
  • If you need Google Analytics for your project Enable Google Analytics for the Project Button or You can turn it off and continue.
  • If you have enabled Google Analytics then you need to configure by creating or adding an account. Usually for regular projects choose Default Account for Firebase.
  • And now enable create Project.
  • If you have not enabled Google Analytics, you can directly create the project without configuring Google Analytics.

After creating the project it is visible like below:

Now click on the Android Button to add firebase to your Android App.

Firstly, We need to register the app:

  • Android Package Name: We can find the android package name in your project folder Named “Android-App-Src-Main-AndroidManifest.xml”
Android Package Name
  • App nickname (optional): Enter the name of the App.
  • Debug signing certificate SHA-1 (optional): SHA-1 key is useful for many projects.

Finding SHA-1 Key:

  • Open the command prompt.
  • Navigate to the place where JDK-bin is present on your local machine (Usually present in — “Program Files-Java-JDK-bin”).
  • Now run “keytool” over there on the command prompt.
  • Now you are ready to generate SHA-1.
  • If you are on Windows Operating System then Run

keytool -list -v -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore

  • If you are on Mac/Linux Operating System then Run

keytool -list -v \ -alias androiddebugkey -keystore ~/.android/debug.keystore

  • The default Keystore password for both Windows and Mac/Linux is “android
  • After running those commands we will get the SHA-1 key
SHA-1 Key
  • And Next, Register your app.
  • Now As the next step download the JSON file.
  • Note: If you already have the JSON file downloaded use it only and don't download the file again. If you download the file again it may have some disturbances.
  • Now place the JSON file in the Android-App folder.
JSON file in Android->App folder
  • Now add the SDK to the firebase.

There will be two levels of gradles:

  1. Project Level
  2. App Level
  • Now Add the dependencies at the project level
  • Now add the plugins and dependencies at the App Level
  • When every step goes ok it is visible like below:
  • Now continue console.

Finally, Firebase is added to your Android App.

--

--