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
This is silly answer, I know
Just comment out Fabric.with(this, new Crashlytics());
, work on that and uncomment it when you want to release it.
Check out the latest doc. https://docs.fabric.io/android/crashlytics/build-tools.html#gradle-advanced-setup.
Apart from adding ext.enableCrashlytics = false
in build.grade you need to do,
Crashlytics crashlyticsKit = new Crashlytics.Builder()
.core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build())
.build();
// Initialize Fabric with the debug-disabled crashlytics.
Fabric.with(this, crashlyticsKit);
Another simple solution that I like, because it doesn't require different manifest files:
Step 1 - define manifest placeholders in build.gradle
android {
...
buildTypes {
release {
manifestPlaceholders = [crashlytics:"true"]
}
debug {
manifestPlaceholders = [crashlytics:"false"]
}
}
...
}
Step 2 - use them in your AndroidManifest.xml
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="${crashlytics}" />
You can use a dedicated manifest file for debug mode (works for me with Crashlytics 2.9.7):
Create the file app/src/debug/AndroidManifest.xml
and add the following:
<application>
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="false"/>
</application>
Note that this meta-data element must be put into debug/AndroidManifest.xml only, and not into the regular AndroidManifest.xml
The solution which uses CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build()
did not work for me, and I found out that crashlytics is initialized by the CrashlyticsInitProvider before Application.onCreate() is called or an any activity is started, which means that manually initializing fabric in the application or an activity has no effect because fabric is already initialized.
Up to date easiest version when using Gradle to build:
if (!BuildConfig.DEBUG) {
Fabric.with(this, new Crashlytics());
}
It uses the new Built-In Syntax from Fabric for Crashlytics and works automatically with the a Gradle build.
Add this to your app’s build.gradle:
android {
buildTypes {
debug {
// Disable fabric build ID generation for debug builds
ext.enableCrashlytics = false
...
Disable the Crashlytics kit at runtime. Otherwise, the Crashlytics kit will throw the error:
// Set up Crashlytics, disabled for debug builds
// Add These lines in your app Application class onCreate method
Crashlytics crashlyticsKit = new Crashlytics.Builder()
.core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build())
.build();
// Initialize Fabric with the debug-disabled crashlytics.
Fabric.with(this, crashlyticsKit);
In AndroidManifest.xml, add
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="false" />