我的 Flutter 应用程序的代码库中某处抛出异常。
然而这是控制台输出的内容:
[VERBOSE-2:dart_error.cc(16)] Unhandled exception:
// (nothing, should be printing stack-trace or error message here)
没有堆栈跟踪使得很难找到这个错误的来源。
有谁知道堆栈跟踪或错误消息不打印是否正常?
是否有一种模式可以让我运行 flutter run
以查看有关所抛出错误的更多信息?
设置:
flutter: 0.2.8
running on an iphone device
最佳答案
对迟钝的 iOS 物理设备/抖动错误的一种见解是查看物理设备控制台和设备日志。就我而言,我正在使用 iPhone 6S 尝试在相机应用程序上工作。
日志可通过 Xcode --> 窗口 --> 设备和模拟器 --> 选择设备,然后选择“查看设备日志”或“打开控制台”按钮。选择“错误和故障”按钮可以使这更容易一些。
在我的案例中,我发现了一个在我的开发环境中根本看不到的相机权限错误。该应用程序刚刚崩溃,我不知道为什么...然后我在日志中发现了这个...
error 21:51:03.438135 -0700 tccd Refusing TCCAccessRequest for service kTCCServiceCamera and client /var/containers/Bundle/Application/A817FC3E-F55D-46F5-9EF2-372E4FC90B1B/Runner.app[319] without NSCameraUsageDescription key
error 21:51:03.476854 -0700 Runner This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data.
解决我在 iPhone 上的相机困境的方法如下:
- 找到 Info.plist 文件(位置 = flutter_image_picker/ios/Runner/Info.plist )
添加以下键/字符串对:
<key>NSCameraUsageDescription</key>
<string>Camera used to take photos in support of the app.</string>
全部修复!
关于dart - Flutter 运行不输出错误消息或堆栈跟踪 ("[VERBOSE-2:dart_error.cc(16)] Unhandled exception:"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49959278/