패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.0.0

flutter_crashlytics

Android 및 iOS에서 Crashlytics 보고 기능을 활성화하는 Flutter 플러그인으로, 보고서에 사용자 정의 로그 및 정보를 추가할 수 있는 기능도 제공합니다.

30일 다운로드
460
좋아요
24
Pub 점수
40

패키지 설치

flutter pub add flutter_crashlytics

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Flutter Crashlytics는 Android 및 iOS용 Flutter 앱에 Firebase Crashlytics를 통합하여 자동 크래시 보고 기능을 제공하는 플러그인입니다. 개발자는 사용자 정의 메시지와 메타데이터를 포함한 상세한 크래시 로그를 캡처하고 전송할 수 있어 문제 진단에 도움이 됩니다. 이 플러그인은 실시간으로 크래시 및 오류에 대한 인사이트를 제공함으로써 앱의 안정성을 향상시키며 디버깅과 성능 최적화를 지원합니다. Firebase 백엔드 서비스와 원활하게 작동하며 다양한 플랫폼에서 앱 건강 상태를 모니터링할 수 있는 도구를 제공합니다.

사용 사례

  • 프로덕션에서 앱 크래시 모니터링
  • 세부 스택 트레이스를 사용하여 런타임 오류 디버깅
  • 크래시 보고서에 사용자 정의 로그 추가
  • 시간이 지남에 따라 앱 안정성 추적
  • Firebase 분석 대시보드와의 통합

주요 기능

  • 자동 충돌 감지
  • 사용자 정의 로그 및 메타데이터 지원
  • 크로스 플랫폼의 안드로이드 및 iOS 호환성
  • 실시간 크래시 보고
  • Firebase Crashlytics 대시보드와의 통합

적합한 대상

  • Firebase를 사용하는 모바일 앱 개발자
  • 앱 신뢰성에 집중하는 팀
  • 크래시 분석이 필요한 프로젝트
  • 생산용 플러터 앱을 개발하는 개발자
  • 오류 추적 및 진단이 필요한 앱

고려 사항

  • Firebase 프로젝트 설정이 필요합니다
  • Android 및 iOS 플랫폼에만 제한됨
  • 앱 시작 시 올바른 초기화가 필요합니다
  • 일부 기기에서는 추가 권한이 필요할 수 있습니다
  • 데이터 과부하를 방지하기 위해 사용자 정의 로그는 신중하게 사용해야 합니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

flutter_crashlytics

pub package

Flutter plugin to enable Crashlytics reporting.

Setup

Firebase Crashlytics

If you're using Firebase instead of Fabric, you must first setup your app to use Firebase as per this tutorial. https://codelabs.developers.google.com/codelabs/flutter-firebase/#4

The instructions are the same for Fabric and Firebase, except that for Firebase, you don't get an API key so you don't have to add it anywhere.

Android

To setup Crashlytics on Android side, you need to set the Fabric ID in your manifest like this: (Only do this if using Fabric, not Firebase as you will not have an API Key)

 <meta-data
            android:name="io.fabric.ApiKey"
            android:value="YOUR_ID_HERE" />

You also need to change your build.gradle file like this:

buildscript {
    repositories {
        ...
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
        ...
    }
}

And apply the fabric plugin apply plugin: 'io.fabric'

Nothing more.

Symbolicating Native Android Crashes

Unfortunately, even pure Dart projects can't always protect you from native crashes. Without the following setup, a native crash like SIGSEGV will appear as a blank stacktrace in Crashlytics. Here's how to get some symbols:

Add the following to build.gradle, after apply plugin: 'io.fabric':

crashlytics {
    enableNdk true
    androidNdkOut "../../debugSymbols"
    androidNdkLibsOut "../../build/app/intermediates/transforms/stripDebugSymbol/release/0/lib"
}

Ensure that the NDK bundle is installed or the stripDebugSymbol directory won't get created.

Now setup a release script to populate the debugSymbols directory, guided by the instructions from https://github.com/flutter/flutter/wiki/Crashes

# Build our app like usual
flutter -v build apk --release

### BEGIN MODIFICATIONS

# Copy mergeJniLibs to debugSymbols
cp -R ./build/app/intermediates/transforms/mergeJniLibs/release/0/lib debugSymbols

# The libflutter.so here is the same as in the artifacts.zip found with symbols.zip
cd debugSymbols/armeabi-v7a

# Download the corresponding libflutter.so with debug symbols
ENGINE_VERSION=`cat $HOME/flutter/bin/internal/engine.version`
gsutil cp gs://flutter_infra/flutter/${ENGINE_VERSION}/android-arm-release/symbols.zip .

# Replace libflutter.so
unzip -o symbols.zip
rm -rf symbols.zip

# Upload symbols to Crashlytics
cd ../../android
./gradlew crashlyticsUploadSymbolsRelease

### END MODIFICATIONS

# Release your app like usual
cd ../..
fastlane submit_playalpha
iOS

On iOS side you need to set your Fabric ID under your Info.plist like: (Only do this if using Fabric, not Firebase as you will not have an API Key)

<key>Fabric</key>
    <dict>
        <key>APIKey</key>
        <string>YOUR_ID_HERE</string>
        <key>Kits</key>
        <array>
            <dict>
                <key>KitInfo</key>
                <dict/>
                <key>KitName</key>
                <string>Crashlytics</string>
            </dict>
        </array>
    </dict>

Turn off automatic collection with a new key to your Info.plist file (GDPR compliency if you want it):

Key: firebase_crashlytics_collection_enabled

Value: false

Don't forget to add your Run Script step (with any version of Xcode) on the build phases tab. If using Xcode 10, you also must add your app's built Info.plist location to the Build Phase's Input Files field:

$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)

ios run script

That's it :)

Flutter

All you need to do under your code is to let the plugin handle the Flutter crashes.

Your main method should look like:

void main() async {
  bool isInDebugMode = false;

  FlutterError.onError = (FlutterErrorDetails details) {
    if (isInDebugMode) {
      // In development mode simply print to console.
      FlutterError.dumpErrorToConsole(details);
    } else {
      // In production mode report to the application zone to report to
      // Crashlytics.
      Zone.current.handleUncaughtError(details.exception, details.stack);
    }
  };

  await FlutterCrashlytics().initialize();

  runZoned<Future<Null>>(() async {
    runApp(MyApp());
  }, onError: (error, stackTrace) async {
    // Whenever an error occurs, call the `reportCrash` function. This will send
    // Dart errors to our dev console or Crashlytics depending on the environment.
    await FlutterCrashlytics().reportCrash(error, stackTrace, forceCrash: false);
  });
}

forceCrash allows you to have a real crash instead of the red screen, in that case the exception will be tagged as fatal.

API available

  • Add log to crash reporting with log(String msg, {int priority, String tag})
  • Add manual log to crash reporting with logException(Error/Exception exception, Stacktrace stack)
  • Add user info to crash reporting with setUserInfo(String identifier, String email, String name)
  • Add general info to crash reporting with setInfo(String key, dyncamic value)

Limitation

This plugin uses Crashlytics SDK to log manual dart crashes, all manually logged crashes are tagged as non fatal under Crashlytics, that's a limitation of the SDK.

You can bypass that limitation with the forceCrash parameter, instead of the red screen an actual crash will be appended, the crash will be tagged as fatal.

On iOS fatal crash has their dart stacktrace under the Logs tab of Crashlytics, that's a limitation of iOS that prevents developers to set a custom stacktrace to an exception.

Contribution

We love contributions! Don't hesitate to open issues and make pull request to help improve this plugin.

카테고리

의존성

의존성 목록 1 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.