问题描述
我有一个通过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.gradleclasspath "io.fabric.tools:gradle:1.25.1"
在我的app/build.gradle中implementation "com.crashlytics.sdk.android:crashlytics:2.9.1"
in my app/build.gradleimplementation "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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!