├── .editorconfig ├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE.txt ├── Makefile ├── README.md ├── UPGRADING.md ├── build.gradle ├── example ├── build.gradle ├── proguard.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── bugsnag │ │ └── android │ │ ├── example │ │ └── ExampleActivity.java │ │ └── other │ │ └── Other.java │ └── res │ ├── drawable-xhdpi │ └── ic_launcher.png │ └── layout │ └── main.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src ├── androidTest ├── AndroidManifest.xml └── java │ └── com │ └── bugsnag │ └── android │ ├── AppDataTest.java │ ├── AppStateTest.java │ ├── BeforeNotifyTest.java │ ├── BreadcrumbsTest.java │ ├── BugsnagTestCase.java │ ├── ClientTest.java │ ├── ConfigurationTest.java │ ├── DeviceDataTest.java │ ├── DeviceStateTest.java │ ├── ErrorTest.java │ ├── ExceptionHandlerTest.java │ ├── ExceptionsTest.java │ ├── JsonStreamTest.java │ ├── MetaDataTest.java │ ├── ReportTest.java │ └── StacktraceTest.java └── main ├── AndroidManifest.xml └── java └── com └── bugsnag └── android ├── AppData.java ├── AppState.java ├── Async.java ├── BeforeNotify.java ├── BreadcrumbType.java ├── Breadcrumbs.java ├── Bugsnag.java ├── BugsnagException.java ├── Callback.java ├── Client.java ├── Configuration.java ├── DateUtils.java ├── DeviceData.java ├── DeviceState.java ├── Error.java ├── ErrorStore.java ├── ExceptionHandler.java ├── Exceptions.java ├── HttpClient.java ├── IOUtils.java ├── JsonStream.java ├── JsonWriter.java ├── Logger.java ├── MetaData.java ├── NativeInterface.java ├── Notifier.java ├── NotifyType.java ├── Report.java ├── Severity.java ├── Stacktrace.java ├── ThreadState.java └── User.java /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 4 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | 15 | [*.xml] 16 | indent_size = 2 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io 2 | 3 | ### Android ### 4 | # Built application files 5 | *.apk 6 | *.ap_ 7 | 8 | # Files for the Dalvik VM 9 | *.dex 10 | 11 | # Java class files 12 | *.class 13 | 14 | # Generated files 15 | bin/ 16 | gen/ 17 | 18 | # Gradle files 19 | .gradle/ 20 | build/ 21 | 22 | # Local configuration file (sdk path, etc) 23 | local.properties 24 | 25 | # Proguard folder generated by Eclipse 26 | proguard/ 27 | 28 | # Log Files 29 | *.log 30 | 31 | # Android Studio # 32 | .idea 33 | *.iml 34 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | 3 | android: 4 | components: 5 | - tools 6 | - platform-tools 7 | - build-tools-23.0.1 8 | - build-tools-25.0.2 9 | - android-4 10 | - android-10 11 | - android-19 12 | - android-23 13 | - android-25 14 | - extra-android-m2repository 15 | 16 | env: 17 | matrix: 18 | - ANDROID_TARGET=android-4 ANDROID_ABI=armeabi 19 | - ANDROID_TARGET=android-10 ANDROID_ABI=armeabi 20 | - ANDROID_TARGET=android-19 ANDROID_ABI=armeabi-v7a 21 | 22 | before_script: 23 | # Create and start emulator 24 | - jdk_switcher use oraclejdk8 25 | - echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI 26 | - emulator -avd test -no-skin -no-audio -no-window & 27 | - adb wait-for-device 28 | - while [[ `adb shell pm path android` == 'Error'* ]]; do sleep 2; done 29 | - adb shell input keyevent 82 & 30 | 31 | script: ./gradlew --info connectedAndroidTest 32 | 33 | sudo: false 34 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 3.8.0 (2017-01-27) 4 | 5 | ## Enhancements 6 | 7 | * Add support for interfacing with native code 8 | 9 | ## 3.7.2 (2017-01-12) 10 | 11 | * Cache unhandled exception reports prior to sending, send non-blocking 12 | [Delisa Mason](https://github.com/kattrali) 13 | [#139](https://github.com/bugsnag/bugsnag-android/pull/139) 14 | 15 | ## 3.7.1 (2016-12-21) 16 | 17 | ### Bug fixes 18 | 19 | * Make `getContext` and `clearUser` static methods 20 | [Dave Perryman](https://github.com/Pezzah) 21 | [#132](https://github.com/bugsnag/bugsnag-android/pull/132) 22 | 23 | * Ensure fatal crashes are sent as blocking requests 24 | [Simon Maynard](https://github.com/snmaynard) 25 | [#137](https://github.com/bugsnag/bugsnag-android/pull/137) 26 | 27 | ## 3.7.0 (2016-10-05) 28 | 29 | ### Enhancements 30 | 31 | - Add support for sending reports using lambdas for customization 32 | [Delisa Mason](https://github.com/kattrali) 33 | [#123](https://github.com/bugsnag/bugsnag-android/pull/123) 34 | 35 | ## 3.6.0 (2016-09-09) 36 | 37 | ### Enhancements 38 | 39 | - Support optionally persisting user information between sessions using the 40 | configuration option `persistUserBetweenSessions` 41 | [Dave Perryman](https://github.com/Pezzah) 42 | [#120](https://github.com/bugsnag/bugsnag-android/pull/120) 43 | 44 | - Support initializing Bugsnag with a pre-configured Configuration instance 45 | [Dave Perryman](https://github.com/Pezzah) 46 | [#121](https://github.com/bugsnag/bugsnag-android/pull/121) 47 | 48 | - Expose client context 49 | [nicous](https://github.com/nicous) 50 | [#112](https://github.com/bugsnag/bugsnag-android/pull/112) 51 | 52 | - Add CPU/ABI information to device metadata 53 | [Dave Perryman](https://github.com/Pezzah) 54 | [Crossle Song](https://github.com/crossle) 55 | [#119](https://github.com/bugsnag/bugsnag-android/pull/119) 56 | 57 | ### Bug Fixes 58 | 59 | - Fix potentially misdirected error report when changing the endpoint soon 60 | after initializing Bugsnag 61 | [Dave Perryman](https://github.com/Pezzah) 62 | [#121](https://github.com/bugsnag/bugsnag-android/pull/121) 63 | 64 | - Fix missing static modifier on `disableExceptionHandler` 65 | [Niklas Klein](https://github.com/Taig) 66 | [#113](https://github.com/bugsnag/bugsnag-android/pull/113) 67 | 68 | ## 3.5.0 (2016-07-21) 69 | 70 | ### Enhancements 71 | 72 | - Add access to new Breadcrumbs API 73 | [Delisa Mason](https://github.com/kattrali) 74 | [#111](https://github.com/bugsnag/bugsnag-android/pull/111) 75 | 76 | 77 | ## 3.4.0 (2016-03-09) 78 | 79 | ### Enhancements 80 | 81 | - Limit the number of stored errors 82 | [Duncan Hewett](https://github.com/duncanhewett) 83 | [#97](https://github.com/bugsnag/bugsnag-android/pull/97) 84 | 85 | ### Bug Fixes 86 | 87 | - Fix `ConcurrentModificationException` which could occur when saving 88 | breadcrumbs 89 | [Duncan Hewett](https://github.com/duncanhewett) 90 | [#98](https://github.com/bugsnag/bugsnag-android/pull/98) 91 | 92 | - Localize all numbers in error metrics 93 | [Delisa Mason](https://github.com/kattrali) 94 | [#100](https://github.com/bugsnag/bugsnag-android/pull/100) 95 | 96 | 3.3.0 (2016-01-18) 97 | ----- 98 | 99 | ### Enhancements 100 | 101 | - Change distribution method to be .aar only 102 | [Lars Grefer](https://github.com/larsgrefer) 103 | [#91](https://github.com/bugsnag/bugsnag-android/pull/91) 104 | 105 | - Skip sending empty device data values 106 | [Matthias Urhahn](https://github.com/d4rken) 107 | [#96](https://github.com/bugsnag/bugsnag-android/pull/96) 108 | 109 | - Remove the need for synthetic methods 110 | [Jake Wharton](https://github.com/JakeWharton) 111 | [#87](https://github.com/bugsnag/bugsnag-android/pull/87) 112 | 113 | 3.2.7 (2015-12-10) 114 | ----- 115 | 116 | ### Enhancements 117 | 118 | - Add additional check to ensure the cache of uploaded errors are deleted 119 | [#80](https://github.com/bugsnag/bugsnag-android/issues/80) 120 | 121 | ### Bug Fixes 122 | 123 | - Fix exception which occurs when `appContext.getResources()` is null 124 | [#78](https://github.com/bugsnag/bugsnag-android/issues/78) 125 | 126 | - Fix bug preventing `maxBreadcrumbs` from being set 127 | [David Wu](https://github.com/wuman) 128 | [#70](https://github.com/bugsnag/bugsnag-android/pull/70) 129 | 130 | 3.2.6 131 | ----- 132 | - Add blocking API 133 | - Fix NPE issue 134 | - Concurrent adding to tabs 135 | - Thread Safe DateUtils#toISO8601 136 | 137 | 3.2.5 138 | ----- 139 | - Silence harmless proguard warning 140 | 141 | 3.2.4 142 | ----- 143 | - Support buildUUID to distinguish between multiple builds with the same appId and versionCode 144 | 145 | 3.2.3 146 | ----- 147 | - Support projectPackages when proguard is used. 148 | - Fix jailbroken % on Bugsnag dashboard. 149 | 150 | 3.2.2 151 | ----- 152 | - Prefer API keys passed to Client directly over those from AndroidManifest 153 | 154 | 3.2.1 155 | ----- 156 | - Fix NPE when unboxing in JsonStream (thanks @mattprecious) 157 | 158 | 3.2.0 159 | ----- 160 | - Allow setting Bugsnag API key in your AndroidManifest.xml 161 | 162 | 3.1.1 163 | ----- 164 | - Re-add `Error#getException` to allow access to exception in callbacks 165 | 166 | 3.1.0 167 | ----- 168 | - Add support for leaving developer-defined log messages called "breadcrumbs" 169 | to help understand what was happening in your application before each 170 | crash 171 | 172 | 3.0.0 173 | ----- 174 | - Removed dependency on `bugsnag-java` 175 | - Reduced memory usage, using lazy-loading and streaming 176 | - Easier "top activity" tracking 177 | - Device brand information is now collected (eg. "Samsung") 178 | - SSL enabled by default 179 | - Adding custom diagnostics (MetaData) is now easier to use 180 | - Fixed app name detection 181 | - Uses Android's new build system (gradle based) 182 | - Added unit tests, automatically run on travis.ci 183 | - Severity is now an Enum for type-safety 184 | 185 | 2.2.3 186 | ----- 187 | - Bump bugsnag-java dependency to fix prototype mismatch bug 188 | 189 | 2.2.2 190 | ----- 191 | - Add support for collecting thread-state information (enabled by default) 192 | 193 | 2.2.1 194 | ----- 195 | - Add support for beforeNotify callbacks 196 | - Allow disabling of automatic exception handler 197 | 198 | 2.2.0 199 | ----- 200 | - Add support for sending a custom app version with `setAppVersion` 201 | - Send both `versionName` and `versionCode` in the app tab 202 | 203 | 2.1.3 204 | ----- 205 | - Fix strictmode violation caused by hostname checking 206 | 207 | 2.1.2 208 | ----- 209 | - Prepare 'severity' feature for release 210 | 211 | 2.1.1 212 | ----- 213 | - Update bugsnag-java dependency, allows disabling of auto-notification 214 | 215 | 2.1.0 216 | ----- 217 | - Support severity 218 | - Better format of notification payload 219 | - Structure the data of notifications better 220 | 221 | 2.0.10 222 | ------ 223 | - Fixed bug in `BugsnagFragmentActivity` calling the wrong callbacks. 224 | 225 | 2.0.9 226 | ----- 227 | - Added missing `setProjectPackages` and `setFilters` static methods 228 | to the `Bugsnag` class. 229 | 230 | 2.0.8 231 | ----- 232 | - Added additional `Activity` parent classes to help collect debug 233 | information, added support for custom Activities. 234 | 235 | 2.0.7 236 | ----- 237 | - Improved memory usage when sending exceptions that were previously 238 | saved to disk 239 | - `setNotifyReleaseStages` now defaults to `null`, to reduce confusion 240 | 241 | 2.0.6 242 | ----- 243 | - Fixed bug which caused notifications to be sent on the UI thread 244 | in some situations. 245 | - Fixed bug which meant `setIgnoreClasses` was not respected. 246 | 247 | 2.0.5 248 | ----- 249 | - Added support for `setIgnoreClasses` to set which exception classes 250 | should not be sent to Bugsnag. 251 | 252 | 2.0.4 253 | ----- 254 | - Attempt to automatically detect releaseStage from the debuggable flag 255 | - Android backward compatibility fixes, now works on Android 1.5+ 256 | 257 | 2.0.3 258 | ----- 259 | - Fixed bug where session time wouldn't start counting until first exception 260 | 261 | 2.0.2 262 | ----- 263 | - Fixed missing apiKey in metrics, use java notifier's metrics sending 264 | 265 | 2.0.1 266 | ----- 267 | - Added `Bugsnag.addToTab` to replace `setExtraData` for sending meta-data 268 | with every exception 269 | - Reduced jar size 270 | 271 | 2.0.0 272 | ----- 273 | - Refactored to use the classes from `bugsnag-java` 274 | - Project is now available in Maven, and built using Maven 275 | - Added support for metrics tracking (MAU/DAU) 276 | - Added additional diagnostic information (network status, memory usage, 277 | gps status, time since boot, time since app load) to every notification 278 | - Fixed some issues which might have caused error sending to fail 279 | 280 | 1.0.2 281 | ----- 282 | - Ensure empty exception files aren't created 283 | 284 | 1.0.1 285 | ----- 286 | - Fix bug with incorrect "caused by" exception names and messages 287 | 288 | 1.0.0 289 | ----- 290 | - Initial release 291 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing 2 | ============ 3 | 4 | - [Fork](https://help.github.com/articles/fork-a-repo) the [notifier on github](https://github.com/bugsnag/bugsnag-android) 5 | - Build and test your changes 6 | - Commit and push until you are happy with your contribution 7 | - [Make a pull request](https://help.github.com/articles/using-pull-requests) 8 | - Thanks! 9 | 10 | 11 | Installing the Android SDK 12 | -------------------------- 13 | 14 | Running `./gradlew` can automatically install both the Gradle build system 15 | and the Android SDK. 16 | 17 | If you already have the Android SDK installed, make sure to export the 18 | `ANDROID_HOME` environment variable, for example: 19 | 20 | ```shell 21 | export ANDROID_HOME=/usr/local/Cellar/android-sdk/23.0.2 22 | ``` 23 | 24 | If you don't already have the Android SDK installed, it will be automatically 25 | installed to `~/.android-sdk`. 26 | 27 | > Note: You'll need to make sure that the `adb`, `android` and `emulator` tools 28 | > installed as part of the Android SDK are available in your `$PATH` before 29 | > building. 30 | 31 | 32 | Building the Library 33 | --------------------- 34 | 35 | You can build new `.aar` files as follows: 36 | 37 | ```shell 38 | ./gradlew clean :build 39 | ``` 40 | 41 | Files are generated into`build/outputs/aar`. 42 | 43 | 44 | Running Tests 45 | ------------- 46 | 47 | Running the test suite requires a connected android device or emulator. 48 | 49 | You can run the test suite on a device/emulator as follows: 50 | 51 | ```shell 52 | ./gradlew clean :connectedCheck 53 | ``` 54 | 55 | 56 | Building the Example App 57 | ------------------------ 58 | 59 | You can build and install the example app to as follows: 60 | 61 | ```shell 62 | ./gradlew clean example:installDebug 63 | ``` 64 | 65 | This builds the latest version of the library and installs an app onto your 66 | device/emulator. 67 | 68 | 69 | Releasing a New Version 70 | ----------------------- 71 | 72 | If you are a project maintainer, you can build and release a new version of 73 | `bugsnag-android` as follows: 74 | 75 | ### 1. Ensure you have permission to make a release 76 | 77 | This process is a little ridiculous... 78 | 79 | - Create a [Sonatype JIRA](https://issues.sonatype.org) account 80 | - Ask in the [Bugsnag Sonatype JIRA ticket](https://issues.sonatype.org/browse/OSSRH-5533) to become a contributor 81 | - Ask an existing contributor (likely Simon) to confirm in the ticket 82 | - Wait for Sonatype them to confirm the approval 83 | 84 | 85 | ### 2. Prepare for release 86 | 87 | - Test unhandled and handled exception reporting via the example application, 88 | ensuring both kinds of reports are sent. 89 | - Update the `CHANGELOG` and `README.md` with any new features 90 | 91 | - Update the version numbers in `gradle.properties` and `src/main/java/com/bugsnag/android/Notifier.java` 92 | 93 | - Commit and tag the release 94 | 95 | ```shell 96 | git commit -am "v3.x.x" 97 | git tag v3.x.x 98 | git push origin master && git push --tags 99 | ``` 100 | 101 | ### 3. Release to Maven Central 102 | 103 | - Create a file `~/.gradle/gradle.properties` with the following contents: 104 | 105 | ```ini 106 | # Your credentials for https://oss.sonatype.org/ 107 | # NOTE: An equals sign (`=`) in any of these fields will break the parser 108 | NEXUS_USERNAME=your-nexus-username 109 | NEXUS_PASSWORD=your-nexus-password 110 | 111 | # GPG key details 112 | signing.keyId=your-gpg-key-id # From gpg --list-keys 113 | signing.password=your-gpg-key-passphrase 114 | signing.secretKeyRingFile=/Users/{username}/.gnupg/secring.gpg 115 | ``` 116 | 117 | - Build and upload the new version 118 | 119 | ```shell 120 | ./gradlew clean :uploadArchives 121 | ``` 122 | 123 | - "Promote" the release build on Maven Central 124 | 125 | - Go to the [sonatype open source dashboard](https://oss.sonatype.org/index.html#stagingRepositories) 126 | - Click the search box at the top right, and type “com.bugsnag” 127 | - Select the com.bugsnag staging repository 128 | - Click the “close” button in the toolbar, no message 129 | - Click the “refresh” button 130 | - Select the com.bugsnag closed repository 131 | - Click the “release” button in the toolbar 132 | 133 | ### 4. Upload the .aar file to GitHub 134 | 135 | - Create a "release" from your new tag on [GitHub Releases](https://github.com/bugsnag/bugsnag-android/releases) 136 | - Upload the generated `.aar` file from `build/outputs/aar/bugsnag-android-release.aar` on the "edit tag" page for this release tag 137 | 138 | ### 5. Update documentation 139 | 140 | - Update installation instructions in the quickstart 141 | guides on the website with any new content (in `_android.slim`) 142 | - Bump the version number in the installation instructions on 143 | docs.bugsnag.com/platforms/android, and add any new content 144 | 145 | ### 6. Keep dependent libraries in sync 146 | 147 | - Make releases to downstream libraries, if appropriate (generally for bug 148 | fixes) 149 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Bugsnag 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: build 2 | 3 | .PHONY: build test clean 4 | 5 | build: 6 | ./gradlew build 7 | 8 | clean: 9 | ./gradlew clean 10 | 11 | test: 12 | ./gradlew :connectedCheck 13 | 14 | release: 15 | ./gradlew clean :uploadArchives 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Bugsnag exception reporter for Android 2 | [![Documentation](https://img.shields.io/badge/documentation-latest-blue.svg)](http://docs.bugsnag.com/platforms/android/) 3 | [![Build status](https://travis-ci.org/bugsnag/bugsnag-android.svg?branch=master)](https://travis-ci.org/bugsnag/bugsnag-android) 4 | 5 | Bugsnag's [Android crash reporting](https://bugsnag.com/platforms/android) 6 | library automatically detects crashes in your Android apps, collecting 7 | diagnostic information and immediately notifying your development team, helping 8 | you to understand and resolve issues as fast as possible. 9 | 10 | 11 | ## Features 12 | 13 | * Automatically report unhandled exceptions and crashes 14 | * Report [handled exceptions](http://docs.bugsnag.com/platforms/android/#reporting-handled-exceptions) 15 | * [Log breadcrumbs](http://docs.bugsnag.com/platforms/android/#logging-breadcrumbs) which are attached to crash reports and add insight to users' actions 16 | * [Attach user information](http://docs.bugsnag.com/platforms/android/#identifying-users) to determine how many people are affected by a crash 17 | 18 | 19 | ## Getting started 20 | 21 | 1. [Create a Bugsnag account](https://bugsnag.com) 22 | 1. Complete the instructions in the [integration guide](http://docs.bugsnag.com/platforms/android/) to report unhandled exceptions thrown from your app 23 | 1. Report handled exceptions using [`Bugsnag.notify`](http://docs.bugsnag.com/platforms/android/reporting-handled-exceptions/) 24 | 1. Customize your integration using the [configuration options](http://docs.bugsnag.com/platforms/android/configuration-options/) 25 | 26 | 27 | ## Support 28 | 29 | * [Read the integration guide](http://docs.bugsnag.com/platforms/android/) or [configuration options documentation](http://docs.bugsnag.com/platforms/android/configuration-options/) 30 | * [Search open and closed issues](https://github.com/bugsnag/bugsnag-android/issues?utf8=✓&q=is%3Aissue) for similar problems 31 | * [Report a bug or request a feature](https://github.com/bugsnag/bugsnag-android/issues/new) 32 | 33 | 34 | ## Contributing 35 | 36 | All contributors are welcome! For information on how to build, test 37 | and release `bugsnag-android`, see our 38 | [contributing guide](https://github.com/bugsnag/bugsnag-android/blob/master/CONTRIBUTING.md). 39 | 40 | 41 | ## License 42 | 43 | The Bugsnag Android notifier is free software released under the MIT License. 44 | See [LICENSE.txt](https://github.com/bugsnag/bugsnag-android/blob/master/LICENSE.txt) 45 | for details. 46 | -------------------------------------------------------------------------------- /UPGRADING.md: -------------------------------------------------------------------------------- 1 | Upgrading Guide 2 | =============== 3 | 4 | Upgrade from 2.0 to 3.0 5 | ----------------------- 6 | - Change any `Bugsnag.register` calls to `Bugsnag.init`: 7 | 8 | ```java 9 | // Old 10 | Bugsnag.register(Context, "api-key"); 11 | 12 | // New 13 | Bugsnag.init(Context, "api-key"); 14 | ``` 15 | 16 | - Severity is now an `Enum`, so please update any references to severity in your app: 17 | 18 | ```java 19 | // Old 20 | Bugsnag.notify(new RuntimeException("oops"), "error"); 21 | 22 | // New 23 | import com.bugsnag.android.Severity; 24 | Bugsnag.notify(new RuntimeException("oops"), Severity.ERROR); 25 | ``` 26 | 27 | - "Top Activity" tracking is now automatically handled when you add the 28 | `GET_TASKS` permission to your `AndroidManifest.xml`, so you should no 29 | longer have your app's `Activity`s inherit from `BugsnagActivity`: 30 | 31 | ```java 32 | // Old 33 | class MyActivity extends BugsnagActivity {} 34 | 35 | // New 36 | class MyActivity extends Activity {} 37 | ``` 38 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | mavenCentral() 5 | } 6 | 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.2.3' 9 | } 10 | } 11 | 12 | // Tasks to build and test the android library 13 | apply plugin: 'com.android.library' 14 | android { 15 | compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION) 16 | buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION 17 | 18 | defaultConfig { 19 | minSdkVersion 4 20 | targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION) 21 | } 22 | 23 | lintOptions { 24 | disable 'DefaultLocale' 25 | } 26 | } 27 | 28 | dependencies { 29 | compile "com.android.support:support-annotations:25.1.1" 30 | } 31 | 32 | // Disable doclint: 33 | // https://github.com/GPars/GPars/blob/312c5ae87605a0552bc72e22e3b2bd2fa1fdf98c/build.gradle#L208-L214 34 | if (JavaVersion.current().isJava8Compatible()) { 35 | tasks.withType(Javadoc) { 36 | // disable the crazy super-strict doclint tool in Java 8 37 | //noinspection SpellCheckingInspection 38 | options.addStringOption('Xdoclint:none', '-quiet') 39 | } 40 | } 41 | 42 | // Tasks to release the library to maven central 43 | apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle' 44 | -------------------------------------------------------------------------------- /example/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | mavenCentral() 5 | mavenLocal() 6 | } 7 | dependencies { 8 | classpath 'com.bugsnag:bugsnag-android-gradle-plugin:+' 9 | } 10 | } 11 | apply plugin: 'com.android.application' 12 | 13 | android { 14 | compileSdkVersion 25 15 | buildToolsVersion '25.0.2' 16 | 17 | buildTypes { 18 | 19 | debug { 20 | applicationIdSuffix ".debug" 21 | } 22 | 23 | release { 24 | minifyEnabled true 25 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.pro' 26 | } 27 | } 28 | 29 | defaultConfig { 30 | minSdkVersion 4 31 | } 32 | } 33 | 34 | dependencies { 35 | compile rootProject 36 | } 37 | 38 | apply plugin: 'com.bugsnag.android.gradle' 39 | -------------------------------------------------------------------------------- /example/proguard.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /example/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /example/src/main/java/com/bugsnag/android/example/ExampleActivity.java: -------------------------------------------------------------------------------- 1 | package com.bugsnag.android.example; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.view.View; 6 | import android.widget.Toast; 7 | import com.bugsnag.android.BeforeNotify; 8 | import com.bugsnag.android.Bugsnag; 9 | import com.bugsnag.android.Error; 10 | import com.bugsnag.android.MetaData; 11 | import com.bugsnag.android.Severity; 12 | import com.bugsnag.android.other.Other; 13 | import com.bugsnag.android.BreadcrumbType; 14 | import java.util.ArrayList; 15 | import java.util.Collection; 16 | import java.util.HashMap; 17 | import java.util.Map; 18 | 19 | import static android.widget.Toast.LENGTH_SHORT; 20 | 21 | public class ExampleActivity extends Activity 22 | { 23 | /** Called when the activity is first created. */ 24 | @Override 25 | public void onCreate(Bundle savedInstanceState) 26 | { 27 | super.onCreate(savedInstanceState); 28 | setContentView(R.layout.main); 29 | 30 | // Initialize the Bugsnag client 31 | Bugsnag.init(this); 32 | 33 | // Execute some code before every bugsnag notification 34 | Bugsnag.beforeNotify(new BeforeNotify() { 35 | @Override 36 | public boolean run(Error error) { 37 | System.out.println(String.format("In beforeNotify - %s", error.getExceptionName())); 38 | return true; 39 | } 40 | }); 41 | 42 | // Set the user information 43 | Bugsnag.setUser("123456", "james@example.com", "James Smith"); 44 | 45 | Bugsnag.setProjectPackages("com.bugsnag.android.example", "com.bugsnag.android.other"); 46 | 47 | // Add some global metaData 48 | Bugsnag.addToTab("user", "age", 31); 49 | Bugsnag.addToTab("custom", "account", "something"); 50 | 51 | Bugsnag.leaveBreadcrumb("onCreate", BreadcrumbType.NAVIGATION, new HashMap()); 52 | 53 | new Thread(new Runnable() { 54 | public void run() { 55 | try { 56 | sleepSoundly(); 57 | } catch (java.lang.InterruptedException e) { 58 | 59 | } 60 | } 61 | 62 | private void sleepSoundly() throws java.lang.InterruptedException { 63 | Thread.sleep(100000); 64 | } 65 | }).start(); 66 | } 67 | 68 | public void sendError(View view) { 69 | actuallySendError(); 70 | } 71 | 72 | private void actuallySendError() { 73 | Bugsnag.notify(new RuntimeException("Non-fatal error"), Severity.ERROR); 74 | Toast.makeText(this, "Sent error", LENGTH_SHORT).show(); 75 | } 76 | 77 | public void sendWarning(View view) { 78 | actuallySendWarning(); 79 | } 80 | 81 | private void actuallySendWarning() { 82 | Bugsnag.notify(new RuntimeException("Non-fatal warning"), Severity.WARNING); 83 | Toast.makeText(this, "Sent warning", LENGTH_SHORT).show(); 84 | } 85 | 86 | public void sendInfo(View view) { 87 | Bugsnag.notify(new RuntimeException("Non-fatal info"), Severity.INFO); 88 | Toast.makeText(this, "Sent info", LENGTH_SHORT).show(); 89 | } 90 | 91 | public void sendErrorWithMetaData(View view) { 92 | Map nested = new HashMap(); 93 | nested.put("normalkey", "normalvalue"); 94 | nested.put("password", "s3cr3t"); 95 | 96 | Collection list = new ArrayList(); 97 | list.add(nested); 98 | 99 | MetaData metaData = new MetaData(); 100 | metaData.addToTab("user", "payingCustomer", true); 101 | metaData.addToTab("user", "password", "p4ssw0rd"); 102 | metaData.addToTab("user", "credentials", nested); 103 | metaData.addToTab("user", "more", list); 104 | 105 | Bugsnag.notify(new RuntimeException("Non-fatal error with metaData"), Severity.ERROR, metaData); 106 | Toast.makeText(this, "Sent error with metaData", LENGTH_SHORT).show(); 107 | } 108 | 109 | public void crash(View view) { 110 | Other other = new Other(); 111 | other.meow(); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /example/src/main/java/com/bugsnag/android/other/Other.java: -------------------------------------------------------------------------------- 1 | package com.bugsnag.android.other; 2 | 3 | public class Other { 4 | 5 | public void meow() { 6 | mew(); 7 | } 8 | 9 | private void mew() { 10 | throw new RuntimeException("herpaderpa"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /example/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/airbnb/bugsnag-android/a2d00ca16a9d765c157d76f37e0d951934557f49/example/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 20 |