3

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?

Pete Ythong
  • 305
  • 5
  • 13
peter_budo
  • 1,748
  • 4
  • 26
  • 48

2 Answers2

2

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

MertNYuksel
  • 311
  • 1
  • 8
  • Thank you @MertNYuksel sorry I failed to mention this in original post, I do have this meta data collection setup in manifest, also as you can see from snippet in post boolean is dependant on build config if it is debug or not. So I believe I followed docs correctly on that point – peter_budo May 28 '20 at 11:04
  • Well, We haven't updated our SDK yet. So I don't have any other ideas than checking your merged manifest or examining thread stack traces of running Java process with jstack command to find out the culprit. – MertNYuksel May 28 '20 at 14:29
0

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

peter_budo
  • 1,748
  • 4
  • 26
  • 48
  • 2
    I tried this but didn't work for me. I am using RXJava and onError I am calling `FirebaseCrashlytis.getInstance().recordExeption(throwable)` and here it fails. – rupesh Jun 24 '20 at 14:12
  • @rupesh then your problem is different from my. In my case project compiled fine, however when unit testing included build would fail somewhere along the test path with OutOfMemory. In your case you are attempting in code to handle error scenario through RxJava and if that happen record exception in Firebase. You better create new post, add bit of details of what you doing in the code and what error or crash you having with any logs attached – peter_budo Jun 25 '20 at 15:15