Crash reports

Bugsee automatically intercepts uncaught exceptions and sends crash reports on app restart.

Proguard

When proguard is used, crash reports are likely to have obfuscated parts in them. In order to process them a matching mapping.txt has to be uploaded to Bugsee servers. The mapping can be uploaded manually at any time, but Bugsee also provides a special mechanism to upload mapping files automatically at build time using a gradle plugin:

  • Add the following code to your build.gradle to initiate Bugsee gradle plugin when appropriate:
buildscript { // This block is in your project's or app module's build.gradle file
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0'

        // Add Bugsee plugin as a dependency
        classpath 'com.bugsee:bugsee-android-gradle-plugin:1+' 
    }
}

// This line is already in your app/feature module's build.gradle file
apply plugin: 'com.android.application' // Or 'com.android.feature'

// Activate Bugsee plugin
apply plugin: 'bugsee' 

Application token is required to associate the uploaded mapping file with the right application. If you have the single app token for all build variants, you might add the following section to the app/feature module's build.gradle file

bugsee {
    appToken '<your_app_token>'
}

But if you have several app tokens for different build variants, you can provide Bugsee plugin with closure

import com.android.build.gradle.api.BaseVariant;

bugsee {
    appToken { BaseVariant variant ->
        switch (variant.buildType.name) { // Check build type or any other condition based on a given BaseVariant.
            case 'release': '<release app token>'
                break
            case 'qa': '<qa app token>'
                break
        }
    }
}

Proguard optimization

If you enable Proguard optimization by, for example, adding 'proguard-android-optimize.txt' to proguardFiles list, it is necessary to add the following Proguard rule:

-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*,!code/allocation/variable 

First part is taken from standard 'proguard-android-optimize.txt' file and last part '!code/allocation/variable' is added in order to compile with Bugsee.

Special cases

If you use other libraries, which intercept uncaught exceptions, Bugsee.launch() method should be called after all these libraries are initialized. When uncaught exceptions occurs, Bugsee will inform these libraries about exception.

If you set uncaught exceptions handler in your app using Thread.setDefaultUncaughtExceptionHandler() method after calling Bugsee.launch(), you should call Bugsee.onUncaughtException() method from your handler:

Thread.setDefaultUncaughtExceptionHandler(mExceptionHandler);
//...
private final Thread.UncaughtExceptionHandler mExceptionHandler = new Thread.UncaughtExceptionHandler() {
        @Override
        public void uncaughtException(Thread thread, Throwable ex) {
            Bugsee.onUncaughtException(thread, ex);

            // App specific exception handling.
            System.exit(1);
        }
    };