Firebase

Adding Firebase to Android App Manually

In this article, I’ll show you how you adding firebase to android app. We’ll discuss the possible options and recommended ways of it. Apart from this, I will tell you preliminary information for Firebase integration. For doing that, we’ll create a sample app and will add the firebase into it. So let’s started

Prerequisite

The following preliminary information that required for Firebase

  • One Google account
  • One real device or emulator for running the sample app
  • The latest Android Studio version (1.5 or later)
  • The app must use gradle 4.1 or later
There are two options for adding firebase into your project.
  • Firebase Assistant in Android Studio
    • Prebuild tool available in Android Studio
    • Using Assistant you can connect existing project or create new ones for you.
    • Assistant is automatically added and install all necessary dependencies
  • Add Firebase to your app via a firebase console manually.
    • This way you have to do all operations manually

Note – Google recommended manual way to add firebase in your app.

Create a project in Firebase console

Let’s open web browse and open firebase console. Click on add project -> enter the project name -> If you need analytics then check this option otherwise you can uncheck it. Finally, click on create a project.

adding firebase to android app
Go to add firebase into android platform

Open this project and click on android icon, Then below window pop up. The big thing here is the package name. This package name has to match android app package name.

how to add firebase to android app
The next step is to download google-services.json file

You have to download this file and put into your app

add firebase to android app
Put this json file into app folder in your app

It’s a really important step. So let’s open your app folder -> navigate app folder – paste inside the app google-services.json. After adding it click on next.

how to add firebase database to android app
Create a project in Android Studio with the same package name.

Let’s move to Android Studio create a new project with package name com.sampleapp. Now paste the google-services.json file in your app folder. just like below screenshot.

Add firebase SDK
Modify project-level build.gradle in Android Studio and add SDK classpath
  dependencies {
    // Add this line
    classpath 'com.google.gms:google-services:4.3.2'
  }
Open the app-level.gradle file. (<project>/<app-module>/build.gradle)
// Add this line
apply plugin: 'com.google.gms.google-services'

After modifying these files sync the project. Now your firebase setup is used. Firebase provides so many libraries that we’ll learn in the coming tutorial.

Learn our firebase android tutorial series

Leave a Reply

  Subscribe  
Notify of