ADDING FIREBASE SDK TO ANDROID APP

Working with Firebase is pretty easy. If you are new to Firebase you can look into the introduction to Firebase and follow this tutorial. Before started it is preferred to have following prerequisites.

Prerequisites

  • A device running Android 2.3 (Gingerbread) or newer, and Google Play services 9.6.1 or newer
  • The Google Repository from the Android SDK Manager
  • Android Studio 1.5 or higher

Now follow these steps for installing the SDK

Step 1 : Create a Firebase project in the Firebase console, if you don’t already have one. If you already have an existing Google project associated with your mobile app, click Import Google Project. Otherwise, click Create New Project.

instal2

instal1

Step 2 : Click Add Firebase to your Android app and follow the setup steps. If you’re importing an existing Google project, this may happen automatically and you can just download the config file.

instal3

Step 3. When prompted, enter your app’s package name. It’s important to enter the package name your app is using; this can only be set when you add an app to your Firebase project.

instal4

Here I am creating new project. You can add your existing project’s package name also and insert the configuration file into the same Projects app folder

instal5

Step 4 : At the end, you’ll download a google-services.json file. You can download this file again at any time.

Step 5 : You can copy ‘google-services.json’ file and paste in the app folder or drag and drop to app folder form your     downloads

instal7

Step 6 : Add rules to your root-level build.gradle file(Project’s), to include the google-services plugin:

It should look like snippet below

 

instal8

 

Step 7: Now in your module Gradle file (usually the app/build.gradle), add the apply plugin line at the bottom of the file to enable the Gradle plugin:

And dependency should look like snippet below

 

instal10

Note : You should also add the dependencies for the Firebase SDKs you want to use. As of now I have used ‘firebase-core’. I have used other dependencies in the respective task and will be explained there.

Step 8 : Sync the project with gradle files. Make sure you have proper internet connection. You should get gradle build successful and hence SDK is successfully installed.