PC パソコン

How to Fix Android “FirebaseApp initialization unsuccessful”

After adding Firebase to an Android application, Logcat may report “FirebaseApp initialization unsuccessful”.

FirebaseApp initialization unsuccessful

This message means that Firebase’s automatic initialization did not complete successfully.

In a normal Firebase Android application, the default FirebaseApp is initialized automatically by FirebaseInitProvider, a ContentProvider that runs when the application starts. Google’s FirebaseApp API reference states that for the vast majority of applications, FirebaseInitProvider initializes the default Firebase project using configuration generated from google-services.json, with no additional initialization code required. :contentReference[oaicite:21]{index=21}

Therefore, when initialization fails, check the Firebase configuration rather than immediately adding FirebaseApp.initializeApp() everywhere.

This article explains how to diagnose the JSON file, Google Services Gradle plugin, generated resources, application ID, Firebase SDK dependencies, manifest, build variants, and process configuration.

  1. What Does “FirebaseApp initialization unsuccessful” Mean?
  2. Common Situations
  3. Cause 1: google-services.json Is Missing
  4. Solution 1: Download the Correct JSON File
  5. Cause 2: The Google Services Gradle Plugin Is Missing
  6. Solution 2: Apply the Google Services Plugin
  7. Cause 3: The Application ID Does Not Match Firebase
  8. Solution 3: Register the Current Application ID
  9. Check applicationId, Not Only namespace
  10. Cause 4: Generated Firebase Resources Are Missing
  11. Solution 4: Inspect Generated Resources
  12. Cause 5: The Wrong Debug or Release Configuration Is Used
  13. Solution 5: Match the JSON to the Current Build Variant
  14. Cause 6: applicationIdSuffix Changes the Package
  15. Solution 6: Register the Debug Application
  16. Cause 7: Firebase SDK Dependencies Are Incomplete
  17. Solution 7: Use the Firebase Android BoM
  18. Cause 8: FirebaseInitProvider Was Removed
  19. Solution 8: Inspect the Merged Manifest
  20. Check for Accidental Provider Removal
  21. Cause 9: Firebase Is Being Used in a Secondary Process
  22. Solution 9: Check android:process
  23. Cause 10: Custom FirebaseOptions Are Incomplete
  24. Solution 10: Supply Valid FirebaseOptions
  25. Cause 11: FirebaseApp.initializeApp Returns null
  26. Solution 11: Check the Return Value
  27. Cause 12: Firebase Is Accessed Too Early
  28. Solution 12: Resolve Firebase Lazily
  29. Cause 13: The FirebaseApp Was Deleted
  30. Solution 13: Remove Unnecessary delete() Calls
  31. Cause 14: Only a Named FirebaseApp Exists
  32. Solution 14: Use the Named FirebaseApp Explicitly
  33. Cause 15: Google Services Processing Failed
  34. Solution 15: Run the Google Services Task
  35. Cause 16: Gradle Sync Has Not Completed
  36. Solution 16: Run Gradle Sync
  37. Solution 17: Clean and Rebuild
  38. Check Logcat
  39. Verify FirebaseInitProvider
  40. Verify google_app_id
  41. Do Not Manually Rewrite google-services.json
  42. Using Firebase Assistant
  43. Difference from “Default FirebaseApp is not initialized”
  44. Difference from “google-services.json is missing”
  45. Difference from “No matching client found”
  46. Can Google Play services Be the Cause?
  47. What About the Android Emulator?
  48. Should You Manually Initialize Firebase?
  49. Manual Initialization Example
  50. Fastest Troubleshooting Order
  51. If the Error Still Occurs
  52. Summary

What Does “FirebaseApp initialization unsuccessful” Mean?

The normal Firebase Android initialization flow is:

google-services.json ↓ Google Services Gradle Plugin ↓ Firebase Android resources generated ↓ Application process starts ↓ FirebaseInitProvider ↓ FirebaseApp.initializeApp() ↓ Default FirebaseApp created

If Firebase cannot load the default options needed to create the FirebaseApp, automatic initialization can fail.

Google’s FirebaseApp API reference explains that initializeApp(Context) initializes the default FirebaseApp from string resources populated from google-services.json. :contentReference[oaicite:22]{index=22}

Key point: This error is commonly caused by missing or incorrect Firebase configuration resources rather than by a broken Firebase SDK.

Common Situations

  • google-services.json is missing
  • The JSON file is in the wrong module
  • The Google Services Gradle plugin is not applied
  • The application ID does not match the Firebase Android app
  • An old JSON file is being used
  • Debug, Release, or flavor-specific configuration is incorrect
  • Gradle has not been synchronized after adding Firebase
  • FirebaseInitProvider was removed from the merged manifest
  • Firebase is being accessed from a secondary Android process
  • Generated resources such as google_app_id are missing
  • Custom FirebaseOptions are incomplete

