Is there any simple way to turn Crashlytics Android SDK off while developing ?
I don\'t want it to send a crash every time I do something stupid
On the othe
A strange problem that I encountered: I followed xialin's answer (which also appears on the official website) and it didn't work. Turned out that I was referencing BuildConfig
in Fabric's package which also contains a static DEBUG variable that was set to false even in debug mode.
So, if you follow the aforementioned solution and you still get debug reports, make sure that you're referencing this:
import com.yourpackagename.BuildConfig;
And not this:
import io.fabric.sdk.android.BuildConfig;
I found the solution from Crashlytics (with Fabric integration)
Put following code inside your Application class onCreate()
Crashlytics crashlytics = new Crashlytics.Builder().disabled(BuildConfig.DEBUG).build();
Fabric.with(this, crashlytics);
EDIT:
In Crashalitics 2.3 and above, this is deprecated. The correct code is:
CrashlyticsCore core = new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build();
Fabric.with(this, new Crashlytics.Builder().core(core).build());
or
Fabric.with(this, new Crashlytics.Builder().core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build()).build());
(copied from Crashlytics deprecated method disabled())
EDIT2:
You can also optionally add this to your buildType
in gradle. This command disables sending the crashlytics mapping file and generating an ID for each build, which speeds up gradle builds of those flavors. (It doesn't disable Crashlytics at run time.) See Mike B's answer here.
buildTypes {
release {
....
}
debug {
ext.enableCrashlytics = false
}
}
If you want to capture all crashes (for debug and release builds) but want to separate them in the Crashlytics Dashboard, you can add this line of code to build.gradle:
debug {
versionNameSuffix "-DEBUG"
}
For example, if your app's versionName is 1.0.0, your release builds will be tagged as 1.0.0 while debug builds will be 1.0.0-DEBUG
Use flavors or build configs. Use a separate build identifier for dev build and all your crashes will keep going to a separate app. Can come handy in case of sharing the build with peers or using it without a debugger. Something like this -
productFlavors {
dev {
applicationId "io.yourapp.developement"
}
staging {
applicationId "io.yourapp.staging"
}
production {
applicationId "io.yourapp.app"
}
Marc from Crashlytics here. Here's a couple of ways to disable Crashlytics while you are doing your debug builds!
Use a different android:versionString for debug and release builds and then disable crash reporting from the Crashlytics web dashboard for the debug version.
Wrap the call to Crashlytics.start() in an if statement that checks a debug flag. You could use either a custom flag or an approach like the ones proposed here: How to check if APK is signed or "debug build"?
There are two options in order to disable Firebase Crashlytics for the following version com.google.firebase:firebase-crashlytics:17.0.0:
<meta-data android:name="firebase_crashlytics_collection_enabled" android:value="false" />
OR
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(true)