firebase / firebase-android-sdk

Firebase Android SDK
https://firebase.google.com
Apache License 2.0
2.27k stars 575 forks source link

Do not initialized Crashlytics in unit/instrumented tests #2595

Open ekselys opened 3 years ago

ekselys commented 3 years ago

What feature would you like to see?

A way to avoid Crahlytics initialization on unit/instrumented tests. This could be very helpful whenever the crashlytics library is used to across multiple modules (like library modules), avoiding errors like Caused by: java.lang.IllegalStateException: The Crashlytics build ID is missing. This occurs when Crashlytics tooling is absent from your app's build configuration. Please review Crashlytics onboarding instructions and ensure you have a valid Crashlytics account.

How would you use it?

val options = FirebaseOptions.Builder()
            .setApiKey("fake key")
            .setApplicationId("fake app")
            .setProjectId("project id")
            .forTest(true) // do whatever is needed in order to make firebase work in unit/instrumented test 
            // or
            .excludeCrashlytics() // do not include crashlytics on firebase app initialization
            .build()

Firebase.initialize(InstrumentationRegistry.getInstrumentation().context, options)
google-oss-bot commented 3 years ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.