How to disable Crashlytics during development

后端 未结 28 2556
心在旅途
心在旅途 2020-11-29 15:42

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

28条回答
  •  [愿得一人]
    2020-11-29 16:05

    1. Add this to your app’s build.gradle:

      android {
          buildTypes {
              debug {
                // Disable fabric build ID generation for debug builds
                ext.enableCrashlytics = false
                ...
      
    2. 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);
      
    3. In AndroidManifest.xml, add

      
      

提交回复
热议问题