How to add Firebase to your Android Studio Project

Prerequisites

You need a device running Android 2.3 (Gingerbread) or newer devices.
NewImage
Make sure the device or emulator has a Google Play Services 9.0 or above.

NewImage

You need to make sure you have atl least Google Play Services rev 30 and Google Repository Rev 30. As per today we have Google Play services rev 33 and Google Repository rev 35. Always update this two repository.

There are plenty of sample code for Andorid and iOS here. You can also Quick Start from GitHub

Step to add firebase project.
 NewImage
1. Add firebase project in https://firebase.google.com/console/.


NewImage
2. Click Add Firebase to your Android app
NewImage
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.

4. Doownload a google-services.json file and drag and drop the file in your android studio app folder.


NewImage

The Google services plugin for Gradle loads the google-services.json file that you just downloaded. Modify your build.gradle files to use the plugin.

  1. Project-level build.gradle (<project>/build.gradle):
    buildscript { dependencies {
        // Add this line
        classpath 'com.google.gms:google-services:3.0.0' } }
  2. App-level build.gradle (<project>/<app-module>/build.gradle):
    ...
    // Add to the bottom of the file
    apply plugin: 'com.google.gms.google-services'
    includes Firebase Analytics by default help_outline
  3. Finally, press "Sync now" in the bar that appears in the IDE:
The Google services plugin for Gradle loads the google-services.json file that you just downloaded. Modify your build.gradle files to use the plugin.

No comments:

Post a Comment