Creating a Firebase Project and connecting it to an App

Umair Jibran
4 min readApr 25, 2020

--

NOTE: This article is over 2 years old, you can read this as a reference only, the code snippets might be outdated

Flutter + Firebase ❤

First of all, you need to have a Google Account to create a Firebase Project. If you don’t you can create one here. After creating Google Account you need to create a Firebase Project here, now follow the following simple steps.

Step 1: Name Your Firebase Project

Naming your Firebase Project
Project Name

Read, and Accept the Firebase Terms, if you agree.

Step 2: Google Analytics Opt-in/out

Google Analytics
Opt-in/out to Google Analytics

Opting-in to Google Analytics is Optional but if you decide to opt-in you get, in debt analytics and some demanding features, free, from Google. if you opt-in here you will have another step otherwise this will be your final step.

Step 3(Final Step): Location and Sharing

Google Analytics according to Location

Select your Location for Analytics, and you can choose what data to collect/share via Google Analytics. After choosing carefully what data to share and what to not, read the following terms and conditions, accept if agree, and Create your Project.

Creating Project will take some time. So sit Tight! once the project is ready you’ll be prompted hit Continue.

The project is Ready now
Integrate it to your App

Select your Platform i.e Android/iOS/Web or Unity (I’ll go with Android for now)

Step 1:

Adding Firebase to the Android Application

Enter your Package name, if you don’t know what it is you can always check it here in default package name is com.example.[your_app_name]

build.gradle location

[project] > android > build.gradle {here you can find it as applicationID in `defaultConfig` bloc}

you can also add a nickname for your Application(merely for distinguishing if you have more than one app)

SHA keys are for user authentication, we don’t need them in this scenario, but if you still want to add them, here’s how

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

Just copy, paste and run this in your terminal

Step 2:

Google Config Files

Download the following config File, and paste them in the following directory.

[Project] > android > app

Hit next after doing this.

Step 3:

updating build.gradle

For the following step, I would strongly recommend using Android Studio.

Open the following two files

build.gradle(app and project level)

Add the highlighted line of codes in the build.gradle(Project: android) file

Updating build.gradle(Project: android)

Add the highlighted line of codes in the build.gradle(Module: app) file

Updating build.gradle(Module: app)

if you had opted-in for Google Analytics, you have to add this line as well, otherwise, you don’t have to:

Updating build.gradle(Module: app), if you have opted in for analytics

After adding all the above line of codes, you have to now, sync the project for building the gradle. If you encounter an error about gradle, check this video, it might help

Sync your project

After Gradle builds and the app synced, we have connected our app to FIrebase. Now, if you had opted-in for Google Analytics, you should now run the app to verify the connection with Google servers.

--

--