Skip to content

NullPointerException: FirebaseCrashlytics component is not present. #5075

Description

@tprochazka
  • Firebase Component: Crashlytics 18.3.2, Common: 20.2.0
  • Android 13 only!
Exception java.lang.NullPointerException: FirebaseCrashlytics component is not present.
  at com.google.firebase.crashlytics.FirebaseCrashlytics.getInstance (FirebaseCrashlytics.java:186)
  at com.avast.android.logging.crashlytics.CrashlyticsAlfLogger.logMessage (CrashlyticsAlfLogger.kt:29)

This happen to us based on Google Play reports about 30-50 users per day.
On the line 29 is just this FirebaseCrashlytics.getInstance().log(logMessage)

We even call FirebaseApp.initializeApp(applicationContext) in the Application class.

I found that FirebaseApp do this in the constructor

    componentRuntime =
        ComponentRuntime.builder(UI_EXECUTOR)
            .addLazyComponentRegistrars(registrars)
            .addComponentRegistrar(new FirebaseCommonRegistrar())
            .addComponent(Component.of(applicationContext, Context.class))
            .addComponent(Component.of(this, FirebaseApp.class))
            .addComponent(Component.of(options, FirebaseOptions.class))
            .setProcessor(new ComponentMonitor())
            .build();

It uses UI_EXECUTOR, but it not running this component setup immediately in the constructor, right? So it means that when I run something on a background thread that will call FirebaseCrashlytics.getInstance() it can happen that it will be executed before this constructor initialization which can lead to this error right?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions