I have successfully implemented Firebase Crash Reporting, but I need to disable the service when the app is running undo the \'debug\' Build Variant, in order to avoid non-r
First initialize variables in the gradle file and check whether it is in debug or in release mode. The best way to submit the crash report is within the Application class.
Build.gradle
buildTypes {
release {
buildConfigField "Boolean", "REPORT_CRASH", '"true"'
debuggable false
}
debug {
buildConfigField "Boolean", "REPORT_CRASH", '"false"'
debuggable true
}
}
Now first check the mode and submit the crash report if crashed .
Application.java
/** Report FirebaseCrash Exception if application crashed*/
Thread.setDefaultUncaughtExceptionHandler (new Thread.UncaughtExceptionHandler()
{
@Override
public void uncaughtException (Thread thread, Throwable e)
{
/** Check whether it is development or release mode*/
if(BuildConfig.REPORT_CRASH)
{
FirebaseCrash.report( e);
}
}
});