Cause 1: google-services.json Is Missing

The normal configuration location is:

app/google-services.json

Google’s Firebase Android documentation states that both the Google Services Gradle plugin and the google-services.json configuration file are part of adding Firebase to an Android project. :contentReference[oaicite:23]{index=23}

Solution 1: Download the Correct JSON File

Firebase Console → Project settings → General → Your apps → Android app → Download google-services.json

Place it in the application module:

app/ ├── build.gradle.kts ├── google-services.json └── src/

If the application module is named mobile, use:

mobile/google-services.json

Cause 2: The Google Services Gradle Plugin Is Missing

The JSON file is processed by the Google Services plugin, which generates Android resources used by Firebase.

Google’s plugin documentation lists generated values such as google_app_id, google_api_key, and project_id. :contentReference[oaicite:24]{index=24}

Solution 2: Apply the Google Services Plugin

Root:

plugins { id("com.google.gms.google-services") version "4.5.0" apply false }

Application module:

plugins { id("com.android.application") id("org.jetbrains.kotlin.android") id("com.google.gms.google-services") }

Google’s current Firebase documentation lists Google Services Gradle Plugin 4.5.0. :contentReference[oaicite:25]{index=25}

Cause 3: The Application ID Does Not Match Firebase

Android:

android { defaultConfig { applicationId = "com.example.myapp" } }

JSON:

"package_name": "com.example.oldapp"

This prevents the plugin from selecting the correct Firebase Android client.

The Google Services plugin matches the package name of the current build against clients in the JSON configuration. :contentReference[oaicite:26]{index=26}

Solution 3: Register the Current Application ID

Add an Android app to Firebase with the exact current application ID and download a fresh google-services.json.

Check applicationId, Not Only namespace

namespace = "com.example.myapp"

defaultConfig {
applicationId =
"com.example.production"
}

The final application ID is the important value for Firebase’s Android client configuration.

Cause 4: Generated Firebase Resources Are Missing

Firebase default options are loaded from generated Android resources.

Important examples include:

google_app_id google_api_key project_id

These resources are generated by the Google Services Gradle plugin. :contentReference[oaicite:27]{index=27}

Solution 4: Inspect Generated Resources

app/build/generated/res/google-services/ debug/values/values.xml

Look for:

<string name="google_app_id">...</string>

...

...

If these values are not generated, fix the JSON/plugin configuration first.

Cause 5: The Wrong Debug or Release Configuration Is Used

The Google Services plugin supports build-type-specific files:

app/ └── src/ ├── debug/ │ └── google-services.json └── release/ └── google-services.json

Google’s official plugin documentation also supports product-flavor-specific JSON files. :contentReference[oaicite:28]{index=28}

Solution 5: Match the JSON to the Current Build Variant

Check the selected variant, for example:

debug release staging freeDebug paidRelease

Cause 6: applicationIdSuffix Changes the Package

android { buildTypes { debug { applicationIdSuffix = ".debug" } } }

This creates:

Release: com.example.app

Debug:
com.example.app.debug

Solution 6: Register the Debug Application

Register:

com.example.app.debug

in Firebase and place its configuration at:

app/src/debug/google-services.json

Cause 7: Firebase SDK Dependencies Are Incomplete

Each Firebase product needs its Android SDK.

com.google.firebase:firebase-auth com.google.firebase:firebase-firestore com.google.firebase:firebase-messaging

Solution 7: Use the Firebase Android BoM

dependencies { implementation( platform( "com.google.firebase:firebase-bom:34.18.0" ) )
implementation(
    "com.google.firebase:firebase-auth"
)

implementation(
    "com.google.firebase:firebase-firestore"
)

implementation(
    "com.google.firebase:firebase-messaging"
)

}

Google recommends the Firebase Android BoM for compatible Firebase library versions. :contentReference[oaicite:29]{index=29}

Cause 8: FirebaseInitProvider Was Removed

Firebase normally initializes through FirebaseInitProvider.

Google’s FirebaseApp API reference states that this provider is merged into the application’s manifest when building with Gradle and runs automatically at application launch. :contentReference[oaicite:30]{index=30}

Solution 8: Inspect the Merged Manifest

In Android Studio:

AndroidManifest.xml → Merged Manifest

Look for:

com.google.firebase.provider.FirebaseInitProvider

Check for Accidental Provider Removal

Search for:

tools:node="remove"

