![](/img/trans.png)
[英]Flutter Firebase Crashlytics reports stack trace as Java class files and not as Dart files
[英]How to see Dart code stack trace instead of Java code stack trace in Crashlytics/Flutter (Android)
我們正在使用 Flutter 的firebase_crashlytics
插件來獲取 Crashlytics 中的錯誤報告。 不幸的是,對於 Android,只有非致命問題顯示了正確的 Dart 代碼堆棧跟蹤。 致命問題僅顯示 Java 代碼堆棧跟蹤,這使得它們很難調試。
有沒有什么方法可以為致命問題獲得正確的 Dart 代碼堆棧跟蹤?
我將此行添加到我的main.dart
以獲取 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);
}
有關更多詳細信息,請參閱: https://pub.dev/packages/firebase_crashlytics
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.