GithubHelp home page GithubHelp logo

bugsnag / bugsnag-android Goto Github PK

View Code? Open in Web Editor NEW
1.2K 68.0 203.0 11.42 MB

BugSnag crash monitoring and reporting tool for Android apps

Home Page: https://www.bugsnag.com/platforms/android/

License: Other

Java 22.02% Makefile 0.14% Kotlin 45.16% Ruby 1.18% Gherkin 7.98% Shell 0.15% CMake 0.23% C++ 2.71% C 20.43%
bugsnag java crash android crash-reporting crash-reports error-monitoring error-reporting crash-reporting-tool debug

bugsnag-android's Introduction

Bugsnag error monitoring & exception reporter for Android

Documentation

Get comprehensive Android crash reports to quickly debug errors.

Bugsnag's Android crash reporting library automatically detects crashes in your Android apps, collecting diagnostic information and immediately notifying your development team, helping you to understand and resolve issues as fast as possible.

Features

Getting started

  1. Create a Bugsnag account
  2. Complete the instructions in the integration guide to report unhandled exceptions thrown from your app
  3. Report handled exceptions using Bugsnag.notify
  4. Customize your integration using the configuration options

Support

Contributing

All contributors are welcome! For information on how to build, test and release bugsnag-android, see our contributing guide.

Bugsnag employees should start by reading the docs.

License

The Bugsnag Android notifier is free software released under the MIT License. See the LICENSE for details.

bugsnag-android's People

Contributors

bengourley avatar cawllec avatar conradirwin avatar d4rken avatar felipecsl avatar fractalwrench avatar friederbluemle avatar hannah-smartbear avatar jakewharton avatar jessicard avatar johnkiely1 avatar joshedney avatar jrodbx avatar kattrali avatar kstenerud avatar larsgrefer avatar lemnik avatar loopj avatar martin308 avatar pezzah avatar pyricau avatar renovate-bot avatar rich-bugsnag avatar simonbowring avatar snmaynard avatar tomlongridge avatar tremlab avatar twometresteve avatar yousif-bugsnag avatar yychen01988 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bugsnag-android's Issues

device_state['time'] can be not iso-8601

Correctness
SimpleDateFormat: Implied locale in date format
../../src/main/java/com/bugsnag/android/DateUtils.java:13: To get local formatting use getDateInstance(), getDateTimeInstance(), or getTimeInstance(), or use new SimpleDateFormat(String template, Locale locale) with for example Locale.US for ASCII dates.

Optimizations

Some optimizations are due

  • Avoid creating garbage, too many new per call like Runnables, JSONObjects and byte[]s
  • Avoid autoboxing
  • If ActivityStack mere purpose is to keep track of "context" names why keep Activity/Context references instead of say Class preventing even more Activity/Context leaking
  • Allow batching requests aka Big cookie approach

Should register in an Application class instead of "main activity"

Strictly there is no such thing as a "main activity" in Android. Any activity could be launched in any order. So to be sure the Bugsnag notifier is registered when our App is running I've put the register code in my Application-subclass onCreate method. That method is always launched before the creation of the first Activity.

I think it would be great if the Readme advised users to implement Bugsnag.register in this method to make it somewhat more robust. (If I've some time this afternoon I'll make a pull request for this.) :)

Ps. Great work, bugsnag looks like a great App and is really easy to set up! :)

Before notify callback not invoked by uncaught exception handler.

Any before notify listeners attached to the client are not invoked when the uncaught exception handler triggers. This is due to the Client subclass in this library overriding notify(Throwable, String, MetaData). The superclass implementation is what stores the list of notifiers but the method to trigger them, beforeNotify(Error) is private.

The 'bugsnag-java' library should probably be updated to change this to a protected method so that it can be invoked from the subclass. This keeps the logic in one place.

setUser() not persisted across sessions.

Shouldn't user details be persisted across app sessions?
Right now I have to call setUser() at every app start, it would be more convenient if user info were persisted unless manually reset.
This is not specified in the doc either, I had to manually test the behavior in order to find why most of my users were not having a userId set in the crash reports.
Lastly, all the analytics tools I've used so far (segment, google analytics, flurry and mixpanel) persist user info across sessions.

Ring Buffer-based Log, Tab

A .log method (with a few overloads) would allow attaching crash data without actually having to do it at the time of the crash.

This would show up in a "Device Log" tab on the site ordered by time (oldest to newest). Lexicographically a "yyyy-mm-dd hh:mm:ss" format is well suited to the key/pair data model that already exists today and will likely Just Work™ with the current addToTab API.

