Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fabric's Crashlytics with Firebase can't be disabled for DEBUG builds

I have an app that utilises Fabric's Crashlytics via Firebase. The following is the first thing executed in my Applications onCreate

CrashlyticsCore crashlyticsCore = new CrashlyticsCore.Builder()     .disabled(BuildConfig.DEBUG)     .build(); Fabric.with(this, new Crashlytics.Builder().core(crashlyticsCore).build()); 

Nonetheless, the crashes are submitted in DEBUG == true mode.

I use the following versions

in my build.gradle classpath "io.fabric.tools:gradle:1.25.1"

in my app/build.gradle implementation "com.crashlytics.sdk.android:crashlytics:2.9.1"

Unfortunately the crashes still get reported. Any ideas, what I am doing wrong?

like image 967
peshkira Avatar asked Mar 28 '18 07:03

peshkira


People also ask

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.

How do I debug Crashlytics?

Enable debug logging for CrashlyticsSelect Run from the left menu, then select the Arguments tab. In the Arguments Passed on Launch section, add -FIRDebugEnabled .

How do I turn on Firebase Crashlytics?

Implementation path. Start by adding Firebase to your app in the Firebase console. Add the Crashlytics SDK via CocoaPods, Gradle, or Pub, and Crashlytics starts collecting reports. Visit the Firebase console to track, prioritize, and fix issues in your app.


1 Answers

Correct answers have been posted by Bob Snyder and niqueco already however it seems kinda tedious to change the meta-data value every time you are building an actual release APK thus here's a solution that uses so called manifestPlaceholder and changes the value automatically to trueor false depending on the buildType.

Add the following to your apps build.gradle

android {      // ...      buildTypes {         debug {             manifestPlaceholders = [enableCrashReporting:"false"]         }         release {             manifestPlaceholders = [enableCrashReporting:"true"]         }     }  } 

And this to your AndroidManifest.xml

<manifest ... >      <application ...>          // ...          <meta-data android:name="firebase_crashlytics_collection_enabled" android:value="${enableCrashReporting}" />      </application>  </manifest> 

You can verify the current value by clicking on the Merged Manifest tab once you have opened the AndroidManifest.xml. You should see something like this:

Merged manifest meta-data value for crash reporting

like image 57
reVerse Avatar answered Sep 22 '22 03:09

reVerse