简体   繁体   English

Firebase crashlytics 无法读取崩溃报告

[英]Firebase crashlytics not able to read crash reports

I have configured crashlytics as per Firebase Documentation https://firebase.google.com/docs/crashlytics/get-started?platform=android .我已根据 Firebase 文档https://firebase.google.com/docs/crashlytics/get-started?platform=android配置了 crashlytics But crash reports not generated and uploaded to server.但未生成崩溃报告并上传到服务器。

服务器

Kindly refer my build details.请参考我的构建细节。

Here is our project-level build.gradle这是我们的项目级build.gradle

buildscript {
    
    repositories {
        google()
        jcenter()

        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.1'
        classpath 'com.google.gms:google-services:4.3.10'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'

    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io'}
        maven{ url 'https://maven.google.com/' }
        mavenCentral()

        flatDir {
            dirs 'libs'
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

build.gradle(:app) build.gradle(:应用程序)

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

android {

    compileSdkVersion 28
    defaultConfig {
        applicationId "com.XXX.XXX"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 375
        versionName "2.25.1"

        multiDexEnabled true
        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
        dataBinding {
            enabled = true
        }
        signingConfig signingConfigs.config
    }

    android {
        lintOptions {
            checkReleaseBuilds false
            abortOnError false
        }
    }

    flavorDimensions "appVariant", "projectCode"
    productFlavors {
        A {
            applicationId 'com.XXX.A'
            dimension "appVariant"
        }
        B {
            applicationId 'com.XXX.B'
            dimension "appVariant"
        }
        C {
            applicationId 'com.XXX.C'
            dimension "appVariant"
        }
        D {
            applicationId 'com.XXX.D'
            dimension "appVariant"
        }
        DEV {
            dimension "projectCode"
        }
        QA {
            dimension "projectCode"
        }
        LIVE {
            dimension "projectCode"
        }
        DEMO {
            dimension "projectCode"
        }
        BETA {
            dimension "projectCode"
        }
    }

    applicationVariants.all { variant ->
        variant.outputs.all { output ->
            def project = "XXX"
            def SEP = "_"
            def flavor = variant.productFlavors[0].name
            def projcode = variant.productFlavors[1].name
            def buildType = variant.buildType.name
            def buildTypeName = "";
            switch (buildType) {
                case "ABC": buildTypeName = SEP + "AB"; break;
                case "XYZ": buildTypeName = SEP + "XY"; break;
                default:
                    buildTypeName = "";
            }

            def version = variant.versionName
            def newApkName = project + buildTypeName + SEP + flavor + SEP + projcode + SEP + version + ".apk"

            outputFileName = new File(newApkName)
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    buildTypes {
        debug {

            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
            buildConfigField "String", "AREA", "\"\""
        }
        
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
            buildConfigField "String", "AREA", "\"\""
        }
        ABC {
            signingConfig signingConfigs.config
            minifyEnabled false
            buildConfigField "String", "AREA", "\"_A\""
        }
        XYZ {
            signingConfig signingConfigs.config
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
            buildConfigField "String", "AREA", "\"_X\""
        }
    }
    
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }
}

repositories {

    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }

}

dependencies {
    def room_version = "1.1.1"
    def lifecycle_version = "1.1.1"
    def work_version = "1.0.0-beta01"
    implementation files('libs/commons-net-3.3.jar')
    implementation files('libs/httpclient-4.3.4.jar')
    implementation files('libs/httpcore-4.3.2.jar')
    implementation files('libs/httpmime-4.3.4.jar')
    implementation files('libs/silipmlib.jar')
    implementation files('libs/HyperLogLib8.jar')
    
    // Import the BoM for the Firebase platform
    implementation platform('com.google.firebase:firebase-bom:29.3.0')
    
    implementation 'com.google.firebase:firebase-crashlytics'
    implementation 'com.google.firebase:firebase-analytics'
    implementation 'com.google.firebase:firebase-messaging'

    //dependency for Workmanager
    implementation 'androidx.work:work-runtime:2.0.1'

    //dependencies for Room database
    implementation 'androidx.room:room-runtime:2.0.0'
    //noinspection GradleCompatible
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    annotationProcessor 'androidx.room:room-compiler:2.0.0'
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.material:material:1.0.0'
    //dependency for custom progress dialog

    //dependency for retrofit
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.google.code.gson:gson:2.8.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.1.0'

    //dependency for joda time for date time calculation
    implementation 'joda-time:joda-time:2.10'

    //dependency for glide
    implementation 'com.github.bumptech.glide:glide:3.7.0'

    //dependency for custom toast
    implementation 'com.valdesekamdem.library:md-toast:0.9.0'

    //dependency for marshmallow permission - dexter library
    implementation 'com.karumi:dexter:4.2.0'

    // ViewModel and LiveData
    implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
    annotationProcessor 'androidx.lifecycle:lifecycle-compiler:2.0.0'

    // alternately - if using Java8, use the following instead of compiler
    implementation 'androidx.lifecycle:lifecycle-common-java8:2.0.0'

    implementation 'com.jakewharton:butterknife:10.1.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'

    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
    implementation project(':floatingmenu')
    implementation project(':html2bitmap')
    debugImplementation 'com.amitshekhar.android:debug-db:1.0.4'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
    implementation 'com.github.vipulasri:timelineview:1.0.6'
    implementation 'me.relex:circleindicator:1.2.2@aar'
    implementation 'com.haozhang.libary:android-slanted-textview:1.2'
    implementation 'com.google.android.gms:play-services-maps:15.0.1'
    implementation 'com.google.android.gms:play-services-location:15.0.1'

    // implementation 'com.google.android.gms:play-services-gcm:11.8.0'

    // implementation 'com.google.android.gms:play-services-ads:11.8.0'
    implementation('com.github.florent37:materialviewpager:1.2.3') {
        exclude group: 'com.android.support'
    }

    implementation 'com.orhanobut:dialogplus:1.11@aar'

    //  implementation 'me.dm7.barcodescanner:zbar:1.8.4'
    implementation 'me.dm7.barcodescanner:zxing:1.9'
    implementation 'com.journeyapps:zxing-android-embedded:2.3.0@aar'
    implementation 'com.journeyapps:zxing-android-legacy:2.3.0@aar'
    implementation 'com.journeyapps:zxing-android-integration:2.3.0@aar'
    implementation 'com.google.zxing:core:3.2.0'
    implementation 'net.cachapa.expandablelayout:expandablelayout:2.9.2'
    implementation 'com.github.siyamed:android-shape-imageview:0.9.+@aar'
    implementation files('libs/HyperLogLib8.jar')
    implementation project(':scandecode-release')
    implementation 'com.tt:whorlviewlibrary:1.0.3'
    implementation 'io.reactivex:rxandroid:1.2.1'
    implementation 'io.reactivex:rxjava:1.1.6'
    implementation 'com.jakewharton.rxbinding:rxbinding:0.4.0'
    implementation 'com.jakewharton.rxbinding:rxbinding-design:0.4.0'

    implementation 'org.apache.commons:commons-text:1.7'

    // these are for retrolambda and streams api
    implementation 'com.annimon:stream:1.1.2'

}

With initialisation:初始化:

FirebaseApp.initializeApp(this)
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(true)

And manifest:并体现:

<meta-data
            android:name="firebase_crashlytics_collection_enabled"
            android:value="true" />

Here is the logcat for the Crashlytics/CrashTest crash:这是 Crashlytics/CrashTest 崩溃的 logcat:

2022-04-10 15:53:07.717 21310-21310/com.XXX.XXX E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.XXX.XXX, PID: 21310
    java.lang.RuntimeException: Test Crash
        at com.XXX.XXX.UI.HomeActivity$1.onClick(HomeActivity.java:345)
        at android.view.View.performClick(View.java:6392)
        at android.view.View$PerformClick.run(View.java:25133)
        at android.os.Handler.handleCallback(Handler.java:790)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:198)
        at android.app.ActivityThread.main(ActivityThread.java:7055)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:523)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:836)

