Crash and ANR
Connecting dependencies to your project
In your <project>/<app-module>/build.gradle
.
dependencies {
implementation "ru.ok.tracer:tracer-crash-report:0.2.7"
}
Also, Tracer supports gathering and analysis of native crashes. If you want to gather crashes that occurred on the native code, connect the relevant dependency (see below).
dependencies {
implementation "ru.ok.tracer:tracer-crash-report-native:0.2.7"
}
Currently, this feature is under active development. Crash logs gathering functions, however, native crashes are displayed without stack trace and other details. Now you can gather and count them while displaying and categorization are being tweaked.
For a detailed description of the dependencies see “Quickstart”.
CrashReportConfiguration
and CrashFreeConfiguration
description
In your Application.kt
.
class MyApplication : Application(), HasTracerConfiguration {
override val tracerConfiguration: List<TracerConfiguration>
get() = listOf(
CrashReportConfiguration.build {
// your options
},
CrashFreeConfiguration.build {
// your options
},
)
}
Below are the CrashReportConfiguration.Builder
options:
setEnabled
— enables/disables crash reporting. By default: enabled.setSendAnr
— disables ANR sending. By default: enabled.setNativeEnabled
— enables/disables native crash reporting. The default value depends on whether thetracer-crash-report-native
dependency is connected. If the dependency is connected, then, reporting is by default enabled. If not, disabled. ⚠ You cannot enable native crash reporting without connecting the relevant dependency but you can disable reporting if the dependency is connected.
Below are the CrashReportConfiguration.Builder
options that are deprecated or dangerous.
setHost
— deprecated and will be removed in version 0.3.x. If you really need to change the host, useCoreTracerConfiguration.setHost
;setSendLogs
— deprecated and does nothing, will be removed in version 0.3.x;setCountCrashFreeUsers
— deprecated and does nothing, will be removed in version 0.3.x; useCrashFreeConfiguration.Builder.setEnabled
instead;setSendThreadsDump
,setSendAsap
,setMaxNonFatalExceptions
— deprecated and do nothing, will be deleted in version 0.3.x.
Below are the CrashFreeConfiguration.Builder
options.
setEnabled
— enables/disablescrash free users
count. By default: disabled!
Below are the CrashFreeConfiguration.Builder
options that are deprecated or dangerous.
setExperimentalMaxSessionsToUpload
— how many sessions to gather before sending a batch. By default: 10. For testing purposes only!setExperimentalMaxSessionTimeSpanToUpload
— for how long to gather sessions before sending a batch. By default: 4 hours (in milliseconds). For testing purposes only!setExperimentalUploadSessionsFromYesterday
— send a batch if yesterday's (or earlier) sessions are detected. By default: enabled.
TracerCrashReport
description
To send non-fatals
the TracerCrashReport.report(throwable)
method is used.
// Log a non-fatal error.
TracerCrashReport.report(NonFatalException("I'll be ok soon"))
Crashes are grouped by common parts of a stack trace. By default, non-fatals
, however, tweak this grouping approach.
You can gather all non-fatals
in one group regardless of a stack trace using the report
method with the issueKey
parameter.
// Log a non-fatal error with the ISSUE-001 key
TracerCrashReport.report(NonFatalException("What a terrible failure"), issueKey = "ISSUE-001")
Currently, Tracer has a limit of 1 million events a day. That is why the excessive use of this method is not recommended.
You can also add additional info to an event.