Internally this would be implemented as a ring-buffer of the last 50 or 100 calls to this method to ensure we were bloating memory use by caching calls indefinitely. When a crash occurs (either through .notify or unexpected), the buffer is copied and attached to the report automatically.

Can't import with Gradle

Hi
I'm trying to compile that artifact but it isn't work. My gradle file compile everything, but not the Bugsnag. I'm at online mode and this is my gradle:

repositories {
  mavenCentral()
  maven {
    url "https://oss.sonatype.org/content/repositories/snapshots/"
  }
  maven {
    url "https://clojars.org/repo/"
  }
  maven {
    url "https://jitpack.io"
    credentials { username authToken }
  }
}

dependencies {
  ...another libraries 
  compile 'com.bugsnag:bugsnag:+'
}

Exception reporting doesn't work with deep linking

If an activity is started from another app task and it crashes, it's not reporting the exception to bugsnag.

Here's an example:

<!-- AndroidManifest.xml -->
<application android:name="MyApplication">
   <activity android:name="MyActivity">
      <intent-filter>
         <action android:name="android.intent.action.VIEW"/>
               <category android:name="android.intent.category.DEFAULT" />
               <category android:name="android.intent.category.BROWSABLE" />
               <data android:scheme="https"
                         android:host="www.google.com"
                         android:pathPrefix="/calendar" />
      </intent-filter>
   </activity>
</application>
// MyActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
   // crash with NPE
   savedInstantState.get("test");
}
//MyApplication.java
@Override
public void onCreate() {
   super.onCreate();
   Bugsnag.init(this);
}

If you start MyActivity manually by launching the app, it will crash and the crash gets reported to bugsnag as expected.

If you click on https://www.google.com/calendar link (in email or browser), Android will ask which app you want to open with, and if you open with MyApp, it will start MyActivity and crash as expected. However, in this case, the crash doesn't get reported to bugsnag.

The version I used was bugsnag-android 3.2.4

Bugsnag drops a lot of crashes

Here: https://github.com/bugsnag/bugsnag-android/blob/master/src/main/java/com/bugsnag/android/Client.java#L517

The crashes are written to disk asynchronously, and then the exception is handled to the default exception handler.

If the app is in the foreground, the default handler will show the crash dialog and block there, then when the user clicks on it the default handler kills the process. See here: https://github.com/android/platform_frameworks_base/blob/master/core/java/com/android/internal/os/RuntimeInit.java#L88

If the app is in the background, there is no dialog, so the process dies immediately.

So this basically means that the process can die before the async work is done, so before the crash is saved to the file system.

We can't even work around that and use our own exception handler, because we do not have any hook into the async work to wait for its completion.

Btw, Async uses AsyncTask. That's terrible, its internal behavior has changed over Android versions. Don't use that.

