How to report Silent Crashes in Flutter - android

Our app uses Firebase Crashlytics and Sentry to keep track of all the crashes. We have covered all of our dart code with crash handling but have noticed that in some cases the crashes come from native code, which means that they are not caught by our catchers.
For example, we recently had an issue with one of our images accidentally getting published in very high res causing memory issues and the app to crashed without any reports.
We were to able to know about it and fix it because of feedback from the users and the fact that it was easily reproducible, but we'd rather have some sort of reporting in place for such crashes.

Firebase Crashlytics can pick up those errors too.
Follow all steps on the package setup guide.
https://pub.dev/packages/firebase_crashlytics
quoting the guide
Overriding FlutterError.onError with Crashlytics.instance.recordFlutterError will automatically catch all errors that are thrown from within the Flutter framework.
If you want to catch errors that occur in runZoned, you can supply Crashlytics.instance.recordError to the onError parameter:
runZoned<Future<void>>(() async {
// ...
}, onError: Crashlytics.instance.recordError);

Have you tried catching NDK crashes? Crashlytics supports it

Related

Crashlytics sendUnsentReports() doesn't work even with FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(false)

I need to send my reports right after the errors happens, but Crashlytics only send them when i restart the app.
I tried to follow the documentation and implement this in different ways, but everytime it seems to lead to the same outcome, which is that Crashlytics only send the reports after i restart the app. I get that this is the expected behavior, but it is completely useless for my app's purposes.
main.dart
...
FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(false);
...
AndroidManifest.xml
...
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="false" />
...
firebase_util.dart
...
await FirebaseCrashlytics.instance
.recordError(error, stackTrace, printDetails: true)
.then((value) async => await FirebaseCrashlytics.instance.sendUnsentReports());
...
What am i doing wrong?
The Android SDK will try to send the crash report after it happens, if you are on the latest Crashlytics SDK version this should be the case.
But in iOS, unfortunately, this will happen only after restarting the app. As far as I know, this is to avoid issues where the app gets closed while making network requests.
In relation to setCrashlyticsCollectionEnabled(false), this is intended for giving users more control of their data. You would set this to false in the manifest (for Android) or in the Info.plist (for iOS) to prevent Crashlytics from sending crash data. This explains why crashes not were being sent when calling:
FirebaseCrashlytics.instance.sendUnsentReports()
Then you could ask the user for their consent and if they do, you can set this value to true with:
FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true)
After doing this, Crashlytics will start collecting and sending crash reports. But it will follow the process from above.

How to manually log errors/crashes to appcenter in react native application?

I am creating an application with the use of react native and I want to handle exceptions in some cases when an application can get crashed. I want to show that exception in appcenter and also not want that the application actually crash. I am using appcenter already and implemented it for building the app. I am also getting crash reports there but it shows when the actual application got crashed. But I want only the reports there while not crashing the application.
you can use appcenter-analytics and appcenter-crashes
If you use the library, you can find out when a crash occurs.
appcenter
To manage the event separately, the following method can be used.
Example
import Analytics from "appcenter-analytics";
...
Analytics.trackEvent("eventName", {
[key]: value,
});
appcenter

Using AppCenter, am I able to add user data to a unhandled crash report?

We have a Xamarin.Android application for a client which is experiencing crashes on the field. They aren't reproducible when going through testing but we are able to handle the crash and add information like the user data to it. But when a crash that isn't handled happens, we just get an obscure log. I've been asked to try and get some user data into the unhandled crash to understand which user has caused it.
So, basically, am I able to add data to the log of an unhandled crash using AppCenters Library?
I've done some research and just found...
AndroidEnvironment.UnhandledExceptionRaiser += (sender, args) =>
{
TraceWriter.WriteTrace(args.Exception);
args.Handled = true;
};
This seems to be an overall exception handler. I read it would be just used to get more info about the crash but can't handle it there as the Delvik machine on the device is already crashing. Is this something I could use to pass in more data to a crash?
You can add one binary and one text file to the crash report using Crashes.GetErrorAttachments. The file must be smaller than 7MB. There is more information available in the AppCenter Crashes documentation.
You can also set the user id in the AppCenter SDK using AppCenter.SetUserId so you can tell which user generated the crash report.

firebase android functional setup

Added firebase to my android marshmallow application and have run the application with the recommended FirebaseCrash.report(new Exception("")) to verify the setup and am getting the report in my firebase console.
Questions due to the developer guide being a bit unclear:
do I need to add a firebase.log or firebase.logcat to each of the caught exceptions in my application in order to get report entries for them. If so, which is recommended? Should I use firebasecrash.report instead?
Is there any additional work needed to capture uncaught exceptions generated
In the evaluation phase at this point and would prefer not to make a lot of code changes for something that might not work out.
From the documentation of Firebase Crash Reporting (I added numbers to correlate them to your questions):
Firebase Crash Reporting automatically generates reports for fatal errors (or uncaught exceptions) (2). However, you can also generate reports in instances where you catch an exception but still want to report the occurrence (1).
So:
if you want to report caught exception you have to report them yourself with FirebaseCrash.report().
uncaught exceptions are reported automatically.

How to learn a reason why a 3rd party, non-debuggable app crashed

In Android, is there a way to tell why app crashed on my device? Let's say I have root access to the device, but the app that crashed is not debuggable and does not print anything to logcat.
Just to reiterate, the app that crashed is not my app, I have no access to the source, and it's not debuggable (it's a release build). I just want to get any available insights on why it crashed.
EDIT: I forgot to mention, I only found the /data/anr/ and /data/tombstones as sources for potential information. Those do not contain the stacktraces. Is there anything more available?
EDIT: There is a lot of confusion in comments, please read the question carefully. What I'm after is some kind of low level component that knows about the reason of the crash. The virtual machine must know, right?
I identified following sources that may or may not have useful information about 3rd party apps crashes:
adb logcat -b crash
/data/tombstones/
/data/anr/
Cannot. In third-party app, you cannot get detail about crash report. In some rarely case, third-party application has saved crash reports to log file. If you know file location, you can analyze crash on that log file. Otherwise, there isn't any way.
In case you develop your own app, and your application already has released to user and you want to get some statistic about crash event. You can gain some insight by using Crash Report Service as I mention below.
In case you want go get crash report from your own application, here is some libraries and services for your: ACRA library. Crash report will generated and post to Google Form. Really easy to use and setup in your application. As document stated:
#ReportsCrashes(formUri = "http://www.yourselectedbackend.com/reportpath")
public class MyApplication extends Application {
#Override
public void onCreate() {
// The following line triggers the initialization of ACRA
super.onCreate();
ACRA.init(this);
}
}
But you must have your own server. (There are tutorials for deploying this server, but you still must have your own). If you want to depend all to third-party service then Crashlytics or Crittercism or Countly or Google search query

Categories

Resources