如何启用Firebase崩溃报告 - Android [英] How to enable Firebase Crash Reporting - Android
问题描述
我遵循文档中的所有步骤,在我的Android应用中使用Firebase崩溃报告(我使用的是Android Studio,并且所有内容都是最新的)。
我使用他们自己的代码来抛出一个异常,看看它是否工作:
$ p $ {
throw new NullPointerException() ;
catch(NullPointerException ex){
FirebaseCrash.logcat(Log.ERROR,TAG,NPE caught);
FirebaseCrash.report(ex);
$ p 然后控制台给我这个日志:
E / MainActivity:NPE已被捕获
V / FirebaseCrash:Firebase崩溃报告已停用。 b $ b
以下是一个build.gradle
//顶级构建文件,您可以在其中添加对所有子项目/模块通用的配置选项。
uildscript {
repositories {
jcenter()
}
依赖关系{
classpath'com.android.tools.build:gradle: 2.1.0'
// Firebase - Google服务3.0.0
classpath'com.google.gms:google-services:3.0.0'
/ /注意:不要把你的应用程序依赖关系放在这里;它们属于单个模块build.gradle文件中的
//
}
}
allprojects {
repositories {
jcenter()
任务清理(类型:删除){
删除rootProject.buildDir
}
以下是其他build.gradle
apply plugin :'com.android.application'
android {
compileSdkVersion'android-N'
buildToolsVersion '24 .0.0-rc2'
defaultConfig {
applicationIdcom.app.test
minSdkVersion 19
targetSdkVersion'N'
versionCode 1
versionName1.0
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
useProguard true
}
}
}
依赖关系{
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'
编译'com.google.firebase:firebase-core:9.0.0'
编译'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'
我也使用:
$ p $ mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
FirebaseMessaging.getInstance()。subscribeToTopic(news);
Log.d(标签,订阅新闻主题);
我添加了所有需要的依赖关系,但是我逐个添加并测试一个一个和通知的作品,分析:不知道,大约需要24小时更新,所以直到它,我不知道是否正在工作...
所以,我怎么才能启用它?
注意:我已经添加了所有依赖关系,包括崩溃和核心,还有插件和类路径
先进的谢谢。
请注意以下几点:$ b
$ b
-
在添加SDK之后,您可以尝试使用:
FirebaseCrash.report新的异常(我的第一个Android非致命错误));
-
错误需要长达20分钟崩溃报告控制台。看看你的报告。
c $ c>权限。
I followed all the steps on the docs to use Firebase Crash Reporting in my Android app (I use Android Studio and everything is up-to-date).
I used their own code to throw an exception to see if it works:
try {
throw new NullPointerException();
} catch (NullPointerException ex) {
FirebaseCrash.logcat(Log.ERROR, TAG, "NPE caught");
FirebaseCrash.report(ex);
}
And the console gives me this log:
E/MainActivity: NPE caught
V/FirebaseCrash: Firebase Crash Reporting is disabled.
Here is one 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
}
Here is the other 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'
I also use:
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
FirebaseMessaging.getInstance().subscribeToTopic("news");
Log.d(TAG, "Subscribed to news topic");
I added all dependencies that I'll need, but I'm adding one by one and testing one by one, and Notifications works, Analytics: no idea, it takes about 24 hours to update, so until it does, I don't know if is working...
So, the thing is how can I enable it?
NOTE: I have all of the dependencies added including the crash and core ones, also the plugin and the classpath
Thank you in advanced.
Please note the following:
After adding the SDK you can try using:
FirebaseCrash.report(new Exception("My first Android non-fatal error"));
Errors take up to 20 minutes to show up in the Crash Reporting console. Check back to see your report there.
(It may seem obvious but) make sure you have:
INTERNET and ACCESS_NETWORK_STATE
permission.
这篇关于如何启用Firebase崩溃报告 - Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!