简体   繁体   中英

How to see Dart code stack trace instead of Java code stack trace in Crashlytics/Flutter (Android)

We are using the firebase_crashlytics plugin for Flutter to get error reports in Crashlytics. Unfortunately for Android, only the non-fatal issues show a proper Dart code stack trace. The fatal issues only show Java code stack trace which makes them very hard to debug.

Is there any way to get proper Dart code stack traces for fatal issues as well?

I added this lines to my main.dart to get the Dart StackTrace:

FlutterError.onError = (error) => flutterErrorHandler(error);

runZonedGuarded<Future<void>>(
    () async => runApp(
      YourAppWidget(),
    ),
    (error, strack) async {
      debugPrint(error.toString());
      // Whenever an error occurs, call the `reportCrash`
      // to send Dart errors to Crashlytics
      Crashlytics.instance.recordError(error, strack);
    },
  );
void flutterErrorHandler(FlutterErrorDetails details) {
  FlutterError.dumpErrorToConsole(details);

  // Report to the application zone to report to Crashlytics.
  Zone.current.handleUncaughtError(details.exception, details.stack);
}

For more details see: https://pub.dev/packages/firebase_crashlytics

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM