First you will have to create debug and release build variants and then set a variable with boolean value. Then you will need to get that value from your java file which extends application i.e from where you enable Fabric crash reporting.
A code example is given below.
In your app's build.gradle file, add the following lines to create 2 build variants debug and release and then add a variable with boolean value.
defaultConfig { buildConfigField 'boolean', 'ENABLE_ANALYTICS', 'true' } buildTypes { debug { applicationIdSuffix ".debug" versionNameSuffix 'DEBUG' buildConfigField 'boolean', 'ENABLE_ANALYTICS', 'false' } release { minifyEnabled false } }
Then when you are trying to add Fabric crash reporting check the value for ENABLE_ANALYTICS
public class Test extends Application {
private GoogleAnalytics googleAnalytics; private static Tracker tracker; @Override public void onCreate() { super.onCreate(); if (BuildConfig.ENABLE_ANALYTICS) Fabric.with(this, new Crashlytics()); } }
You can see the value for ENABLE_ANALYTICS by ctrl + click on the value. Hope this helps.
if (!development) { FirebaseCrash.report(e);}releaseCompile 'com.google.firebase:firebase-crash:9.8.0'won't this work? it is supposed to add the dependency only for your release builds, hence while developing the library won't be added to the project, right?