bugsnag / bugsnag-android Goto Github PK
View Code? Open in Web Editor NEWBugSnag crash monitoring and reporting tool for Android apps
Home Page: https://www.bugsnag.com/platforms/android/
License: Other
BugSnag crash monitoring and reporting tool for Android apps
Home Page: https://www.bugsnag.com/platforms/android/
License: Other
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.
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.
The permission.GET_TASKS" was deprecated in API level 21.
How can i use bugsnag android in Lollipop?
The java library provides an overloaded Client
constructor to initialize without installing the default uncaught exception handler. The Android library does not expose the same functionality.
If you're just ignoring IOException
swallow it silently. Otherwise propagate as a RuntimeException
so it can be caught and logged with Logger
.
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?
Looking forward to use the BeforeNotify functionality
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)
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 ?
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)
From the device tab of the event log,
locale | ar_AE
...
screenResolution | ١٢٨٠x٨٠٠
Similar for other locales, including fa_IR
https://github.com/bugsnag/bugsnag-android/blob/master/src/main/java/com/bugsnag/android/DeviceData.java#L104 should probably specify Locale.US for standardization.
Might be tricky to unit test
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.
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.
Sometimes people need to add
-keep class com.bugsnag.android.** { *; }
to their proguard config.
Investigate BuildConfig.DEBUG for better releaseStage detection: http://stackoverflow.com/a/25267049/102542
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?
Need a hybrid Activity that allows to extend from BugsnagActivity and SherlockActivity together.
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.
Some optimizations are due
new
per call like Runnable
s, JSONObject
s and byte[]
sActivityStack
mere purpose is to keep track of "context" names why keep Activity
/Context
references instead of say Class
preventing even more Activity
/Context
leakingAt https://github.com/bugsnag/bugsnag-android/blob/master/src/main/java/com/bugsnag/android/HttpClient.java#L46, why use ad-hoc comparison and not compare against http://download.java.net/jdk7/archive/b123/docs/api/java/net/HttpURLConnection.html#HTTP_OK?
Using an aar instead of a simple jar has two advantages:
<uses-permission />
-elements in its own manifest which gets merged to the apps manifest during the build.Update the android/proguard docs to describe our new UUID support:
https://bugsnag.com/docs/notifiers/android/proguard
Also, there are some formatting issues on this page right now that need fixing.
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 null
s my API key I'm passing in.
Please guard it with TextUtils.isEmpty
.
Seeing this in v3.2.1.
Is it possible to add Logcat when a exception occurred ?
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.
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.
This problem makes the compile impossible! Please create another way to update the map to bugsnag.
:app:uploadBugsnagDebugMapping
That`s all.
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.
It would be nice to support overriding the deviceId.
Currently async calls relay on AsyncTask
which can easily get RejectedException
s
http://stackoverflow.com/questions/2492909/asynctask-rejectedexecutionexception-and-task-limit
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.
Update the schema in Bugsnag.setEndpoint("http://bugsnag.internal.example.com"); to https.
Not really sure where to post this, but just wanted to let you guys know.
The contributing guidelines link on the android reference page (at the bottom) points to this dead URL.
Should it be pointing to this instead?
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.
At https://github.com/bugsnag/bugsnag-android/blob/master/src/main/java/com/bugsnag/android/HttpClient.java#L28 and elsewhere use HttpsURLConnection. This promotes safe practices, since if the developer sets an HTTP URL, they will get an error similar to this one: "sun.net.www.protocol.http.HttpURLConnection cannot be cast to javax.net.ssl.HttpsURLConnection".
It is possible to add some filters to group exceptions not by phone and exception but only by exceptions?
At https://github.com/bugsnag/bugsnag-android/blob/master/src/main/java/com/bugsnag/android/ErrorStore.java#L61 and https://github.com/bugsnag/bugsnag-android/blob/master/src/main/java/com/bugsnag/android/ErrorStore.java#L66, .delete() may return false. If that's the case, then .deleteOnExit() should be called.
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.
In the docs https://bugsnag.com/docs/notifiers/android this is included. But the actual function does not exists in source (I'm using 2.0.8 jar file).
This is sorta important as crashes in the library does not get grouped properly.
As I want my application to be backwards with versions of Android before 3.0 I use the Android Support Library see http://developer.android.com/tools/extras/support-library.html. So my Activities do not extend android.app.Activity
but android.support.v4.app.FragmentActivity
. This means that I can't use your BugSnagActivity
class in my application. Please add support for FragmentActivity
as well.
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:+'
}
android.os.NetworkOnMainThreadException: The exception that is thrown when an application attempts to perform a networking operation on its main thread.
On an unhandled exception uncaughtException()
is called which in turn calls client.autoNotify()
. client
is an instance of com.bugsnag.Client
which does not call notify()
on a background thread while Bugsnag.notify()
does (which is correct).
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.
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.
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! :)
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.