CODE24 WEB SOLUTIONS
Home / Firebase setup
Android Studio · Firebase

Connect your Android app to Firebase.

A practical walkthrough for registering an Android app, adding its configuration, installing SDKs and checking that the connection works.

A reliable setup, step by step

What the connection does

Firebase services let an Android app use products such as Authentication, Cloud Firestore, Analytics and Crashlytics. Connecting the project registers the app, adds its Firebase configuration and makes the selected SDKs available to the Android build.

Important: Firebase configuration identifies your project, but it is not a replacement for access control. Protect user data with Firebase Authentication and properly configured Security Rules.

1. Register your Android app

  1. Open the Firebase Console and create a Firebase project, or select one you are authorised to use.
  2. Add an Android app from the project overview and enter the Android package/application ID from your app module’s Gradle configuration.
  3. Check the application ID carefully. It must match the installed app exactly. A debug or product-flavor variant may use a different ID.
  4. Register the app. Add a SHA certificate fingerprint only when a feature you use requires it, such as certain sign-in providers or App Check flows.
Tip: The application ID is commonly set as applicationId in app/build.gradle or app/build.gradle.kts. Do not rely on the Kotlin or Java package name alone.

2. Add the Firebase configuration file

Download google-services.json for the registered Android app and place it in the Android app module directory—usually the project’s app/ folder.

your-project/
├── app/
│   ├── build.gradle.kts
│   └── google-services.json
├── build.gradle.kts
└── settings.gradle.kts

If your project has multiple build variants, confirm that the configuration file matches the application ID of the variant you are building. Never add service-account private keys or server credentials to an Android app.

3. Configure the Google services plugin and Firebase SDK

Use Firebase’s setup instructions for the current plugin and SDK versions. The examples below show the usual Kotlin DSL structure; replace each placeholder with the version recommended for your project.

Project-level build.gradle.kts
plugins {
    // Keep your existing Android plugin entries.
    id("com.google.gms.google-services") version "CURRENT_PLUGIN_VERSION" apply false
}
App module app/build.gradle.kts
plugins {
    // Keep your existing Android and Kotlin plugin entries.
    id("com.google.gms.google-services")
}

dependencies {
    // Replace with the current Firebase BoM version.
    implementation(platform("com.google.firebase:firebase-bom:CURRENT_BOM_VERSION"))

    // Add only the Firebase products your app actually uses.
    implementation("com.google.firebase:firebase-auth")
}

If your project uses Groovy Gradle files, use the equivalent syntax from the official setup page. Avoid copying old plugin or BoM versions from tutorials; versions change over time.

4. Use a Firebase product in your app

After Gradle sync, add the SDK for the product you need and follow that product’s current setup guide. For example, the Firebase Authentication Kotlin SDK provides an authentication instance:

import com.google.firebase.auth.FirebaseAuth

val auth: FirebaseAuth = FirebaseAuth.getInstance()

Initialize Firebase only as required by the SDK and your project setup. Modern Firebase Android libraries normally use the default app configuration generated from google-services.json.

5. Build and verify the connection

  1. Sync Gradle and resolve plugin or dependency errors before running the app.
  2. Build and install the same app variant whose application ID is registered in Firebase.
  3. Test the Firebase feature in a development environment—for example, sign in with a test account if you added Authentication.
  4. Check Firebase Console for product-specific activity. Some dashboards take time to show new events.

Common setup problems

Gradle cannot find the Google services plugin

Check that the plugin is declared in the project-level Gradle configuration, applied in the app module, and that your project repositories and Gradle versions are compatible with current Firebase instructions.

Firebase reports that the app is not configured

Compare the registered Android package name with the app variant’s exact applicationId. Confirm that google-services.json is in the correct module or variant-specific directory, then sync and rebuild.

Authentication or a Firebase product does not work

Confirm the product’s SDK is included, that it is enabled and configured in Firebase Console, and that any required sign-in provider, SHA fingerprint, API or Security Rules are set up.

The app works on debug but not on release

Check release application IDs, signing certificate fingerprints when required, build-variant configuration and release-specific Firebase settings. Test a release build before publishing.

Security checklist

  • Require authentication where data or actions are private.
  • Write and test Firestore or Realtime Database Security Rules before production.
  • Do not ship Firebase service-account keys, private credentials or server secrets in the app.
  • Use separate Firebase projects or carefully managed environments for development and production.
  • Review authentication providers, API restrictions, App Check and access logs as appropriate to your app.
Building an app?

Need help planning your Android app?

Code24 can help with Android and cross-platform app development, integrations and a practical launch plan.

Talk to Code24

This is an independent, general setup guide and is not affiliated with or endorsed by Google or Firebase. For the latest SDK versions and product-specific instructions, consult the official Firebase documentation.

WA