firebaseflutterandroid-ndkcrashlyticscrashlytics-android

Firebase Crashlytics NDK With Flutter


I have a C++ backend and I would like to get reports of NDK crashes. My problem is crashlytics with NDK seems to be only available for native Android, not flutter. You can see it here. I have crashlytics setup in Flutter with FireFlutter and I tried to catch NDK errors with the following in flutter but it of course does not work:

// Pass all uncaught errors from the framework to Crashlytics.
    FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterError;

    // To catch errors that happen outside of the Flutter context, install an error listener on the current Isolate:
    Isolate.current.addErrorListener(RawReceivePort((pair) async {
      final List<dynamic> errorAndStacktrace = pair;
      await FirebaseCrashlytics.instance.recordError(
        errorAndStacktrace.first,
        errorAndStacktrace.last,
      );
    }).sendPort);

I searched this for so long but I could not find any resources to get crashlytics NDK to work with Flutter. I am also using other firebase services in flutter such as Remote Config, Analytics, Performance etc. How may I use crashlytics with NDK in Flutter? Is this possible at all?


Solution

  • Broadly speaking, anything that is available for Android is already available for Flutter. That is how many phugins work on flutter, they're implemented in native and bridged to flutter. Similarly, for adding NDK crashalytics, you can treat the /android folder of your flutter project as a native android project and proceed with all the steps that are mentioned in this link to add NDK crashalytics to a native android app.