Firebase 崩溃报告在 Firebase crashlytics 更新后未出现在 android 中

Firebase Crash report not appearing in android after Firebase crashlytics update

在 Android 中更新 Firebase crashlytics 依赖项后,我无法查看崩溃报告。甚至我的 Firebase 控制台也显示“您安装了最新的 SDK”。请参考我的构建细节。

build.gradle

buildscript {
    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.2'
        classpath 'com.google.gms:google-services:4.3.4'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
    }
}

allprojects {
    repositories {
        google()
        mavenLocal()
        mavenCentral()
        maven {                                 
            url 'https://maven.google.com/'
            name 'Google'
        }
        jcenter()
    }
}

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

build.gradle(:app)

apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.crashlytics'

android {
    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }

    compileSdkVersion 28

    defaultConfig {
        applicationId "com.XXX.XXX"
        minSdkVersion 16
        targetSdkVersion 28
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        renderscriptSupportModeEnabled true
        multiDexEnabled true
    }

    buildTypes {
        release {
            // signingConfig signingConfigs.release
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            // resValue "string", "app_name", "$app_name_release"
        }

        debug {
            applicationIdSuffix ".debug"
            versionNameSuffix "-debug"
            buildConfigField "String", "TYPE", '"DEBUG"'
        }
    }
    flavorDimensions "mode", "key"

    productFlavors {
        lite {
            dimension "mode"
            applicationId "com.xxx.xxx"
            versionCode 23
            versionName "4.4.3"
            manifestPlaceholders = [app_name: "Pro-Inspector"]
        }

        pi {
            dimension "mode"
            applicationId "com.xxx.xxx"
            versionCode 53
            versionName "4.4.3"
            manifestPlaceholders = [app_name: "Pro-Inspector"]
        }

        local {
            dimension "key"
        }

        sandbox {
            dimension "key"
        }

        demo {
            dimension "key"
        }

        dev {
            dimension "key"
        }

        production {
            dimension "key"
        }

        live {
            dimension "key"
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    variantFilter { variant ->
        def modeName = variant.flavors*.name
        def keyName = variant.flavors*.name

        // To check for a certain build type, use variant.buildType.name == "<buildType>"
        // Gradle ignores any variants that satisfy the conditions below

        if (modeName.contains("lnt") && keyName.contains("demo")) {
            setIgnore(true)
        }
        if (modeName.contains("pi") && keyName.contains("dev")) {
            setIgnore(true)
        }
        if (modeName.contains("pi") && keyName.contains("production")) {
            setIgnore(true)
        }
        if (modeName.contains("lnt") && keyName.contains("live")) {
            setIgnore(true)
        }
    }
}

dependencies {
    implementation 'com.google.firebase:firebase-crashlytics:17.2.2'
    implementation 'com.google.firebase:firebase-analytics:18.0.0'
    implementation 'com.google.firebase:firebase-core:18.0.0'
    implementation 'com.google.firebase:firebase-messaging:21.0.0'
    implementation 'com.google.firebase:firebase-auth:20.0.0'
    implementation 'com.google.firebase:firebase-messaging-directboot:21.0.0'
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    // RETROFIT
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
    // GLIDE
    implementation 'com.github.bumptech.glide:glide:4.3.1'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.3.1'
    // VIEWMODEL
    implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
    implementation 'androidx.lifecycle:lifecycle-viewmodel:2.0.0'
    api 'com.theartofdev.edmodo:android-image-cropper:2.8.+'

    implementation 'org.greenrobot:eventbus:3.1.1'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'com.google.android.material:material:1.1.0-alpha02'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'com.android.volley:volley:1.1.0'
    implementation 'com.daasuu:EasingInterpolator:1.0.0'
    implementation 'com.google.android.gms:play-services-vision:20.1.2'
    implementation 'com.google.android.gms:play-services-location:17.1.0'
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
    implementation 'com.google.android.gms:play-services-identity:17.0.0'
    implementation 'com.google.android.gms:play-services-location:17.1.0'
    implementation 'com.google.android.gms:play-services-places:17.0.0'
    implementation 'org.adw.library:discrete-seekbar:1.0.1'
    implementation 'fr.avianey.com.viewpagerindicator:library:2.4.1@aar'
    implementation 'com.nineoldandroids:library:2.4.0'
    implementation 'androidx.multidex:multidex:2.0.1'
    androidTestImplementation 'androidx.multidex:multidex:2.0.1'
    androidTestImplementation 'androidx.multidex:multidex-instrumentation:2.0.0'
    implementation 'commons-io:commons-io:2.0.1'
    testImplementation 'junit:junit:4.12'
    implementation project(':pdfviewer')

    //retrofit dependencies
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
    implementation 'androidx.lifecycle:lifecycle-viewmodel:2.2.0'
 
}
apply plugin: 'com.google.gms.google-services'

有人遇到过这个问题吗?谁能帮我查看控制台中的崩溃

我也遇到了同样的问题,为了解决这个问题,我做了以下步骤。

  1. 添加新的 Crashlytics SDK 后。从 Firebase 控制台下载新的 Google-services.json 文件(您可以从 Firebase 控制台的项目设置中获取)

  2. 第一次强制崩溃。

     throw new RuntimeException("Test Crash");
    
  3. 运行 你的 app.It 会崩溃,因为我们是在上面添加的 运行 时间异常。

现在检查您的 Firebase 控制台。可以看到崩溃报告

参考HERE

就我而言,我犯了一个愚蠢的错误:

FirebaseCrashlytics.getInstance().setUserId(uid);

其中 uid 仍然为空。