- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
Error Tracking processes errors collected from the Android SDK.
Enable Android Crash Reporting and Error Tracking to get comprehensive crash reports and error trends. With this feature, you can access:
Your crash reports appear in Error Tracking.
If you have not set up the Android SDK yet, follow the in-app setup instructions or see the Android setup documentation.
env
and variant
when initializing the SDK.For any given error, you can access the file path, line number, and a code snippet for each frame of the related stack trace.
Your Android application may be running native code (C/C++) for performance or code reusability reasons. In order to enable NDK crash reporting, use the Datadog NDK plugin.
Add the Gradle dependency by declaring the library as a dependency in your build.gradle
file:
dependencies {
implementation "com.datadoghq:dd-sdk-android-ndk:x.x.x"
//(...)
}
Enable NDK crash collection after initializing the SDK.
NdkCrashReports.enable()
An “Application Not Responding” (ANR) is an Android-specific type of error that gets triggered when the application is unresponsive for too long.
ANRs are only reported through the SDK (not through Logs).
Fatal ANRs result in crashes. The application reports them when it’s unresponsive, leading to the Android OS displaying a popup dialog to the user, who chooses to force quit the app through the popup.
Non-fatal ANRs may or may not have led to the application being terminated (crashing).
For any Android version, you can override the default setting for reporting non-fatal ANRs by setting trackNonFatalAnrs
to true
or false
when initializing the SDK.
Mapping files are used to deobfuscate stack traces, which helps in debugging errors. Using a unique build ID that gets generated, Datadog automatically matches the correct stack traces with the corresponding mapping files. This ensures that regardless of when the mapping file was uploaded (either during pre-production or production builds), the correct information is available for efficient QA processes when reviewing crashes and errors reported in Datadog.
Depending on the Android Gradle plugin version, the matching of stack traces and mapping files relies on different fields:
build_id
fieldservice
, version
, and variant
fieldsNote: Re-uploading a source map does not override the existing one if the version has not changed.
Add the Android Gradle Plugin to your Gradle project using the following code snippet.
// In your app's build.gradle script
plugins {
id("com.datadoghq.dd-sdk-android-gradle-plugin") version "x.y.z"
}
Create a dedicated Datadog API key and export it as an environment variable named DD_API_KEY
or DATADOG_API_KEY
. Alternatively, pass it as a task property, or if you have datadog-ci.json
file in the root of your project, it can be taken from an apiKey
property there.
Optionally, configure the plugin to upload files to the EU region by configuring the plugin in your build.gradle
script:
datadog {
site = "EU1"
}
Run the upload task after your obfuscated APK builds:
./gradlew uploadMappingRelease
If running native code, run the NDK symbol upload task:
./gradlew uploadNdkSymbolFilesRelease
Note: If your project uses additional flavors, the plugin provides an upload task for each variant with obfuscation enabled. In this case, initialize the Android SDK with a proper variant name (the necessary API is available in versions 1.8.0
and later).
Add the Android Gradle Plugin to your Gradle project using the following code snippet.
// In your app's build.gradle script
plugins {
id("com.datadoghq.dd-sdk-android-gradle-plugin") version "x.y.z"
}
Create a dedicated Datadog API key and export it as an environment variable named DD_API_KEY
or DATADOG_API_KEY
. Alternatively, pass it as a task property, or if you have datadog-ci.json
file in the root of your project, it can be taken from an apiKey
property there.
Configure the plugin to use the EU region by adding the following snippet in your app’s build.gradle
script file:
datadog {
site = "EU1"
}
Run the upload task after your obfuscated APK builds:
./gradlew uploadMappingRelease
If running native code, run the NDK symbol upload task:
./gradlew uploadNdkSymbolFilesRelease
Note: If your project uses additional flavors, the plugin provides an upload task for each variant with obfuscation enabled. In this case, initialize the Android SDK with a proper variant name (the necessary API is available in versions 1.8.0
and later).
There are several plugin properties that can be configured through the plugin extension. In case you are using multiple variants, you can set a property value for a specific flavor in the variant.
For example, for a fooBarRelease
variant, you can use the following configuration:
datadog {
foo {
versionName = "foo"
}
bar {
versionName = "bar"
}
fooBar {
versionName = "fooBar"
}
}
The task configuration for this variant is merged from all three flavor configurations provided in the following order:
bar
foo
fooBar
This resolves the final value for the versionName
property as fooBar
.
Property name | Description |
---|---|
versionName | The version name of the application (by default, the version declared in the android block of your build.gradle script). |
serviceName | The service name of the application (by default, the package name of your application as declared in the android block of your build.gradle script). |
site | The Datadog site to upload your data to (US1, US3, US5, EU1, US1_FED, or AP1). |
remoteRepositoryUrl | The URL of the remote repository where the source code was deployed. If this is not provided, this value is resolved from your Git configuration during the task execution time. |
checkProjectDependencies | This property controls if the plugin should check if the Datadog Android SDK is included in the dependencies. If not, “none” is ignored, “warn” logs a warning, and “fail” fails the build with an error (default). |
By default, the upload mapping task is independent from other tasks in the build graph. Run the task manually when you need to upload mapping.
If you want to run this task in a CI/CD pipeline, and the task is required as part of the build graph, you can set the upload task to run after the mapping file is generated.
For example:
tasks["minify${variant}WithR8"].finalizedBy { tasks["uploadMapping${variant}"] }
Mapping files are limited to 500 MB. If your project has a mapping file larger than this, use one of the following options to reduce the file size:
Mapping files are limited to 50 MB. If your project has a mapping file larger than this, use one of the following options to reduce the file size:
mappingFileTrimIndents
option to true
. This reduces your file size by 5%, on average.mappingFilePackagesAliases
: This replaces package names with shorter aliases. Note: Datadog’s stacktrace uses the same alias instead of the original package name, so it’s better to use this option for third party dependencies.datadog {
mappingFileTrimIndents = true
mappingFilePackageAliases = mapOf(
"kotlinx.coroutines" to "kx.cor",
"com.google.android.material" to "material",
"com.google.gson" to "gson",
"com.squareup.picasso" to "picasso"
)
}
When looking at RUM Crash Reporting behaviors for Android, consider the following:
onCreate
method.onResume
state), or after the app is sent to the background by the end-user navigating away from it, the crash is muted and isn’t reported for collection. To mitigate this, use the trackBackgroundEvents()
method in your RumConfiguration
builder.To verify your Android Crash Reporting and Error Tracking configuration, you need to trigger a crash in your application and confirm that the error appears in Datadog.
To test your implementation:
Run your application on an Android emulator or a real device.
Execute some code containing an error or crash. For example:
fun onEvent() {
throw RuntimeException("Crash the app")
}
After the crash happens, restart your application and wait for the Android SDK to upload the crash report in Error Tracking.