Flutter:Flutter Firebase Crashlytics 未针对 iOS 显示
Posted
技术标签:
【中文标题】Flutter:Flutter Firebase Crashlytics 未针对 iOS 显示【英文标题】:Flutter: Flutter Firebase Crashlytics not showing for iOS 【发布时间】:2020-05-23 10:57:16 【问题描述】:我无法为 ios 显示崩溃日志(适用于 android)。 我已经测试了以下内容:
-
使用“flutter run”启动应用程序,分离调试器,触发崩溃并重新启动应用程序(多次)
还尝试从 XCode 运行然后停止应用程序并触发崩溃并重新启动应用程序
并不是说崩溃实际上不会导致应用程序崩溃,但我不知道如何从颤振中做到这一点
启动:
void main()
// Set `enableInDevMode` to true to see reports while in debug mode
// This is only to be used for confirming that reports are being
// submitted as expected. It is not intended to be used for everyday
// development.
Crashlytics.instance.enableInDevMode = true;
// Pass all uncaught errors from the framework to Crashlytics.
FlutterError.onError = Crashlytics.instance.recordFlutterError;
runApp(MyApp());
触发器:
FlatButton(
child: const Text('Crash'),
onPressed: ()
Crashlytics.instance.crash();
Crashlytics.instance.log("msg");
Crashlytics.instance.recordFlutterError(new FlutterErrorDetails());
Crashlytics.instance.recordError(new Exception("test"), null);
),
设置 iOS:
日志:
2020-02-07 10:47:59.988421+0100 Runner[32021:139387] - <AppMeasurement>[I-ACS036002] Analytics screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name. To disable screen reporting, set the flag FirebaseScreenReportingEnabled to NO (boolean) in the Info.plist
2020-02-07 10:48:00.467672+0100 Runner[32021:139200] Configuring the default Firebase app...
2020-02-07 10:48:00.509841+0100 Runner[32021:139388] 6.12.0 - [Firebase/Core][I-COR000004] App with name __FIRAPP_DEFAULT does not exist.
2020-02-07 10:48:00.564015+0100 Runner[32021:139403] 6.12.0 - [Firebase/Analytics][I-ACS023007] Analytics v.60105000 started
2020-02-07 10:48:00.633609+0100 Runner[32021:139403] 6.12.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled
2020-02-07 10:48:00.686296+0100 Runner[32021:139428] flutter: Observatory listening on http://127.0.0.1:51095/Jl5T2U0QjXU=/
2020-02-07 10:48:00.703093+0100 Runner[32021:139200] [Crashlytics] Version 3.14.0 (144)
2020-02-07 10:48:00.741256+0100 Runner[32021:139200] Configured the default Firebase app __FIRAPP_DEFAULT.
2020-02-07 10:48:00.746360+0100 Runner[32021:139200] [Fabric] [Fabric +with] called multiple times. Only the first call is honored, please pass all kits you wish to initialize
2020-02-07 10:48:00.788062+0100 Runner[32021:139387] 6.12.0 - [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. If you'd prefer to manually integrate Firebase Messaging, add "FirebaseAppDelegateProxyEnabled" to your Info.plist, and set it to NO.
to ensure proper integration.
2020-02-07 10:48:00.907902+0100 Runner[32021:139387] [Fabric] failed to download settings Error Domain=FABNetworkError Code=-5 "(null)" UserInfo=status_code=403, type=2, request_id=, content_type=application/json; charset=utf-8
2020-02-07 10:48:03.072501+0100 Runner[32021:139403] 6.12.0 - [Firebase/Messaging][I-FCM012002] Error in application:didFailToRegisterForRemoteNotificationsWithError: remote notifications are not supported in the simulator
2020-02-07 10:48:03.100106+0100 Runner[32021:139403] 6.12.0 - [Firebase/Messaging][I-FCM012002] Error in application:didFailToRegisterForRemoteNotificationsWithError: remote notifications are not supported in the simulator
2020-02-07 10:49:51.975510+0100 Runner[32021:139410] flutter: Flutter error caught by Crashlytics plugin:
2020-02-07 10:49:52.003794+0100 Runner[32021:139410] flutter: ══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════
2020-02-07 10:49:52.004161+0100 Runner[32021:139410] flutter: The following StateError was thrown while handling a gesture:
2020-02-07 10:49:52.004429+0100 Runner[32021:139410] flutter: Bad state: Error thrown by Crashlytics plugin
2020-02-07 10:49:52.005323+0100 Runner[32021:139410] flutter:
2020-02-07 10:49:52.006106+0100 Runner[32021:139410] flutter: When the exception was thrown, this was the stack:
2020-02-07 10:49:52.006490+0100 Runner[32021:139410] flutter: #0 Crashlytics.crash (package:firebase_crashlytics/src/firebase_crashlytics.dart:54:5)
2020-02-07 10:49:52.007125+0100 Runner[32021:139410] flutter: #1 _InformationPageState.build.<anonymous closure> (package:mainapp/pages/informationpage.dart:71:42)
2020-02-07 10:49:52.007856+0100 Runner[32021:139410] flutter: #2 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:706:14)
2020-02-07 10:49:52.008560+0100 Runner[32021:139410] flutter: #3 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:789:36)
2020-02-07 10:49:52.008828+0100 Runner[32021:139410] flutter: #4 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
2020-02-07 10:49:52.009341+0100 Runner[32021:139410] flutter: #5 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:486:11)
2020-02-07 10:49:52.009923+0100 Runner[32021:139410] flutter: #6 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:264:5)
2020-02-07 10:49:52.010181+0100 Runner[32021:139410] flutter: #7 BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:236:7)
2020-02-07 10:49:52.010389+0100 Runner[32021:139410] flutter: #8 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
2020-02-07 10:49:52.011013+0100 Runner[32021:139410] flutter: #9 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:222:20)
2020-02-07 10:49:52.011399+0100 Runner[32021:139410] flutter: #10 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
2020-02-07 10:49:52.011511+0100 Runner[32021:139410] flutter: #11 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
2020-02-07 10:49:52.011970+0100 Runner[32021:139410] flutter: #12 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
2020-02-07 10:49:52.012203+0100 Runner[32021:139410] flutter: #13 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
2020-02-07 10:49:52.012346+0100 Runner[32021:139410] flutter: #17 _invoke1 (dart:ui/hooks.dart:273:10)
2020-02-07 10:49:52.012806+0100 Runner[32021:139410] flutter: #18 _dispatchPointerDataPacket (dart:ui/hooks.dart:182:5)
2020-02-07 10:49:52.012924+0100 Runner[32021:139410] flutter: (elided 3 frames from package dart:async)
2020-02-07 10:49:52.013019+0100 Runner[32021:139410] flutter:
2020-02-07 10:49:52.013112+0100 Runner[32021:139410] flutter: Handler: "onTap"
2020-02-07 10:49:52.013202+0100 Runner[32021:139410] flutter: Recognizer:
2020-02-07 10:49:52.013695+0100 Runner[32021:139410] flutter: TapGestureRecognizer#89339
2020-02-07 10:49:52.014395+0100 Runner[32021:139410] flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
2020-02-07 10:49:52.086067+0100 Runner[32021:139410] flutter: firebase_crashlytics: Error reported to Crashlytics.
2020-02-07 10:49:52.739934+0100 Runner[32021:139410] flutter: Flutter error caught by Crashlytics plugin:
2020-02-07 10:49:52.743795+0100 Runner[32021:139410] flutter: ══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════
2020-02-07 10:49:52.743983+0100 Runner[32021:139410] flutter: The following StateError was thrown while handling a gesture:
2020-02-07 10:49:52.744139+0100 Runner[32021:139410] flutter: Bad state: Error thrown by Crashlytics plugin
2020-02-07 10:49:52.744313+0100 Runner[32021:139410] flutter:
2020-02-07 10:49:52.744542+0100 Runner[32021:139410] flutter: When the exception was thrown, this was the stack:
2020-02-07 10:49:52.744708+0100 Runner[32021:139410] flutter: #0 Crashlytics.crash (package:firebase_crashlytics/src/firebase_crashlytics.dart:54:5)
2020-02-07 10:49:52.744848+0100 Runner[32021:139410] flutter: #1 _InformationPageState.build.<anonymous closure> (package:mainapp/pages/informationpage.dart:71:42)
2020-02-07 10:49:52.744946+0100 Runner[32021:139410] flutter: #2 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:706:14)
2020-02-07 10:49:52.745148+0100 Runner[32021:139410] flutter: #3 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:789:36)
2020-02-07 10:49:52.751009+0100 Runner[32021:139410] flutter: #4 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
2020-02-07 10:49:52.751514+0100 Runner[32021:139410] flutter: #5 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:486:11)
2020-02-07 10:49:52.751758+0100 Runner[32021:139410] flutter: #6 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:264:5)
2020-02-07 10:49:52.752005+0100 Runner[32021:139410] flutter: #7 BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:236:7)
2020-02-07 10:49:52.752543+0100 Runner[32021:139410] flutter: #8 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
2020-02-07 10:49:52.753430+0100 Runner[32021:139410] flutter: #9 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:222:20)
2020-02-07 10:49:52.753672+0100 Runner[32021:139410] flutter: #10 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
2020-02-07 10:49:52.755470+0100 Runner[32021:139410] flutter: #11 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
2020-02-07 10:49:52.755806+0100 Runner[32021:139410] flutter: #12 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
2020-02-07 10:49:52.756565+0100 Runner[32021:139410] flutter: #13 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
2020-02-07 10:49:52.757056+0100 Runner[32021:139410] flutter: #17 _invoke1 (dart:ui/hooks.dart:273:10)
2020-02-07 10:49:52.757240+0100 Runner[32021:139410] flutter: #18 _dispatchPointerDataPacket (dart:ui/hooks.dart:182:5)
2020-02-07 10:49:52.757838+0100 Runner[32021:139410] flutter: (elided 3 frames from package dart:async)
2020-02-07 10:49:52.758046+0100 Runner[32021:139410] flutter:
结果:
编辑1: 如果我查看 project.pbxproj,在他们的示例中 https://github.com/FirebaseExtended/flutterfire/blob/master/packages/firebase_crashlytics/example/ios/Runner.xcodeproj/project.pbxproj 它说:
输入路径 = ( "$(SRCROOT)/newInputFile", );
而我的说:
输入路径 = ( "$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)", );
根据他们的文档https://pub.dev/packages/firebase_crashlytics .会是这个原因吗?
【问题讨论】:
在此处关注问题:github.com/FirebaseExtended/flutterfire/issues/1951 iOS Crashlytics 仅适用于软件包版本 ^ 0.2.0。 firebase.flutter.dev/docs/crashlytics/overview 【参考方案1】:$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH) 应该只为 Xcode 10 添加
另外,您的网络上是否有任何广告拦截软件设置?因为这就是阻止我记录错误的原因。
【讨论】:
我尝试过使用和不使用 $(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)。我在虚拟机上运行模拟器,但没有安装任何软件。 macOS会默认阻止它吗?我还在没有任何日志的真实设备上崩溃了应用程序。 您有适用于 iOS 的 Flutter 和 Crashlytics 解决方案吗? 工作示例在这里github.com/FirebaseExtended/flutterfire/tree/master/packages/… 如果您遵循文档并且该示例将起作用。 我按照那个例子,iOS没有任何成功 @ViktorMorin 你找到解决方案了吗?【参考方案2】:我今天设法让它工作,我错过了您需要在 Firebase 控制台中添加适用于 iOS 的 SDK。
第 1 步:在 Firebase 控制台中设置 Crashlytics 点击 Firebase 控制台左侧导航面板中的 Crashlytics。
如果您的 Firebase 项目中注册了多个应用,请从控制台顶部栏中 Crashlytics 旁边的下拉列表中选择您刚刚添加的应用。
点击添加 SDK。
https://firebase.google.com/docs/crashlytics/get-started
【讨论】:
【参考方案3】:我只是在 --release 模式下运行应用程序,它在控制台中显示了第一个异常。
flutter run --release
注意:我在所有其他答案中都做了所有事情,但仍然没有为我工作?
【讨论】:
这在运行发布模式后对我有用【参考方案4】:您是否将 GoogleService.plist 添加到您的项目中?由于我的控制台输出看起来像 Firebase 找不到配置。
另外请记住,由于您有 spark 计划,因此崩溃会延迟一天才会出现在您的在线仪表板中。对于付费版本,我不知道延迟。
【讨论】:
GoogleService-Info.plist 位于 appName\ios\runner\GoogleService-Info.plist,我可以在 Firebase 仪表板的分析中看到 iOS 的安装数量,所以我猜这可行。我也等了超过 1 天(Android 通常在 5 分钟后出现)【参考方案5】:我也遇到了同样的问题。 Android 版本正在运行,但是,iOS 版本在 crashlytics 中没有显示任何内容。请在您的手机上试用。 iOS 模拟器不会被 Firebase 识别为合法设备。
【讨论】:
【参考方案6】:将以下内容应用于您的 Xcode 项目
-
从 Xcode 中,从项目导航中选择 Runner。
选择Build Phases标签,然后点击+ > New Run Script Phase。
将
$PODS_ROOT/FirebaseCrashlytics/run
添加到键入脚本...文本框。
(可选)您还可以将应用程序的构建Info.plist
位置提供给构建阶段的输入文件字段:例如:$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)
您的构建阶段将是这样的
然后重建你的应用程序
完成后,重新构建您的 Flutter 应用程序:
$ flutter run
【讨论】:
我做了所有这些事情,但完全没有在 ios 上安装 crashlystic以上是关于Flutter:Flutter Firebase Crashlytics 未针对 iOS 显示的主要内容,如果未能解决你的问题,请参考以下文章
添加flutter_firebase_ui后flutter应用程序崩溃
我在运行我的应用程序(Flutter、FireBase)时收到此 E/flutter (25055) 错误