I have encounter weird Firebase initialization problem on my application recently. I am using Android Studio Chipmunk(2021.2.1 Patch 1). Application can be build normally and installed to device on debug mode without any error but if you install an APK directly (or download from app distribution) app gets the error during app init.
My google-services.json file is under the src/ and its last recent version.
2022-06-08 23:57:44.570 13535-13535/com.example.app.debug E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.app.debug, PID: 13535
java.lang.RuntimeException: Unable to create application com.example.app.debug.commons.application.Application: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.example.app.debug. Make sure to call FirebaseApp.initializeApp(Context) first.
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6739)
at android.app.ActivityThread.access$1500(ActivityThread.java:256)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2090)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7842)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
Top level gradle plugin part:
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
id 'com.google.dagger.hilt.android' version '2.41' apply false
id 'com.google.gms.google-services' version '4.3.10' apply false
id 'com.google.firebase.crashlytics' version '2.9.0' apply false
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin' version '2.0.1' apply false
}
App level build.gradle :
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
id 'com.google.firebase.crashlytics'
id 'com.google.firebase.firebase-perf'
id 'org.jetbrains.kotlin.android'
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-parcelize'
id 'dagger.hilt.android.plugin'
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
}
CodePudding user response:
With the new gradle plugin and wrapper apk output directory and apk is different than each other. Looks like something is broken or not compatible with current google-services (v4.3.10) dependency
- (WORKING)gradle-wrapper 7.2, application&library 7.1.3 -> ./app/build/intermediates/apk/google/debug
- (GETS ERROR AT THE TOP)gradle-wrapper 7.3.3, application&library 7.2.1 -> ./app/build/outputs/apk/google/debug
Solution: Use working versions for wrapper and platform.
CodePudding user response:
You can try to disconnect the project from the Firebase and reconnect again the project to Firebase. In my case is like this, I have done it and it's successful in my Android project. Thank you.