This is the log that we receive when app relaunched after crash.这是我们在应用程序崩溃后重新启动时收到的日志。

D:\user\Android Projects\XXX>adb logcat -s FirebaseCrashlytics
--------- beginning of main
--------- beginning of system
--------- beginning of crash
04-10 15:54:56.911 22018 22018 I FirebaseCrashlytics: Initializing Firebase Crashlytics 18.2.9 for com.XXX.XXX
04-10 15:54:56.926 22018 22018 D FirebaseCrashlytics: Crashlytics automatic data collection ENABLED by API.
04-10 15:54:56.940 22018 22018 D FirebaseCrashlytics: AnalyticsConnector now available.
04-10 15:54:56.943 22018 22018 D FirebaseCrashlytics: Registered Firebase Analytics listener.
04-10 15:54:56.948 22018 22018 D FirebaseCrashlytics: Mapping file ID is: 00000000000000000000000000000000
04-10 15:54:56.958 22018 22018 D FirebaseCrashlytics: Checking for cached settings...
04-10 15:54:56.992 22018 22018 D FirebaseCrashlytics: Loaded cached settings: {"settings_version":3,"cache_duration":86400,"features":{"collect_logged_exceptions":true,"collect_reports":
true,"collect_analytics":false,"prompt_enabled":false,"push_enabled":false,"firebase_crashlytics_enabled":false,"collect_anrs":true,"collect_metric_kit":false},"app":{"status":"activated
","update_required":false,"report_upload_variant":2,"native_report_upload_variant":2},"fabric":{"org_id":"62513aa60277ea5e0396d4ef","bundle_id":"com.XXX.XXX"},"on_demand_
upload_rate_per_minute":10,"on_demand_backoff_base":1.2,"on_demand_backoff_step_duration_seconds":60,"expires_at":1649666891559}
04-10 15:54:56.996 22018 22018 D FirebaseCrashlytics: Crashlytics automatic data collection ENABLED by API.
04-10 15:54:57.113 22018 22018 D FirebaseCrashlytics: Successfully configured exception handler.
04-10 15:54:57.116 22018 22049 D FirebaseCrashlytics: Opening a new session with ID 6252B07803E20001560228F94565CB5E
04-10 15:54:57.183 22018 22049 D FirebaseCrashlytics: Registered Firebase Analytics event receiver for breadcrumbs
04-10 15:54:58.013 22018 22018 D FirebaseCrashlytics: Crashlytics automatic data collection ENABLED by API.
04-10 15:54:58.642 22018 22018 D FirebaseCrashlytics: Crashlytics automatic data collection ENABLED by API.

These are set to false in cached settings:这些在缓存设置中设置为 false:

"collect_analytics":false,
"firebase_crashlytics_enabled":false,

This setting was weird.这个设定很奇怪。 Both of them are false for some reason though I never did turn them off explicitly.尽管我从未明确关闭它们,但出于某种原因它们都是错误的。 Never even played with these settings.从来没有玩过这些设置。

Not sure what is wrong .不知道哪里出了问题 Any help will be appreciated.任何帮助将不胜感激。

Solved...解决了...
There was another utility logger library initialized in the application class that prevented crashlytics from collecting log.在应用程序 class 中初始化了另一个实用程序记录器库,它阻止 crashlytics 收集日志。 https://github.com/hypertrack/hyperlog-android . https://github.com/hypertrack/hyperlog-android This library prevented the app from crashing.该库防止应用程序崩溃。 As we know crashlytics crash report collection works only if the app crashes.正如我们所知,crashlytics 崩溃报告收集仅在应用程序崩溃时才有效。 As I threw the uncaught exception... the app froze, and it didn't crash.当我抛出未捕获的异常时......应用程序冻结了,并且没有崩溃。 After I commented the code that initializes this library from the application class. It started working like a charm.在我评论了从应用程序 class 初始化这个库的代码之后。它开始像魅力一样工作。

See the reply that I got from GitHub.看我GitHub的回复。 在此处输入图像描述 The first one seems to be my issue.第一个似乎是我的问题。

Also the initialization & manifest part is not necessary unless you want to explicitly enable/disable crashlytics working.此外,除非您想明确启用/禁用 crashlytics 工作,否则初始化和清单部分不是必需的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM