问题描述
相对而言,直接禁用Crashlytics错误报告..我也想禁用Answers进行调试.但是,
Disabling Crashlytics error reporting is relatively straight forward.. I'd also like to disable Answers for debug builds. However,
new Crashlytics.Builder().answers(null);
无效,因为答案显然不能为空并且
doesn't work since apparently answers can't be null and
new Crashlytics.Builder().answers(new CustomAnswers());
CustomAnswers是我的课程,扩展了Answers在调用Answers.getInstance()
时获得了NPE.但是,与简单地调用某些enable()方法相比,这种方法开始时比较麻烦.
with CustomAnswers being my class extending Answers gets me a NPE when calling Answers.getInstance()
. But that approach is cumbersome to begin with compared to simply calling some enable() method.
有什么想法吗?
另一方面,我真的希望Fabric能够尽快更新和改进他们的文档.
On a side note, I really hope Fabric is going to update and improve their docs soon.
推荐答案
在我的应用中,我们以老式的方式进行操作:
on my app we do it the old fashioned way:
if (!IS_DEBUG) {
Fabric.with(this, new Crashlytics());
}
工作正常.
当然,您可以使用所需的任何自定义参数进行初始化.
Of course you can initialise with whichever custom parameters you need.
获取调试布尔值只是使用gradle对您有利:
to get the debug boolean is just a matter of using gradle to your favour:
src/
main/ // your app code
debug/
AppSettings.Java:
public static final boolean IS_DEBUG = true;
release/
AppSettings.Java:
public static final boolean IS_DEBUG = false;
我建议不要使用BuildConfig.DEBUG,请参阅本文: http://www.digipom.com/be-careful-with-buildconfig-debug/
I would advise against using BuildConfig.DEBUG, see this article: http://www.digipom.com/be-careful-with-buildconfig-debug/
这篇关于如何禁用Crashlytics答案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!