Setting Up Firebase
Connect your app to a Firebase project.
Setting Up Firebase is a free Android Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Android Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
What Is Firebase?
Firebase is Google's app development platform. It gives your Android app a ready-made backend so you don't have to build and host servers yourself.
In this course you'll connect an app to Firebase, then use three of its most popular services:
- Authentication — sign users in with email or Google
- Cloud Firestore — a realtime NoSQL database
- Cloud Messaging (FCM) — push notifications
This first lesson is all about setup: creating a project and wiring it into your Android app.
Create a Firebase Project
Everything starts in the Firebase console at console.firebase.google.com.
- Click Add project and give it a name.
- Each Firebase project maps to a Google Cloud project behind the scenes.
- One Firebase project can hold multiple apps (Android, iOS, web).
Inside the project you register your specific Android app using its application ID (package name), for example com.coddykit.demo. This ID is how Firebase knows which app a request comes from.
The google-services.json File
When you register your Android app, Firebase generates a config file called google-services.json.
You download it and drop it into your app module's root folder (next to build.gradle.kts, inside the app/ directory).
This JSON contains your project ID, API keys and the app's registration details. The build tools read it automatically — you almost never open it by hand.
// File location in your project:
// app/google-services.json
// It is generated for you and looks roughly like:
{
"project_info": {
"project_id": "my-demo-app",
"storage_bucket": "my-demo-app.appspot.com"
},
"client": [
{ "client_info": { "mobilesdk_app_id": "1:1234567890:android:abc123" } }
]
}Add the Google Services Plugin
To make Gradle read google-services.json, add the Google Services Gradle plugin.
The modern approach uses the plugins block with version catalogs. You declare the plugin in the root build file (with apply false) and then apply it in the module build file.
// Root build.gradle.kts (project level)
plugins {
id("com.android.application") version "8.5.0" apply false
id("org.jetbrains.kotlin.android") version "2.0.0" apply false
id("com.google.gms.google-services") version "4.4.2" apply false
}Apply the Plugin in the Module
In the app module's build.gradle.kts, apply the plugin so it processes your config file during the build.
Without this line, Firebase initialization will fail at runtime even if everything else is correct.
// app/build.gradle.kts (module level)
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("com.google.gms.google-services")
}The Firebase BoM
Firebase has many libraries (Auth, Firestore, Messaging, Analytics...). Keeping their versions in sync is easy with the Bill of Materials (BoM).
You declare the BoM once, then add each Firebase dependency without a version — the BoM picks compatible versions for you.
// app/build.gradle.kts -> dependencies { }
dependencies {
// One BoM controls all Firebase versions
implementation(platform("com.google.firebase:firebase-bom:33.1.0"))
// No version numbers here - the BoM decides
implementation("com.google.firebase:firebase-auth")
implementation("com.google.firebase:firebase-firestore")
implementation("com.google.firebase:firebase-messaging")
}Automatic Initialization
You might expect to call something like Firebase.initialize() in your Application class. With the modern SDK, you usually don't.
The Google Services plugin auto-generates an initialization provider that runs at app startup using google-services.json. By the time your Activity starts, Firebase is ready.
// You normally do NOT need this anymore:
// FirebaseApp.initializeApp(context)
// Firebase is initialized automatically on app launch.
// You can just start using a service:
import com.google.firebase.Firebase
import com.google.firebase.firestore.firestore
val db = Firebase.firestore // ready to useThe Kotlin KTX Style
Firebase offers idiomatic Kotlin accessors via the Firebase object. Instead of FirebaseFirestore.getInstance() you write Firebase.firestore.
These extensions read more naturally and are the recommended style in modern Android code.
import com.google.firebase.Firebase
import com.google.firebase.auth.auth
import com.google.firebase.firestore.firestore
import com.google.firebase.messaging.messaging
val auth = Firebase.auth // FirebaseAuth
val db = Firebase.firestore // FirebaseFirestore
val fcm = Firebase.messaging // FirebaseMessaging
// Equivalent old style:
// val auth = FirebaseAuth.getInstance()Add the Internet Permission
Firebase talks to Google's servers, so your app needs network access. Declare the INTERNET permission in your manifest.
This is a normal permission, granted automatically at install time — no runtime request needed.
<!-- AndroidManifest.xml -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<application ... >
<!-- activities, services -->
</application>
</manifest>Verify the Connection
A quick way to confirm setup works is to read a value or check the current Firebase app. If Firebase weren't initialized, accessing a service would throw.
Many developers also temporarily add the Analytics dependency and look for an event in the console as a smoke test, but simply touching a service in code already proves the wiring.
import android.util.Log
import com.google.firebase.Firebase
import com.google.firebase.firestore.firestore
fun verifyFirebase() {
val app = Firebase.firestore.app
Log.d("Firebase", "Connected to project: ${app.options.projectId}")
}Common Setup Mistakes
If Firebase isn't working, check these first:
- Wrong package name — the app's applicationId must match what you registered.
- Missing google-services.json — it must sit in the
app/folder. - Forgot to apply the plugin in the module build file.
- No INTERNET permission in the manifest.
- SHA-1 fingerprint not added — required later for Google sign-in.
Quick Check
What is the purpose of the google-services.json file?
Recap: Setup Done
You connected an Android app to Firebase. Key steps:
- Create a project in the Firebase console and register your app by package name.
- Add
google-services.jsonto theapp/folder. - Apply the Google Services plugin and add the Firebase BoM plus the libraries you need.
- Firebase initializes automatically — access services via
Firebase.auth,Firebase.firestore, etc. - Don't forget the INTERNET permission.
Next up: signing users in with Firebase Authentication.
Frequently asked questions
Is the “Setting Up Firebase” lesson free?
Yes — the full text of “Setting Up Firebase” is free to read here on the web, and the Android Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Android Academy course, upgrade to CoddyKit PRO.
What will I learn in “Setting Up Firebase”?
Connect your app to a Firebase project. You practise Android Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Android Academy?
No prior experience is required. Android Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Setting Up Firebase” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Android Academy lesson?
Yes. Every Android Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Setting Up Firebase
- Firebase Authentication
- Cloud Firestore Basics
- Push with Cloud Messaging