How to integrate Firebase into Android App – Android Studio

Firebase is a mobile and web application development platform developed by Google. We can build our apps very fast, without making complex back-end system. It helps to scale automatically, for even the largest apps. In this tutorial, we’re gonna go through the steps to integrate Firebase into Android App with Android Studio Enviroment.

I. Technology

– Android Studio 2.x
– Firebase Android SDK 11.x

II. Step by Step

1. Get SHA-1 Key

– Open your Android Project, in Gradle projects window, double-click on signingReport:
firebase-signingreport

– Look at Run window, you can find SHA-1 Key:
firebase-sha-1

2. Create Project on Firebase

Go to Firebase Console, login with your Google Account, then click on Add Project.

Enter Project name, select Country/Region:
firebase-create-project

Press CREATE PROJECT, a Popup will be shown.

3. Add Firebase to Android App
3.1 Register App

Fill Android package name, App nickname, and SHA-1 (got from step 1):
firebase-register-app

Click on REGISTER APP.

3.2 Download and add config file

– Click on Download google-services.json to download the config JSON file:
firebase-download-config-file

– Move google-services.json into your Android App root directory:
firebase-config-file

Click on CONTINUE. You will come to:
firebase-add-sdk

3.3 Add Firebase SDK

– Open build.gradle (project-level), add:

firebase-add-sdk-project-level

– Open build.gradle (App-level), add:

firebase-add-sdk-app-level

– Re-sync Gradle files:
Tool -> Android -> Sync Project with Gradle Files.

III. When sync fails

– Make sure that package_name in google-services.json has a correct value according to:
+ applicationId in build.gradle (App-level).
+ package in AndroidManifest.xml.

– Open SDK Manager to update:
+ Google Play services
+ Google Repository


Related Posts


Got Something To Say:

Your email address will not be published. Required fields are marked *

*