Manifest API key load should only be attempted if null/empty

    public Client(Context androidContext, String apiKey, boolean enableExceptionHandler) {
        if(androidContext == null) {
            throw new NullPointerException("You must provide a non-null android Context");
        }

        // Get the application context, many things need this
        appContext = androidContext.getApplicationContext();

        // Attempt to load API key from AndroidManifest.xml
        try {
            ApplicationInfo ai = appContext.getPackageManager().getApplicationInfo(appContext.getPackageName(), PackageManager.GET_META_DATA);
            apiKey = ai.metaData.getString("com.bugsnag.android.API_KEY");
        } catch (Exception e) { }

        if(apiKey == null) {
            throw new NullPointerException("You must provide a Bugsnag API key");
        }

This code always throws an NPE for me because it nulls my API key I'm passing in.

Please guard it with TextUtils.isEmpty.

Seeing this in v3.2.1.

Fail gracefully when no API key is provided

Instead of throwing an NPE just log an error so that we can use the library in an open source project without an api key and not get tons of debug crashes from unknown sources.

The actionbarsherlock dependency causes proguard failures

The only fix is to add the following code in the proguard configuration file :

-dontwarn com.bugsnag.**

Is there a workaround ?

Otherwise actionbarsherlock is indicated as an optional dependency. If we don't need it, is there a way to exclude it ?

org.json transitive dependency

Hi,

I'm adding bugsnag to our app as replacement of Crittercism, but I noticed that builds now get this warning:

WARNING: Dependency org.json:json:20090211 is ignored for noRtlStaging as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage with jarjar to change the class packages
WARNING: Dependency org.json:json:20090211 is ignored for noRtlDebug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage with jarjar to change the class packages
WARNING: Dependency org.json:json:20090211 is ignored for noRtlRelease as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage with jarjar to change the class packages
WARNING: Dependency org.json:json:20090211 is ignored for rtlStaging as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage with jarjar to change the class packages
WARNING: Dependency org.json:json:20090211 is ignored for rtlDebug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage with jarjar to change the class packages
WARNING: Dependency org.json:json:20090211 is ignored for rtlRelease as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage with jarjar to change the class packages

Looking at dependencies org.json is certainly being added by bugsnag as transitive dependency

+--- com.bugsnag:bugsnag-android:2.1.3
|    \--- com.bugsnag:bugsnag:[1.2.4,2) -> 1.2.4
|         \--- org.json:json:20090211

Any chance of making org.json provided?

Dex doesn't like Async. Proguard config problem?

warning: Ignoring InnerClasses attribute for an anonymous inner class
(com.bugsnag.android.Async$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.

Why are consumer ProGuard rules included?

As far as I can tell none of them are needed. This library has no reflection so both obfuscation and stripping will behave correctly without them.

Currently it disables both obfuscation and stripping without a clear reason as to why.

DeviceData default values.

Example:

If we can't obtain a value, is it not better to omit the value than to send a default value of "0"?
For someone checking stats in the webconsole, it would be better to see that the value isn't available instead of guessing whether bugsnag defaulted to that value or the system provided that value.

If this doesn't conflict with some API requirements of bugsnag, i would submit a pull request to change this.

Stuck at uploadBugsnagDebugMapping

This problem makes the compile impossible! Please create another way to update the map to bugsnag.

:app:uploadBugsnagDebugMapping

That`s all.

Sorting Exceptions

It is possible to add some filters to group exceptions not by phone and exception but only by exceptions?

Allow configurable number of stored exceptions

Limit the client to only storing the last n exceptions. This could either be done as part of writeErrorToDisk (write time) or flushErrors (transmit time). We should only transmit the last n exceptions.

Unit Test configuration

Is there a recognised way to stop Bugsnag reporting errors in unit tests? It would be nice if we could switch error reporting off. As a work around I do the following...

Bugsnag.init(mock(Context.class), ""); //mock Context with Mockito and pass in an empty string as the API_Key
Bugsnag.beforeNotify(new BeforeNotify() { //assign a BeforeNotify which halts reporting of all exceptions
    @Override
    public boolean run(Error error) {
        return false;
    }
});

I had to create a custom TestRunner to make sure this is called on each test.

ConcurrentModificationException in Breadcrumbs

I received java.util.ConcurrentModificationException if first call Bugsnag.notify() and then call Bugsnag.leaveBreadcrumb() in UI Thread.

StackTrace:

Problem sending error to Bugsnag
    java.util.ConcurrentModificationException
            at java.util.LinkedList$LinkIterator.next(LinkedList.java:124)
            at com.bugsnag.android.Breadcrumbs.toStream(Breadcrumbs.java:27)
            at com.bugsnag.android.JsonStream.value(JsonStream.java:37)
            at com.bugsnag.android.Error.toStream(Error.java:97)
            at com.bugsnag.android.JsonStream.value(JsonStream.java:37)
            at com.bugsnag.android.Notification.toStream(Notification.java:40)
            at com.bugsnag.android.HttpClient.post(HttpClient.java:38)
            at com.bugsnag.android.Notification.deliver(Notification.java:64)
            at com.bugsnag.android.Client.deliver(Client.java:619)
            at com.bugsnag.android.Client.access$000(Client.java:19)
            at com.bugsnag.android.Client$1.run(Client.java:611)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
            at java.lang.Thread.run(Thread.java:856)

Exception in Bugsnag.init() when getResouces() is null

In some circumstances an exception can be thrown during initialization when Context.getResources() is null.

It appears that this only happens when the App's onCreate is triggered by a widget refresh.

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.util.DisplayMetrics android.content.res.Resources.getDisplayMetrics()' on a null object reference
at com.bugsnag.android.DeviceData.<init>(DeviceData.java:33)
at com.bugsnag.android.Client.<init>(Client.java:87)
at com.bugsnag.android.Client.<init>(Client.java:45)
at com.bugsnag.android.Bugsnag.init(Bugsnag.java:35)

Proguard/Dexguard support

Currently there's no way to upload a Proguard mapping file to trace bugs on apps that have been obfuscated.

Are there any plans to add this support in?

Should log when no INTERNET permission

At the moment we log to recommend people enable the other permissions, but if you don't have internet it just fails and writes the request to disk without telling you why.

Enhance "in-project" detection to work with Proguard

Proguard makes it possible to collapse/crash package names, which we use in the app to set lines as "in-project".

We should send our "project packages" list from the client, and determine the in-project status during our server-side proguard processing.

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.