How to add Firebase SDK dependencies

The Firebase SDK is a dependency of the App Center SDK, so if you wish to use the App Center Push, you need to add Firebase dependencies by using the following steps.

Note

If you are a Firebase customer and already use Firebase features, you can skip the following steps.

1. Integrate Firebase in application

  • In the Firebase Console, go to Project Settings.

  • Download the google-services.json file to your Android project's app module (for most projects, it will be the project's android/app folder).

  • Modify the android/build.gradle file:

    buildscript {
        repositories {
            // Add google line if missing before jcenter
            google()
            jcenter()
        }
    
        dependencies {
            // Add this line
            classpath 'com.google.gms:google-services:4.0.1'
        }
    }
    
    allprojects {
        repositories {
            // Add google line if missing before jcenter
            google()
            jcenter()
        }
    }
    

    Note

    Google introduced the google() repository with Gradle v4. If your Gradle version is lower than v4, then you need to use maven { url 'https://maven.google.com' } instead of google().

  • Modify the project's android/app/build.gradle file:

    // Add this line at the bottom
    apply plugin: 'com.google.gms.google-services'
    

2. Remove Sender ID

Remove the Push.setSenderId("{Your Sender ID}") method call from MainApplication.java.