Getting started with Firebase for Android

  • 2019-02-27 04:12 AM
  • 45

To add Firebase to your app you'll need a Firebase project and a Firebase configuration file for your app. When prompted, enter your app's ...

In my previous post, Firebase as a Backend, I briefly explained the features of Firebase and what benefits you can have if you use Firebase as your service base. Here, I will explain to you what are the initial steps you should take to start using Firebase for your applications.

Video Tutorial

Steps

  1. Go to https://console.firebase.google.com
  2. Add Project (you could also import already existing Google Console Project). Creating project from Firebase console will also create Google Console Project automatically, so do keep in mind the limit of creating google console projects.     
  3. Out of these 3 options, you could choose any of them. For this post, I am going to choose, Add Firebase to your Android App.
  4. Keep ready your package name, SHA1 is not mandatory.
  5. After you are done with Registering app you need to download google-services.json config file. This config file you need to put in the app folder of your Android application.
  6. The last step for setting up and linking up Firebase with your Android app would be to put the following lines in your Android project.

Add following line in dependencies of app module

compile 'com.google.firebase:firebase-core:16.0.0'

Add following code at the last of build.gradle for app module

apply plugin : 'com.google.gms.google-services'

Add following code to dependencies of root-level build.gradle

classpath 'com.google.gms:google-services:4.0.1'

Add following code to allprojects section in root-level build.gradle

repositories {
    maven {
       url "https://maven.google.com"
    }
}

These above steps will now link your Firebase Project with Android project. If something does not work, try reinstalling the app. Next question which comes to mind is How to use Database, Storage, etc. in Android Application. For that, I have written separate posts on Database and Storage The following table shows which dependency you should add in order to use respective component.

android
Feel free to ask anything on Firebase. Do write in comments section below if you are already using Firebase and finding some issues.

Originally published at https://techieblossom.com/

Learn More

The Complete Android N Developer Course
Learn Android Development
Android O & Java - Mobile App Development | Beginning to End
The Complete React Native and Redux Course
Flutter & Dart - The Complete Flutter App Development Course

Suggest