GardenMobile & interfaces

An earlier Flutter Crashlytics error pipeline

Native build hooks and separate framework, isolate, and zoned-error paths in a historical integration.

A crash-reporting integration has several boundaries: the native build uploads the right artifacts, the runtime initializes reporting, and different error paths reach the reporter. This older note declared:

dependencies:
  # firebase
  firebase_core: ^0.5.0
  firebase_crashlytics: ^0.2.1

Native build integration

buildscript {
    ext.kotlin_version = '1.3.61'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'
        classpath 'com.google.gms:google-services:4.3.4'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}
dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.firebase:firebase-analytics:17.5.0'
    implementation 'com.google.firebase:firebase-crashlytics:17.2.2'
}

apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.gms.google-services'

The iOS build phase ran:

"${PODS_ROOT}/FirebaseCrashlytics/run"

Those are source instructions, not build scripts executed by this website.

Runtime error paths

import 'dart:async';
import 'dart:isolate';

import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:flutter/material.dart';
import 'package:nft/my_app.dart';

Future<void> main() async {

  /// WidgetsFlutterBinding
  WidgetsFlutterBinding.ensureInitialized();

  // Initializing FlutterFire
  await Firebase.initializeApp();
  
  // Initialize Crash report
  await FirebaseCrashlytics.instance
      .setCrashlyticsCollectionEnabled(true);
  
  // Pass all uncaught errors from the framework to Crashlytics.
  FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterError;

  // Errors outside of Flutter
  Isolate.current.addErrorListener(RawReceivePort((List<dynamic> pair) async {
    final List<dynamic> errorAndStacktrace = pair;
    await FirebaseCrashlytics.instance.recordError(
      errorAndStacktrace.first,
      errorAndStacktrace.last as StackTrace,
    );
  }).sendPort);

  // Zoned Errors
  runZonedGuarded<Future<void>>(() async {
    await myMain();
  }, FirebaseCrashlytics.instance.recordError);
}

The example handles framework errors, isolate messages, and a guarded zone separately. The isolate message’s stack-trace shape and the asynchronous initialization sequence need version-specific review; routing an exception is not the same as proving a report was received.

The original test action

        FlatButton(
          onPressed: () {
            // Forcing a crash
            FirebaseCrashlytics.instance.crash();
          },
          child: const Text('Crash'),
        ),

The source deliberately triggered a crash to inspect reporting. That action was not run for this revision. Older dependency and API names remain historical, and no crash or telemetry was sent.

← Back to the garden