Connect Your Android App to Firebase

Connect Your Android App to Firebase

Firebase is a development kit for adding core infrastructure features to mobile apps and Google Cloud Platform projects. Sometimes called “backend-as-a-service,” it helps bring secure and scalable capabilities to your projects.

This post guides you in creating a connection between Firebase and your app. It uses Gradle’s Kotlin DSL in a native Android project compiled on macOS.

Firebase Project

  1. Navigate to the Firebase Console, and then Add project.

  2. Set its name and create your project.

  3. Navigate to its overview dashboard, then Add app and select the Android platform.

  4. Register the app’s package name. Log your machine’s fingerprint with the keytool CLI. The default password for the android debug keystore is android.

    keytool -list -v -alias androiddebugkey -keystore ~/.android debug.keystore
    

    ``

  5. Copy/paste the SHA1 value into the Firebase field where requested.

  6. Download the project’s google-services.json config file.

Android Project

  1. Move the downloaded google-services.json within the app module.

  2. Add the Google Services Plugin to the project’s buildscript:

    classpath("com.google.gms:google-services:4.3.1").

  3. Apply the plugin below the app module’s dependencies closure,

    apply(mapOf("plugin" to "com.google.gms.google-services")).

Run the app and watch the Firebase console to confirm successful installation. Now you’re ready to select from helpful Firebase solutions. Some of them will need the Analytics feature configured too. Integrating specific products will be an exercise for the reader until a future post.