Code Monkey home page Code Monkey logo

android-api-bugsnag-gradle-plugin's Introduction

Bugsnag Android Gradle Plugin

Gradle plugin to automatically upload ProGuard mapping files to Bugsnag.

Bugsnag for Android automatically detects crashes in your Android apps, collecting diagnostic information and immediately notifying your development team.

Create a free account to start capturing exceptions from your applications.

If you aren't using Gradle or need more manual control, see the API docs for alternative ways to use Bugsnag with Proguard.

Contents

Getting Started

Installation

Using the Gradle Plugin Portal (Gradle 2.1+)

Add the plugin to the plugins section at the top of your Module-level Gradle Settings, at <project dir>/<module name>/build.gradle (usually <project_dir>/app/build.gradle):

plugins {
    id "com.bugsnag.android.gradle" version "2.3.2"
}

Using other source repositories

Add this plugin as a dependency in your main Project Gradle Settings, at <project_dir>/build.gradle:

buildscript {
    dependencies {
        // Add this line to your `dependencies` section
        classpath 'com.bugsnag:bugsnag-android-gradle-plugin:2.3.2'
    }
}

You'll then need to "apply" the plugin by adding the following line to the top of your Module Gradle Settings, at <project_dir>/<module_name>/build.gradle (usually <project_dir>/app/build.gradle).

apply plugin: 'com.bugsnag.android.gradle'

Configuration

In most situations, the basic installation steps above will suffice, but you can manually configure further settings as follows:

API Key

By default this plugin will read your API key from your manifest. You should ensure that you have the following code in AndroidManifest.xml.

<application ...>
    <meta-data android:name="com.bugsnag.android.API_KEY" android:value="your-api-key-here"/>
</application>

Alternatively, you can set your API key in your app's build.gradle as follows:

bugsnag {
    apiKey 'your-api-key-here'
}

Automatic Upload

By default, this plugin will automatically upload the proguard mapping file generated for every build, if you'd prefer to disable this automatic uploading, set the autoUpload property in your app's build.gradle:

bugsnag {
    autoUpload false
}

If you disable automatic uploading, you can still run the upload task manually, with the uploadBugsnagVariantMapping task:

./gradlew clean package uploadBugsnagReleaseMapping

Automatic Proguard Config

In order for Bugsnag to de-duplicate errors correctly it needs to know the file and line number for every crash. Proguard strips this information by default, so we'll automatically add the following line into your Proguard configuation to avoid this:

-keepattributes SourceFile,LineNumberTable
-keep class com.bugsnag.android.NativeInterface { *; }
-keep class com.bugsnag.android.Breadcrumbs { *; }
-keep class com.bugsnag.android.Breadcrumbs$Breadcrumb { *; }
-keep class com.bugsnag.android.BreadcrumbType { *; }
-keep class com.bugsnag.android.Severity { *; }
-keep class com.bugsnag.android.ndk.BugsnagObserver { *; }

If you'd prefer to add this into your Proguard configuration yourself, you can disable our automatic configuration in your app's build.gradle as follows:

bugsnag {
    autoProguardConfig false
}

Custom Endpoints

By default, we'll upload mapping files to upload.bugsnag.com, if you are using Bugsnag Enterprise, you can configure your upload endpoint in your app's build.gradle as follows:

bugsnag {
    endpoint 'http://upload.bugsnag.example.com'
}

Disabling Bugsnag

To completely disable the Bugsnag plugin, use the extension property enableBugsnag, for example:

android {
    buildTypes {
        debug {
            ext.enableBugsnag = false
        }
    }
}

NDK Support

Bugsnag supports uploading NDK shared object symbol mappings as well as ProGuard mappings. If you are using the Native Development Kit, enable symbol upload as follows:

bugsnag {
  ndk true
}

Overwrite mapping file

To overwrite a mapping file, you can set the overwrite property as follows:

bugsnag {
    overwrite false
}

You can also declare this inside a product flavor. Conflicting values (between multiple flavors or a flavor and a build-type) are ignored and the plugin will be disabled if false was set anywhere.

You may want to do this to speed up build types or flavors where you don't require Bugsnag's functionality. Bugsnag's generation of a UUID for each build into your manifest (see Build UUIDs) causes the resources task to be run for each build, introducing a small delay if your build's changes don't involve resources.

Retrying the file upload

To enable retrying the file upload, set the retryCount property:

bugsnag {
    retryCount 5
}

Build UUIDs

This plugin automatically generates a UUID for each build (excluding Instant Run builds, which is inserted into your AndroidManifest.xml during the build process. This UUID is used to uniquely identify each build, along with your appId and versionCode, to help us determine which proguard mapping file to use with each crash report.

This UUID is available as com.bugsnag.BUILD_UUID in a meta-data element in case you'd like to use yourself it in your applications.

Support

Contributing

We'd love your contributions! For information on how to build, test and release this plugin, see our contributing guide.

License

This plugin is free software released under the MIT License. See LICENSE.txt for details.

android-api-bugsnag-gradle-plugin's People

Contributors

conradirwin avatar fcduarte avatar kattrali avatar kpinedok avatar loopj avatar pezzah avatar snmaynard avatar tmelz avatar zlate87 avatar

Watchers

 avatar

Forkers

martofeld

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.