Android Firebase Configuration: google-services.json Explained
The google-services.json file is the bridge between your Android app and Firebase. This guide explains every field in the file, where it goes, how the Gradle plugin processes it, and how to fix common configuration errors.
What Is google-services.json?
When you register an Android app in the Firebase Console, Firebase generates a google-services.json file containing:
- Your Firebase project ID and number
- The Android package name and app ID
- API keys for Google Sign-In, Analytics, and other services
- OAuth client IDs for authentication flows
- Storage bucket and database URLs
File Structure
{
"project_info": {
"project_number": "123456789012", // GCM sender ID
"project_id": "my-app-12345", // Identifies the Firebase project
"storage_bucket": "my-app-12345.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:123456789012:android:abc123",
"android_client_info": {
"package_name": "com.example.myapp" // Must match applicationId
}
},
"oauth_client": [
{
"client_id": "123456789012-xxxx.apps.googleusercontent.com",
"client_type": 1 // 1 = Android, 3 = Web client
}
],
"api_key": [
{ "current_key": "AIzaSy..." }
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [...]
}
}
}
],
"configuration_version": "1"
}Where to Place the File
MyApp/ ├── app/ │ ├── google-services.json ← Correct location │ ├── src/ │ │ └── main/ │ └── build.gradle ├── google-services.json ← WRONG — project root, will not work └── build.gradle
For apps with multiple build flavors, place variant-specific files at:
app/src/debug/google-services.json // debug build app/src/release/google-services.json // release build app/src/staging/google-services.json // custom flavor
Gradle Plugin Setup
The Google Services Gradle plugin reads the JSON file and generates Android resource strings that the Firebase SDK reads at runtime. Without the plugin, Firebase will not initialize.
// settings.gradle (Gradle 7.4+ with version catalog)
pluginManagement {
repositories {
google()
mavenCentral()
}
}
// Project build.gradle
plugins {
id("com.google.gms.google-services") version "4.4.0" apply false
}
// App build.gradle
plugins {
id("com.android.application")
id("com.google.gms.google-services") // Apply here
}
dependencies {
implementation(platform("com.google.firebase:firebase-bom:33.1.0"))
implementation("com.google.firebase:firebase-analytics")
}Common Errors and Fixes
File google-services.json is missing from module root folderMove google-services.json to the app/ directory (not the project root).
No matching client found for package nameThe package_name in the JSON must exactly match your app's applicationId in build.gradle.
Default FirebaseApp is not initializedThe Google Services plugin is not applied. Add id("com.google.gms.google-services") to your app's build.gradle.
Use our tool to validate your file
The Google Services JSON tool can parse your file, check for missing required fields, and validate the package name format before you run a build.
Related Resources
Written by Zhisan
Independent Developer · Last updated June 2026