无法通过DEBUG构建禁用带有Firebase的Fabric的Crashlytics [英] Fabric's Crashlytics with Firebase can't be disabled for DEBUG builds

查看:140
本文介绍了无法通过DEBUG构建禁用带有Firebase的Fabric的Crashlytics的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个通过Firebase利用Fabric的Crashlytics的应用程序. 以下是我的应用程序onCreate中执行的第一件事

I have an app that utilises Fabric's Crashlytics via Firebase. The following is the first thing executed in my Applications onCreate

CrashlyticsCore crashlyticsCore = new CrashlyticsCore.Builder()
    .disabled(BuildConfig.DEBUG)
    .build();
Fabric.with(this, new Crashlytics.Builder().core(crashlyticsCore).build());

尽管如此,崩溃是在DEBUG == true模式下提交的.

Nonetheless, the crashes are submitted in DEBUG == true mode.

我使用以下版本

在我的build.gradle中 classpath "io.fabric.tools:gradle:1.25.1"

in my build.gradle classpath "io.fabric.tools:gradle:1.25.1"

在我的app/build.gradle中 implementation "com.crashlytics.sdk.android:crashlytics:2.9.1"

in my app/build.gradle implementation "com.crashlytics.sdk.android:crashlytics:2.9.1"

不幸的是,崩溃仍然得到报告.有什么想法,我在做什么错了?

Unfortunately the crashes still get reported. Any ideas, what I am doing wrong?

推荐答案

Firebase Crashlytics文档解释说,一旦在应用会话中启用了报告功能,便无法将其禁用.

The Firebase Crashlytics documentation explains that once reporting is enabled in an app session, it cannot be disabled.

默认情况下,名为 CrashlyticsInitProvider ContentProvider中启用了Crashlytics报告,该报告在创建Application实例之前执行. CrashlyticsInitProvider 启用或禁用基于元数据值firebase_crashlytics_collection_enabled的报告,该值默认为true.

By default, Crashlytics reporting is enabled in a ContentProvider named CrashlyticsInitProvider that executes before your Application instance is created. CrashlyticsInitProvider enables or disables reporting based on the meta-data value firebase_crashlytics_collection_enabled, which by default is true.

如果要禁用报告功能,则必须提供清单元数据并将其设置为false,这一点至关重要:

If you want reporting disabled, it's critical that the manifest meta-data be present and set to false:

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

在应用初始化期间查看消息中的logcat:

Look in the logcat during app initialization for the message:

CrashlyticsInitProvider: CrashlyticsInitProvider initialization successful

如果显示该消息,则firebase_crashlytics_collection_enabled为true.如果消息不存在,则说明您已经成功设置了元数据以禁用崩溃报告.

If the message is present, firebase_crashlytics_collection_enabled is true. If the message is not present, you have successfully set the meta-data to disable crash reporting.

如果元数据丢失或设置为true,则无法使用对Fabric.with(...)的调用来禁用代码中的报告.

If the meta-data is missing or set to true, you cannot disable reporting in your code using a call to Fabric.with(...).

在对另一个答案的评论中,您表示您尝试使用元数据禁用报告,但未成功.检查拼写错误,并确保将声明正确放置在<application>元素中.在我的测试中,我能够使用元数据禁用报告,然后在运行时启用.

In a comment to another answer, you indicate that you tried disabling reporting using the meta-data and were not successful. Check for a typo and ensure the declaration is correctly placed in the <application> element. In my tests, I am able to disabling reporting using the meta-data and then enable at run time.

这篇关于无法通过DEBUG构建禁用带有Firebase的Fabric的Crashlytics的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