Android Firebase Integration
This document describes the basic configuration required to connect an Android application to Firebase. Completing this integration allows you to use services such as Push Notifications, Crashlytics, and Analytics.
📋 Prerequisites
| Requirement | Description | Notes |
|---|---|---|
| ✅ Firebase Account | Firebase Console | Ensure you have access or invitation from an admin. |
| ✅ Android Studio | Development environment where Firebase SDK will be integrated | |
| ✅ Android Project | The Android app project to be connected to Firebase |
🔧 1. Creating a Firebase Project
- Go to Firebase Console.
- Click Add project.
- Enter a project name and optionally enable Google Analytics.
- Complete the project creation process.
🧩 2. Adding an Android App to Firebase
- Open your Firebase project.
- Click the Android icon to add an app.
- Fill in the required info:
- Android package name (e.g.,
com.example.myapp) - App nickname (optional) (e.g.,
MyApp - Android Internal App) - Debug signing certificate SHA-1 (optional, can be retrieved via Android Studio)
- Android package name (e.g.,
- Click Register app.
- Download the
google-services.jsonfile.
📥 3. Adding google-services.json to Your Project
Place the downloaded google-services.json file into your Android app folder: YourProject/app/google-services.json
This file enables the Firebase SDK to configure the app.
⚙️ 4. Firebase SDK Setup
- In project-level
build.gradle(usuallybuild.gradle (Project: your-app)):
buildscript {
dependencies {
classpath 'com.google.gms:google-services:4.4.0'
}
}
- In app-level
build.gradle(usuallybuild.gradle (Module: app)):
plugins {
id 'com.android.application'
id 'com.google.gms.google-services' // add at the bottom
}
dependencies {
implementation 'com.google.firebase:firebase-analytics:21.6.1'
// Optional Firebase modules:
implementation 'com.google.firebase:firebase-messaging:23.4.1' // for push notifications
}
🚀 5. Starting Firebase SDK
Firebase initializes automatically with google-services.json and the Google services plugin.
If you want manual initialization, do it in your Application subclass:
class BaseApplication : Application() {
override fun onCreate() {
super.onCreate()
FirebaseApp.initializeApp(this)
}
}
And add to your AndroidManifest.xml:
<application
android:name=".BaseApplication"
... >