Firebase, developed by Google, provides online services like a real-time database, user authorization, cloud messaging, crash reporting, and more. Google Firebase is a Backend as a Service (BaaS) platform designed to work on Android, iOS, Web, or Unity. It is an application development platform for mobile applications, web applications, and games. Firebase contains several tools for reporting and fixing application crashes, hosting, tracking daily analytics, and creating marketing and product experiments.
Firebase manages the real-time data in the database so we can easily and quickly exchange data to and from the database.
Firebase provides simple serialization of the application state.
Firebase allows syncing of real-time data across all devices without refreshing the screen.
It provides analytics to crash reports.
It offers a simple control dashboard.
Firebase has minimal setup.
Firebase provides three-way data binding via angular fire.
Firebase is the most advanced hosted BaaS solution.
Firebase has massive storage size potential.
There are two methods to add Firebase to any Android app:
Firebase assistant
Manually add Firebase
Firebase assistant automatically adds the necessary files and code to the Android project.
Here are the steps to use Firebase assistant in an Android app.
First, ensure that Android Studio is version 2.2 or above.
We can add Firebase to the Android project by clicking on Firebase from the Tools menu.
Next, click on Firebase. A new screen will appear on the right side of the project. This screen shows several Firebase features such as authentication, cloud messaging, analytics, real-time database, etc.
You can select any one of the features. For this example, select Analytics.
Now we need to click on the ‘Connect to Firebase’ option in the menu. Then we will see the below screen.
Click on the Allow option to take us back to the Android studio. Since our project already has a Firebase connection, a pop-up message will display that looks like the following window.
We need to click on Connect to Firebase to establish a connection to our project.
For the last step, we need to add the dependencies. You can choose any Firebase features. We will add analytics to our application by clicking on Add Analytics to your app.
To manually add Firebase to an Android app, follow the steps below.
In this method, we first need to create a Firebase project. Here are the steps to do so.
First, we go to the Firebase console.
Next, we create a Firebase project by clicking on the Create a project button.
Give a name to the project. The Firebase console will automatically create a unique ID for the project. Click on Continue.
Now, we need to enable Google Analytics for our project. Click on Continue.
Set analytics location, accept all the terms and conditions, and click on Create project.
Clicking the Create project button creates our Firebase project. Click on Continue to enter our Firebase project.
Firebase allows different platforms such as IOS, Android, Web, and Unity to add an application. We will choose Android.
After selecting Android, the window below will appear. Here we need to fill in the necessary details. The first is the package name. The package name should match the package name of our Android applications. The second is an optional field that will give a nickname to our app. The last field is SHA-1
Find the SHA-1 certificate: In the Android studio, we can find the SHA-1 with the following steps:
Go to the Android studio project.
Go to Gradle.
Then go to the root folder
Then tasks
Then Android
Then signing the report
And then copy and paste SHA-1.
Now we need to click on the Register app.
Firebase automatically creates and provides the Download config file.
Now, we have to download the google-services.json file.
Click on Next.
Perform this step inside the Android studio. First, we will add the Firebase SDK in our build.gradle files. Next, add the following lines of code.
After adding the Firebase SDK, we need to Sync our Gradle files and click on Next.
Now we need to run our app to verify the installation.