After migration from Fabric to FirebaseCrashlytics tests failing

1k Views Asked by At

Recently we attempted to migrate from Fabric.io to FirebaseCrashlytics. Followed steps as described in documentation https://firebase.google.com/docs/crashlytics/upgrade-sdk?platform=android

  1. Updated google-service.json files
  2. Replaced fabric.io dependencies with Firebase Crashlytics
  3. Updated code and enabled collection only when prod builds with setCrashlyticsCollectionEnabled(!BuildConfig.DEBUG)
  4. Updated proguard rules

After that, we try to run our test suite when we noticed that it is taking much longer than usual and in the end it failed with many tests reporting OutOfMemoryError. This set of tests run just fine with Fabric dependencies. Does anybody had or run into a similar problem?

2

There are 2 best solutions below

2
peter_budo On BEST ANSWER

OK, I do have update on this. We just updated libraries to latest version that was recently published and issue looks to be sorted

  • com.google.firebase:firebase-crashlytics-gradle:2.2.0 instead of 2.1.0
  • com.google.firebase:firebase-crashlytics:17.1.0 instead of 17.0.0

which original article was published with

2
MertNYuksel On

Documentation says Fabric Crashlytics SDK uses a ContentProvider to initialize itself. So it is too late call setCrashlyticsCollectionEnabled function in your Application Code.

Fabric's API key is no longer used by the new SDK. Instead, Crashlytics now uses your app’s google-services.json file to associate your app with your Firebase project and retain your historic crash data. If you have an io.fabric.ApiKey declared in your AndroidManifest.xml file, remove it.

If you want to disable automatic crash reporting and enable it only for select users, use the Android meta-data tag in your AndroidManifest.xml file. Then, you can enable crash reporting using the new setCrashlyticsCollectionEnabled instance method.

https://firebase.google.com/docs/crashlytics/upgrade-sdk?platform=android#firebaseno_longer_works_with_the_fabric_sdk

So you need to disable data collection in your manifest. In order to do that you need to add firebase_crashlytics_collection_enabled meta-tag to your manifest.

<meta-data
    android:name="firebase_crashlytics_collection_enabled"
    android:value="false" />

https://github.com/firebase/firebase-android-sdk/blob/5440af41f0d15ff1358038dc31fcd1d4eac0a89c/firebase-crashlytics/src/main/java/com/google/firebase/crashlytics/internal/common/DataCollectionArbiter.java#L74

You might want to inject build variables to manifest file since you only want to disable Crashlytics in your test builds. See the link down below. https://developer.android.com/studio/build/manifest-build-variables.html