Kick-start with Firebase in Android.

TapanHP
reverseBits
Published in
5 min readNov 16, 2016

This is very basic introduction to Firebase, so if you are familiar with it then you can jump over implementation of stuff discussed in Series of tutorials on our channel.

For those who are new, here we go… Google says that,

Firebase is a mobile platform that helps you quickly develop high-quality apps, grow your user base, and earn more money. Firebase is made up of complementary features that you can mix-and-match to fit your needs.

As per our experience, Firebase is awesome for developers, whether you belong to Web or Mobile development.

Important question : Is Firebase easy to understand and learn?
Ans : Well good news is yeah, see this epic pic:

say yes

Signup with your google account on official site of Firebase and on top right corner you can see the Go to console link, this is basically your console where you can see all your running projects, you can start new projects from here and can also Import existing Google projects.

options for projects

Start a new project by clicking first one and you will asked name and country, give any name you like and then you will get your project on board.

Like i already have this one as shown in image.you can see dashboard where every configuration related stuff to that particular project is available,you can manage everything related to your project from your dashboard.

The left navigation list helps you to switch into different sections like Auth, Realtime databse and other.

Dashboard view, see very left navigation pannel

On Dashboard in Discover Firebase section you can learn everything in depth, there are code snippets, tutorials and guides available for different platform like Web, Ios and Android.

Discover Firebase section

Firebase’s paid infrastructure features are the Realtime Database, Storage, Hosting, and Test Lab. they offer a free tier for all of these features except Test Lab.

Firebase also has many free features: Analytics, Cloud Messaging, Notifications, Remote Config, App Indexing, Dynamic Links, Invites, Crash Reporting, and Authentication. You can use an unlimited amount of any of these features in all plans, including their free Spark plan.

Settings related to projects are available right there in top right corner of navigation panel in Project settings. And you can also change and add Admin permissions.

When you open dashboard then you can see options for adding Firebase in various platforms, we are here talking about using Firebase in Android so we will go with it,

Choose Add Firebase to your Android app

You will be prompted to enter your project related details in it,like package name and SHA key.

details asked for project

Copy+Paste your full package name from Android menifest file and generate SHA-1 from your command prompt by using below command,

To get the debug certificate fingerprint:

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

Note: remove the “\” after -v as it is for multi line specific command line.

asking for password

Password : android

Now you will be able to get SHA-1 and then copy+paste it to our project details screen on Firebase, If you face any issues in generating SHA-1 key then read our Google sign in post.

After this step you will get configuration file named google-services.json,
just save it safely somewhere.

Adding Firebase SDK in android studio to get started

Prerequisites:

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

Add that google-services.json file in to your App level module in Android studio project.

App level module

Now in your project level (Root level) build.gradle add following lines,

buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:3.0.0'
}
}

and Then, 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:

apply plugin: 'com.android.application'

android {
// ...
}

dependencies {
// ...
compile 'com.google.firebase:firebase-core:9.8.0'
}

// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'

After syncing it you are good to go, see above code snippet i have taken compile 'com.google.firebase:firebase-core:9.8.0'

It is just for example,this is used for adding analytics support in your app there are other dependencies available for different purpose, here is list of all those:

Dependencies list

Other useful references are here:

  1. Official documentation
  2. Firebase codelab
  3. Samples
  4. Libraries
  5. Stackoverflow posts

If you find this post helpful then you can recommend, share the post and we will going to write more in series of Firebase with Android soon…So cheers up !!

--

--