Android アクセスの Firebase クラッシュ統計

導入

Firebase は
、Android レイヤーとネイティブ レイヤーの例外情報のキャプチャをサポートし、
致命的ではない例外情報と統計的に重要な例外情報を分析用に設定することをサポートします。

クラッシュ統計にアクセスする

モジュラーbuild.gradle

plugins {
    id 'com.google.firebase.crashlytics'
}
dependencies {
implementation platform('com.google.firebase:firebase-bom:31.1.1')
implementation 'com.google.firebase:firebase-crashlytics-ktx'
}

ルートディレクトリbuild.gradle

buildscript {
    dependencies {
        classpath 'com.google.gms:google-services:4.3.13'
        // Add the dependency for the Crashlytics Gradle plugin
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.4'
    }
}

これで完了です。google-services.jsonファイルの設定を忘れないでください

C レイヤーのクラッシュ統計へのアクセス

前のモジュールに基づいてbuild.gradle

buildTypes {
      release {
          // Add this extension
          firebaseCrashlytics {
                // Enable processing and uploading of native symbols to Firebase servers.
                // By default, this is disabled to improve build speeds.
                // This flag must be enabled to see properly-symbolicated native
                // stack traces in the Crashlytics dashboard.
                nativeSymbolUploadEnabled true
                strippedNativeLibsDir 'build/intermediates/stripped_native_libs/release/out/lib'
                unstrippedNativeLibsDir 'build/intermediates/merged_native_libs/release/out/lib'
            }
       }
}

dependencies {
implementation 'com.google.firebase:firebase-crashlytics-ndk'
}

非致命的

ログイン失敗、トライキャッチ、その他の異常情報は、Non-fatals を通じてプラットフォームにアップロードして分析できます。

FirebaseCrashlytics.getInstance().recordException(e)

プロジェクト logUtils のツール クラス構成で使用できます

fun w(e: Exception) {
    
    
   Log.w(TAG, e)
   //上报到FireBase
   FirebaseCrashlytics.getInstance().recordException(e)
}

材料

公式ドキュメントは C 例外をキャッチします
https://stackoverflow.com/questions/65961515/gradleException-crashlytics-could-not-determine-tripped-untripped-native-libr

おすすめ

転載: blog.csdn.net/Android_yh/article/details/129722042