Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding Firebase Crashlytics either crash in runtime or fail unit test build

I'm trying to add Firebase Crashlytics to a new Android app (single module, no flavors). Since Crashlytics is missing from the IDE assistant plugin, I'm using setup steps from https://firebase.google.com/docs/crashlytics/get-started:

  • add gradle dependencies
  • download google-services.json and put it in the /app root

Crashlytics is initialized for release builds only like this:

class MyApplication: Application() {

  fun onCreate() {
    super.onCreate()
    Fabric.with(
        this,
        Crashlytics.Builder()
            .core(CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build())
            .build()
    )
  }
}

The problem #1: app crashes during initialization with

java.lang.RuntimeException: Unable to get provider com.crashlytics.android.CrashlyticsInitProvider: io.fabric.sdk.android.services.concurrency.UnmetDependencyException: 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.

Adding

<meta-data
  android:name="io.fabric.ApiKey"
  android:value="{blah-blah-key}" />

to AndroidManifest.xml fixes the issue (I'm seeing crashes in firebase console), but now I'm getting

Problem #2: running unit tests (gradle test) fails with

> Task :app:fabricGenerateResourcesRelease FAILED
ERROR - Crashlytics Developer Tools error.
java.lang.IllegalArgumentException: Crashlytics found an invalid API key: blah-blah-key

TL;DR - gradle fails to run unit tests if Fabric api key is present in manifest, app crashes in runtime if it's not present. I suspect that I'm doing something wrong, but not sure what exactly :(

like image 225
Mykhailo Gaidai Avatar asked Mar 06 '19 08:03

Mykhailo Gaidai


People also ask

How do I find out crashes in Firebase Crashlytics?

Open your app from the home screen of your test device or simulator. In your app, press the "Test Crash" button that you added using the code above. After your app crashes, run it again from Xcode so that your app can send the crash report to Firebase.

How do I stop Firebase from crashing?

To mark a cluster as closed, click the three dots on the far right of the row that appear when hovering over the row, then click "close cluster."

How do I disable Firebase Crashlytics in debug mode?

To opt out of automatic crash reporting, pass false as the override value. When set to false, the new value does not apply until the next run of the app. To disable the crash logs while in debug mode you must pass ! BuildConfig.

What is non-fatal and crashes in Crashlytics?

In addition to automatically reporting your app's crashes, Crashlytics lets you record non-fatal exceptions and sends them to you the next time your app launches. Note: Crashlytics only stores the most recent eight exceptions in a given app session.


2 Answers

I had a similar problem.

java.lang.RuntimeException: Unable to get provider com.crashlytics.android.CrashlyticsInitProvider: io.fabric.sdk.android.services.concurrency.UnmetDependencyException: 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.
        at android.app.ActivityThread.installProvider(ActivityThread.java:6288)

In my case it was because I forgot to add apply plugin: 'io.fabric' in /app/build.gradle

I did everything exactly according to the instructions and my application was able to send reports to Crashlytics. And I didn't add a io.fabric.ApiKey.

like image 187
Anatoly Samoylenko Avatar answered Oct 21 '22 05:10

Anatoly Samoylenko


Well in my case:

classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0-beta01'

was missing in project level build.gradle and

apply plugin: 'com.google.firebase.crashlytics'

was missing in the app-level build.gradle file

like image 26
Suraj Vaishnav Avatar answered Oct 21 '22 05:10

Suraj Vaishnav