Solvedflutterfire [firebase_crashlytics] Either the Crashlytics plugin doesn't work, or the instruction is wrong
✔️Accepted Answer
Having the same issue even with a really simple app:
void main() {
Crashlytics.instance.enableInDevMode = true;
FlutterError.onError = Crashlytics.instance.recordFlutterError;
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Test',
home: Scaffold(
appBar: AppBar(
title: Text('Test'),
),
floatingActionButton: FloatingActionButton(
onPressed: () => Crashlytics.instance.crash(),
child: Icon(Icons.error),
),
),
);
}
}
Other Answers:
I'm wondering if this is related to a previous issue with Crashlytics plugin:
#1149
Please try a couple of things:
-
If you are using an IDE the error may be caught before it gets to the Crashlytics plugin and thus not reported. To avoid this run the app directly using
flutter run
and see if the error is reported then. -
Errors are only reported on app restart. So please look out for the
reported
log statement on app restart. -
Are you seeing this with the Crashlytics plugin example app?
@kroikie is it my impression or all Flutter crashes are not being processed as Fatal Exceptions by Crashlytics, so they are only reported if the user restarts the application, in opposition with the native Android behavior, whereas Fatal Exceptions are communicated right away and Non-Fatal only after a restart?
after some digging on this, make sure you understand how crashlytics works. Specifically, crashlytics does not send errors to firebase when an error occurs. Specifically, it sends errors to firebase the next time you start the app. So you must force the app to entirely stop and restart before anything will showup on firebase. Hot reload doesn't count.
I followed the setup instruction from Pub: https://pub.dartlang.org/packages/firebase_crashlytics
I also enabled debug logging: https://firebase.google.com/docs/crashlytics/force-a-crash
Crashlytics seems to be running when my app is started:
And, according to https://github.com/flutter/plugins/blob/master/packages/firebase_crashlytics/example/lib/main.dart I can verify by manually throwing error:
(I've set
enableInDevMode
totrue
as well).The error is indeed thrown, as shown in Android Studio "Run" panel:
But my dashboard ( https://console.firebase.google.com/u/0/project/MYPROJECT/crashlytics/app/android:com.myapp/issues?state=open&time=last-seven-days&type=all ) says my app is 100% error-free.
And ABD log doesn't show anything.
What did I miss?
EDIT: Flutter doctor result: