Skip to content

Problem with com.google.gms:google-services:4.1.0 #1445

Closed
@MacNakrub

Description

@MacNakrub

Step 1: Are you in the right place?

Maybe.

Step 2: Describe your environment

  • Android device: Emulator
  • Android OS version: O
  • Google Play Services version: 4.1.0
  • Firebase/Play Services SDK version:
    implementation 'com.google.firebase:firebase-core:16.0.3'
    implementation 'com.google.firebase:firebase-auth:16.0.3'
    implementation 'com.google.firebase:firebase-perf:16.1.0'
    implementation 'com.google.firebase:firebase-database:16.0.2'
    implementation 'com.google.firebase:firebase-firestore:17.1.0'
    implementation 'com.google.firebase:firebase-invites:16.0.3'
    implementation 'com.google.firebase:firebase-messaging:17.3.1'

    implementation 'com.google.android.gms:play-services-auth:16.0.0'
    implementation 'com.google.android.gms:play-services-maps:15.0.1'
    implementation 'com.google.android.gms:play-services-vision:15.0.2'
  • FirebaseUI version: both 4.1.0 and 4.2.0
   implementation "com.firebaseui:firebase-ui-auth:4.2.0"
   implementation "com.firebaseui:firebase-ui-storage:4.2.0"

Step 3: Describe the problem:

When change the version of com.google.gms:google-services from 4.0.x to 4.1.0

Steps to reproduce:

  1. Start app with google-services version 4.0.2. It's working fine.
  2. Change google-services version 4.1.0, sync and run
  3. Crash
  4. Adding FirebaseApp.initializeApp(applicationContext) won't help

Observed Results:

2018-09-13 17:49:12.515 27842-27842/xxx.xxxxxxx E/AndroidRuntime: FATAL EXCEPTION: main
    Process: xxx.xxxxxxx, PID: 27842
    java.lang.RuntimeException: Unable to create application xxx.xxxxxxx.MainApplication: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process xxx.xxxxxxx. Make sure to call FirebaseApp.initializeApp(Context) first.
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5743)
        at android.app.ActivityThread.-wrap1(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
     Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process xxx.xxxxxxx. Make sure to call FirebaseApp.initializeApp(Context) first.
        at com.google.firebase.FirebaseApp.getInstance(com.google.firebase:firebase-common@@16.0.2:240)
        at com.google.firebase.firestore.FirebaseFirestore.getInstance(com.google.firebase:firebase-firestore@@17.0.5:49)
        at xxx.xxxxxxx.MainApplication.onCreate(MainApplication.kt:57)
        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1119)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5740)
        at android.app.ActivityThread.-wrap1(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:164) 
        at android.app.ActivityThread.main(ActivityThread.java:6494) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 

Expected Results:

App won't crash and start normally

Relevant Code:

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

     // Adding `FirebaseApp.initializeApp(applicationContext)` here won't help
      val settings = FirebaseFirestoreSettings.Builder()
              .setTimestampsInSnapshotsEnabled(true)
              .build()
      val firestore = FirebaseFirestore.getInstance()
      firestore.firestoreSettings = settings
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions