Android Error Tracking

Android Error Tracking

Overview

Error Tracking processes errors collected from the Android SDK. To quickly get started with error tracking download the latest version of dd-sdk-android.

If your mobile Android source code is obfuscated, upload your Proguard/R8 mapping file to Datadog so that your different stack traces can be deobfuscated. For a given error, you can get access to the file path, the line number, as well as a code snippet for each frame of the related stack trace.

Upload your mapping file

  1. Add the Gradle Plugin to your Gradle project, using the following snippet.
// In your project's build.gradle script
buildscript {
    dependencies {
        classpath("com.datadoghq:dd-sdk-android-gradle-plugin:x.x.x")
    }
}

// In your app's build.gradle script
plugins {
    id("dd-sdk-android-gradle-plugin")
}
  1. Create a new and dedicated Datadog API key and export it as an environment variable named DD_API_KEY.
  2. (Optional) Configure the plugin to upload files to the EU region by exporting two additonal environment variables: export DATADOG_SITE="datadoghq.eu" and export DATADOG_API_HOST="api.datadoghq.eu".
  3. Run the upload task after your obfuscated APK has been built:
./gradlew uploadMappingRelease

Note: If your project uses additional flavors, the plugin will provide an upload task for each variant with obfuscation enabled.

  1. Add the Gradle Plugin to your Gradle project, using the following snippet.
// In your project's build.gradle script
buildscript {
    dependencies {
        classpath("com.datadoghq:dd-sdk-android-gradle-plugin:x.x.x")
    }
}

// In your app's build.gradle script
plugins {
    id("dd-sdk-android-gradle-plugin")
}
  1. Create a new and dedicated Datadog API key and export it as an environment variable named DD_API_KEY.
  2. Configure the plugin to use the EU region by adding the following snippet in your app’s build.gradle script file:
datadog {
    site = "EU"
}
  1. Run the upload task after your obfuscated APK has been built:
./gradlew uploadMappingRelease

Note: If your project uses additional flavors, the plugin will provide an upload task for each variant with obfuscation enabled.

Troubleshoot errors

An obfuscated stack trace is not helpful as you don’t have access to the class name, file path and the line number. It’s hard to know where something is happening in your code base. In addition, the code snippet is still minified (one long line of transformed code) which makes the troubleshooting process even harder. See below an example of an minified stack trace:

image_obfuscated

On the contrary, a deobfuscated stack trace gives you all the context you need for troubleshooting:

image_deobfuscated

Further Reading