简体   繁体   English

flutter中release模式如何检测异常

[英]How to detect exceptions in release mode in flutter

My flutter app works fine on debug and profile builds but crashes on release build.我的 flutter 应用程序在调试和配置文件构建时运行良好,但在发布构建时崩溃。 I would like to understand why it crashes on release build.我想了解为什么它会在发布版本上崩溃。 Is there any way to see exceptions like I can see in debug mode?有没有办法像我在调试模式下看到的那样看到异常? It is not enough to see print logs which I can see print logs and does not help.看到打印日志是不够的,我可以看到打印日志并且没有帮助。 I need to know where and why the app crashes.我需要知道应用程序崩溃的位置和原因。 So it would be helpful if I can see exception logs.所以如果我能看到异常日志会很有帮助。 I suspect insufficient pro guard rules causes this problem but I don't know which rules should I add more.我怀疑 pro guard 规则不足会导致此问题,但我不知道应该添加哪些规则。 If I can see exception log, this would help me to add correct rules to pro guard.如果我能看到异常日志,这将帮助我向 pro guard 添加正确的规则。

Connect your physical device or use any emulator and then run your app using this command flutter run --release from the terminal.连接您的物理设备或使用任何模拟器,然后从终端使用此命令flutter run --release运行您的应用程序。 You'd be able to view the logs in the release mode您将能够在发布模式下查看日志

I suggest to use third party tool to track production exceptions.我建议使用第三方工具来跟踪生产异常。 I recommend Sentry (I am not employee, just happy user) as it is easy to configure and works out of the box.我推荐 Sentry(我不是员工,只是快乐的用户),因为它易于配置并且开箱即用。

Check https://pub.dev/packages/sentry package and https://sentry.io/ for documentation.检查https://pub.dev/packages/sentry package 和https://sentry.io/文档。

Please note that Sentry works ONLY at production.请注意,Sentry 仅在生产环境中工作。 Also note that if your app crashes, the error is logged next time you try to open the app , and not immediately after the crash.另请注意,如果您的应用程序崩溃,错误会在您下次尝试打开该应用程序时记录下来,而不是在崩溃后立即记录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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