android - 如何启用 Firebase 崩溃报告 - Android

标签 android firebase firebase-crash-reporting

我按照文档中的所有步骤在我的 Android 应用程序中使用 Firebase 崩溃报告(我使用 Android Studio 并且一切都是最新的)。

我用他们自己的代码抛出一个异常,看看是否有效:

try {
    throw new NullPointerException();
} catch (NullPointerException ex) {
    FirebaseCrash.logcat(Log.ERROR, TAG, "NPE caught");
    FirebaseCrash.report(ex);
}

控制台给了我这个日志:

E/MainActivity: NPE caught

V/FirebaseCrash: Firebase Crash Reporting is disabled.

这是一个build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'

        // Firebase - Google Services 3.0.0
        classpath 'com.google.gms:google-services:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

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

这是另一个build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 'android-N'
    buildToolsVersion '24.0.0-rc2'

    defaultConfig {
        applicationId "com.app.test"
        minSdkVersion 19
        targetSdkVersion 'N'
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            useProguard true
        }
    }
}

dependencies {
    compile 'com.android.support:support-v4:24.0.0-alpha1'
    compile 'com.android.support:appcompat-v7:24.0.0-alpha1'
    compile 'com.android.support:design:24.0.0-alpha1'
    compile 'com.google.firebase:firebase-core:9.0.0'
    compile 'com.google.firebase:firebase-analytics:9.0.0'
    compile 'com.google.firebase:firebase-crash:9.0.0'
    compile 'com.google.firebase:firebase-messaging:9.0.0'
    compile 'com.google.firebase:firebase-config:9.0.0'
    compile 'com.google.firebase:firebase-invites:9.0.0'
    compile 'com.google.android.gms:play-services-appindexing:9.0.0'
}

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

我还用:

mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
FirebaseMessaging.getInstance().subscribeToTopic("news");
Log.d(TAG, "Subscribed to news topic");

我添加了我需要的所有依赖项,但我正在一个一个地添加并一个一个地测试,并且通知有效,分析:不知道,更新大约需要 24 小时,所以在它完成之前,我不知道有没有用...

那么,问题是我该如何启用它?

注意:我添加了所有依赖项,包括崩溃核心,还有插件类路径

先谢谢你。

最佳答案

请注意以下事项:

  • 添加 SDK 后,您可以尝试使用:

    FirebaseCrash.report(new Exception("My first Android non-fatal error"));

  • 错误最多需要 20 分钟才会显示在崩溃报告控制台中。回来查看您的报告。

  • (这可能看起来很明显,但)确保您拥有:INTERNET 和 ACCESS_NETWORK_STATE 权限。

关于android - 如何启用 Firebase 崩溃报告 - Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37393218/

相关文章:

android - 获取使用 Android 默认相机拍摄的照片的设备方向

android - FCM 通知 click_action 应该重定向到打开浏览器

java - Firebase 身份验证 : getCurrentUser from different Activities?

android - 如何防止android应用程序崩溃

Android AVD 没有显示任何内容。屏幕中间只有 "ANDROID"

android - 无法在 oreo -telephony manager 中结束通话

android - Activity 不是从状态栏通知开始的

Java Spring - 从异步回调返回?

ios - Firebase 崩溃报告多个问题

ios - iOS 上的 assertUnfrozen