Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
618 views
in Technique[技术] by (71.8m points)

android - How to disable 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());

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.

Any ideas?

On a side note, I really hope Fabric is going to update and improve their docs soon.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

on my app we do it the old fashioned way:

if (!IS_DEBUG) {
   Fabric.with(this, new Crashlytics());
}

works fine.

Of course you can initialise with whichever custom parameters you need.

edit:

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;

edit:

I would advise against using BuildConfig.DEBUG, see this article: http://www.digipom.com/be-careful-with-buildconfig-debug/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...