or manifest rules that remove Firebase providers.

Important: Do not manually add FirebaseInitProvider as your first fix. Determine why normal manifest merging did not include it.

Cause 9: Firebase Is Being Used in a Secondary Process

Google’s FirebaseApp Android API documentation states that FirebaseApp initialization should occur only in the app’s main process and that Firebase use in other processes is not supported and may cause problems. :contentReference[oaicite:31]{index=31}

For example:

<service android:name=".RemoteService" android:process=":remote" />

Solution 9: Check android:process

Search AndroidManifest.xml for:

android:process

If a secondary process is unnecessary, removing process separation is the simplest solution.

Cause 10: Custom FirebaseOptions Are Incomplete

Applications that do not use google-services.json may initialize Firebase manually.

Solution 10: Supply Valid FirebaseOptions

val options = FirebaseOptions.Builder() .setApplicationId( "1:1234567890:android:abcdef" ) .setApiKey( "YOUR_API_KEY" ) .setProjectId( "your-project-id" ) .build()

FirebaseApp.initializeApp(
applicationContext,
options
)

For normal Android Firebase apps, using the downloaded Firebase configuration is usually easier and safer.

Cause 11: FirebaseApp.initializeApp Returns null

FirebaseApp.initializeApp(Context) loads the default Firebase options from Android resources generated from the Firebase configuration. :contentReference[oaicite:32]{index=32}

Solution 11: Check the Return Value

val firebaseApp = FirebaseApp.initializeApp(this)

if (firebaseApp == null) {
Log.e(
"Firebase",
"Firebase options could not be loaded"
)
}

If it returns null, inspect the generated Google Services resources.

Cause 12: Firebase Is Accessed Too Early

A globally initialized object may access Firebase before the expected application initialization flow completes.

object FirebaseManager { val auth = FirebaseAuth.getInstance() }

Solution 12: Resolve Firebase Lazily

class FirebaseManager {
val auth: FirebaseAuth
    get() =
        FirebaseAuth.getInstance()

}

Cause 13: The FirebaseApp Was Deleted

If code calls:

FirebaseApp.getInstance().delete()

the default app can no longer be used normally afterward.

Solution 13: Remove Unnecessary delete() Calls

Most Android applications do not need to manually delete the default FirebaseApp.

Cause 14: Only a Named FirebaseApp Exists

A multi-project setup might initialize:

FirebaseApp.initializeApp( context, options, "secondary" )

but later call:

FirebaseAuth.getInstance()

which expects the default app.

Solution 14: Use the Named FirebaseApp Explicitly

val app = FirebaseApp.getInstance("secondary")

val auth =
FirebaseAuth.getInstance(app)

Google’s FirebaseApp reference documents this pattern for applications connected to additional Firebase projects. :contentReference[oaicite:33]{index=33}

Cause 15: Google Services Processing Failed

If the JSON processing task fails, Firebase resources are not generated correctly.

Solution 15: Run the Google Services Task

For Debug:

./gradlew processDebugGoogleServices

Or run a normal build:

./gradlew assembleDebug

Windows:

gradlew.bat assembleDebug

Cause 16: Gradle Sync Has Not Completed

After changing plugins or dependencies, Android Studio may still use an outdated project model.

Solution 16: Run Gradle Sync

File → Sync Project with Gradle Files

Solution 17: Clean and Rebuild

macOS or Linux:

./gradlew clean ./gradlew assembleDebug

Windows:

gradlew.bat clean gradlew.bat assembleDebug

Check Logcat

Search for:

FirebaseApp FirebaseInitProvider Firebase

Look for a more specific message immediately before “FirebaseApp initialization unsuccessful.”

Verify FirebaseInitProvider

FirebaseInitProvider is the Firebase ContentProvider responsible for initializing Firebase APIs at app startup. Google’s API reference explicitly documents this role. :contentReference[oaicite:34]{index=34}

If the provider is present but initialization still fails, investigate generated Firebase options and resources.

Verify google_app_id

The generated resource:

google_app_id

is especially important.

Google’s plugin documentation states that it is generated from:

client_info/mobilesdk_app_id

inside google-services.json. :contentReference[oaicite:35]{index=35}

Do Not Manually Rewrite google-services.json

If the package or Firebase project is incorrect, register the correct Android app in Firebase and download a new configuration file.

Using Firebase Assistant

Android Studio’s Firebase Assistant can automate Firebase app registration and add the required configuration file, Gradle plugin, and dependencies.

Google’s Firebase documentation states that Firebase Assistant performs these setup tasks automatically. :contentReference[oaicite:36]{index=36}

Difference from “Default FirebaseApp is not initialized”

