How to disable Crashlytics during development

后端 未结 28 2460
心在旅途
心在旅途 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:07

    This work for me:

        releaseCompile  'com.crashlytics.sdk.android:crashlytics:2.9.9'
    

    and in buildTypes:

    debug {
    ext.enableCrashlytics = false
    }
    
    0 讨论(0)
  • 2020-11-29 16:09

    If you want a debuggable release build, here's the way:

    buildTypes {
        release {
            signingConfig signingConfigs.config
            debuggable true //-> debuggable release build
            minifyEnabled true
            multiDexEnabled false
            ext.enableCrashlytics = true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            buildConfigField 'boolean', 'BUILD_TYPE_DEBUG', 'false'
        }
        debug {
            minifyEnabled false
            multiDexEnabled true
            ext.enableCrashlytics = false
            ext.alwaysUpdateBuildId = false
            // Disable fabric build ID generation for debug builds
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            buildConfigField 'boolean', 'BUILD_TYPE_DEBUG', 'true'
        }
    }
    

    When you set debuggable true your BuildConfig.DEBUG will initialized with true, that's why I added that variable in BuildConfig class.

    Init Fabric:

    Crashlytics crashlytics = new Crashlytics.Builder()
                // disable crash reporting in debug build types with custom build type variable
                .core(new CrashlyticsCore.Builder().disabled(BuildConfig.BUILD_TYPE_DEBUG).build())
                .build();
    
        final Fabric fabric = new Fabric.Builder(this)
                .kits(crashlytics)
                //enable debugging with debuggable flag in build type 
                .debuggable(BuildConfig.DEBUG)
                .build();
    
        // Initialize Fabric with the debug-disabled crashlytics.
        Fabric.with(fabric);
    
    0 讨论(0)
  • 2020-11-29 16:09

    Another way if you only want to do it on your IDE is to logout of the plugin. Apparently it will stop sending reports while you're generating builds without logging in again.

    0 讨论(0)
  • 2020-11-29 16:10

    There are plenty of good answers here, but for my testing I use debug builds for in-house betas and out-of-the-lab testing where crash logs are still very useful and I would still like to report them. Like the OP, all I wanted was to disable them during active development where I am often causing and quickly resolving crashes.

    Rather than remove ALL debug crashes you can choose to only disable the reports while a device is connected to your development machine with the following code.

    if (!Debug.isDebuggerConnected()) {
        Fabric.with(this, new Crashlytics());
    }
    
    0 讨论(0)
提交回复
热议问题