FirebaseApp initialization unsuccessful → Firebase tried to create the app but initialization failed

Default FirebaseApp is not initialized
→ A Firebase SDK was used
but no default FirebaseApp exists

Both messages can appear sequentially:

FirebaseApp initialization unsuccessful ↓ FirebaseAuth or another SDK is used ↓ Default FirebaseApp is not initialized

Difference from “google-services.json is missing”

google-services.json is missing → The build cannot find the JSON file

FirebaseApp initialization unsuccessful
→ Runtime FirebaseApp initialization failed

Difference from “No matching client found”

No matching client found → No JSON client matches the current package

FirebaseApp initialization unsuccessful
→ Runtime FirebaseApp creation failed

Can Google Play services Be the Cause?

Some Firebase products depend on Google Play services, but for default FirebaseApp initialization failures, first verify the Firebase configuration and generated resources.

Google’s current Firebase Cloud Messaging documentation also recommends checking that devices using Play Services-based functionality have a compatible Google Play services APK. :contentReference[oaicite:37]{index=37}

What About the Android Emulator?

For Firebase features that depend on Google Play services, use an emulator image that includes Google Play where appropriate.

However, if “FirebaseApp initialization unsuccessful” appears immediately at startup, configuration resources should be checked first.

Should You Manually Initialize Firebase?

Usually no.

Google’s FirebaseApp API reference says that FirebaseInitProvider automatically initializes the default FirebaseApp for the vast majority of Android applications. :contentReference[oaicite:38]{index=38}

Manual initialization is primarily for specialized setups.

Manual Initialization Example

class MyApplication : Application() {
override fun onCreate() {
    super.onCreate()

    val app =
        FirebaseApp.initializeApp(this)

    if (app == null) {
        Log.e(
            "Firebase",
            "Firebase initialization failed"
        )
    }
}

}

Manifest:

<application android:name=".MyApplication" ... >

Important: If manual initialization returns null, fix the Firebase resources instead of repeatedly calling initializeApp().

Fastest Troubleshooting Order

  1. Verify that google-services.json exists in the application module.
  2. Verify that the Google Services Gradle plugin is applied.
  3. Compare the application ID with the Firebase Android app package.
  4. Check the JSON for the currently selected build variant.
  5. Verify generated values such as google_app_id.
  6. Check that FirebaseInitProvider exists in the merged manifest.
  7. Verify Firebase SDK dependencies.
  8. Run Gradle Sync.
  9. Run ./gradlew clean assembleDebug.
  10. Read the Logcat messages immediately before the initialization failure.
  11. Check whether Firebase is being used from a secondary process.

If the Error Still Occurs

Check all of the following:

  • google-services.json is in the correct module.
  • The JSON belongs to the intended Firebase project.
  • The JSON package name matches the application ID.
  • The Google Services plugin is applied to the application module.
  • Debug, Release, and flavor-specific JSON files are correct.
  • google_app_id is generated.
  • FirebaseInitProvider exists in the merged manifest.
  • No manifest rule removes the provider.
  • The Firebase BoM and required Firebase SDKs are present.
  • Firebase is not being used from an unsupported secondary process.
  • Custom FirebaseOptions contain the required values.
  • The default FirebaseApp was not deleted.
  • Only a named secondary FirebaseApp was not created.
  • The Gradle build succeeds.
  • Logcat does not contain a more specific earlier error.

Summary

Android “FirebaseApp initialization unsuccessful” means that Firebase was unable to complete initialization of the FirebaseApp during application startup.

In a normal Android Firebase application, FirebaseInitProvider automatically initializes the default FirebaseApp. Google’s official FirebaseApp documentation states that this provider is merged into the manifest during the Gradle build and initializes Firebase using configuration derived from google-services.json. :contentReference[oaicite:39]{index=39}

The main configuration chain to verify is:

google-services.json + Google Services Gradle Plugin + generated Firebase resources + Firebase SDK dependencies + FirebaseInitProvider

If resources such as google_app_id are missing, the Google Services plugin probably did not process the Firebase configuration correctly. Google’s plugin documentation explains that it generates values such as Firebase App ID, API key, and project ID from google-services.json. :contentReference[oaicite:40]{index=40}

Google’s FirebaseApp API documentation also states that FirebaseApp initialization is intended for the application’s main process and that using Firebase from other processes is unsupported and likely to cause problems. If the error occurs only inside a Service or another component, inspect android:process. :contentReference[oaicite:41]{index=41}

In most applications, repeatedly calling FirebaseApp.initializeApp() is not the correct fix. Correct the automatic initialization configuration so Firebase can start normally.