Add a mapping file
Your uploaded mapping file enables Splunk RUM to convert stack traces back into a human-readable form.
When you set the minifyEnabled
property to true in your Android application source code, your build process minifies, optimizes, and obfuscates the code and generates a single mapping file, mapping.txt
. This mapping file contains the information Splunk RUM needs to convert stack traces containing obfuscated classes and filenames back into a human readable form. This conversion is called deobfuscation in Android.
In order to associate a specific mapping file with a specific application build, Splunk RUM compares the applicationId
and versionCode
properties of the application to the parameters that you specify for the mapping file upload. You can can specify these parameters and upload the mapping file to Splunk RUM by any of these methods:
Follow the steps on this page to upload your mapping files to Splunk RUM before you distribute corresponding binaries. To ensure that the mapping files you upload to Splunk RUM match the binaries you deploy to production, the best practice is to integrate these steps into your CI pipeline so that whenever you rebuild your Android application, you automatically upload its mapping file. Alternatively, you can upload source maps on demand.
This feature is not available in the us2
region at this time.
Splunk RUM stores your mapping files permanently. You cannot delete them from Splunk RUM at this time.
Use splunk-rum for production builds
Follow these steps to specify the --app-id
and --version-code
parameters on the splunk-rum android upload
command or include your application's merged or packaged manifest (AndroidManifest.xml
), which includes these properties by default, in the splunk-rum android upload-with-manifest
command.
Confirm that your setup meets these prerequisites:
To support de-obfuscation of your application's stack traces, ensure that your proguard-rule.pro has the following two lines enabled:
-keepattributes LineNumberTable,SourceFile -renamesourcefileattribute SourceFile
Upgrade your Splunk RUM Android agent:
- splunk-otel-android: v2.0.0
Build your application.
Upload your application's mapping file and specify its
applicationID
andversionCode
properties.You can do this in either of these ways:
Run the
upload
command with the--app-id
and--version-code
parameters:splunk-rum android upload \ --app-id=applicationID --version-code=versionCode \ --path=path-to-mapping-file \ [optional-parameters]
Note: If you didn't set theSPLUNK_REALM
andSPLUNK_ACCESS_TOKEN
environment variables, you must also add the--realm value
and--token your-splunk-org-access-token
parameters to this command.Run the
upload-with-manifest
command with the path to the application's merged or packagedAndroidManifest.xml
file, along with path to the mapping file. Be sure to include the correct manifest, which is the one that's created when your application is built, and is located in the build output directory:Note: If you didn't set theSPLUNK_REALM
andSPLUNK_ACCESS_TOKEN
environment variables, you must also add the--realm value
and--token your-splunk-org-access-token
parameters to this command.splunk-rum android upload-with-manifest \ --manifest path-to-merged-manifest \ --path path-to-mapping-file \ [optional-parameters]
- (Optional) Verify that your upload succeeded:
splunk-rum android list --app-id=applicationID
Use splunk-rum for pre-production builds
Confirm that your setup meets these prerequisites:
To support de-obfuscation of your application's stack traces, ensure that your proguard-rule.pro has the following two lines enabled:
-keepattributes LineNumberTable,SourceFile -renamesourcefileattribute SourceFile
Upgrade your Splunk RUM Android agent:
- splunk-otel-android: v2.0.0
Since pre-production builds don't update the
versionCode
property for each build, add a unique identifier namedsplunk.build_id
as metadata to theAndroidManifest.xml
file in your source directory before building the application binary:Add this snippet to the
<application>
block of theAndroidManifest.xml
file in your source directory:<meta-data android:name="splunk.build_id" android:value="${splunkBuildId}" />
Add the following code to the
android {}
block of the Gradle build script of your application. This code generates a new UUID for every application variant and adds it to the merged manifest file after the variant is assembled, where the Splunk RUM agent will retrieve it:- Kotlin
If you use Kotlin add this to
build.gradle.kts
:applicationVariants.configureEach { val uniqueBuildId = UUID.randomUUID().toString() this.mergedFlavor.manifestPlaceholders["splunkBuildId"] = uniqueBuildId logger.lifecycle("Splunk: Variant $name assigned build ID: $uniqueBuildId") val capitalizedVariantName = name.replaceFirstChar { it.uppercase() } tasks.named("process${capitalizedVariantName}Manifest").configure { outputs.upToDateWhen { false } } }
- Groovy
If you use Groovy add this to
build.gradle
:applicationVariants.configureEach { variant -> def uniqueBuildId = UUID.randomUUID().toString() variant.mergedFlavor.manifestPlaceholders.put("splunkBuildId", uniqueBuildId) project.logger.lifecycle("Splunk: Variant ${variant.name} assigned build ID: ${uniqueBuildId}") def capitalizedVariantName = variant.name.capitalize() tasks.named("process${capitalizedVariantName}Manifest").configure { outputs.upToDateWhen { false } } }
Build your application.
Upload your application's mapping file and specify its
applicationID
,versionCode
, andsplunk.build_id
properties. You can do this in either of these ways:Run the upload command with the
--app-id
,--version-code
, and--splunk-build-id
parameters. This option only works if you addedsplunk.build_id
to your Gradle build script (in step 1). Get the build ID from the Gradle build output or from the merged manifest:splunk-rum android upload \ --app-id=applicationID --version-code=versionCode \ --splunk-build-id value \ --path=path-to-mapping-file \ [optional-parameters]
Run the
upload-with-manifest
command with the path to the application's merged or packagedAndroidManifest.xml
file, along with path to the mapping file. Be sure to include the correct manifest, which is the one that's created when your application is built, and is located in the build output directory:splunk-rum android upload-with-manifest \ --manifest path-to-merged-manifest \ --path path-to-mappping-file \ [optional-parameters]
- (Optional) Verify that your upload succeeded:
splunk-rum android list --app-id=applicationID
splunk-rum syntax
splunk-rum android [command] [parameters]
splunk-rum command descriptions
Command | Description |
---|---|
| Upload the mapping file Parameters:
|
| Upload the Android Parameters:
|
| List the 100 most recently uploaded mapping files for the given application ID, sorted in reverse chronological order based on the upload timestamp. Parameters:
|
Use the Splunk RUM Gradle plugin
If you obfuscated your production build, you can automatically upload mapping files and inject build correlation IDs using the Splunk RUM Gradle plugin:
Add the plugin to your application-level
build.gradle
orbuild.gradle.kts
:- Kotlin DSL
plugins { id("com.splunk.rum-mapping-file-plugin") version "2.0.0" }
- Groovy
plugins { id 'com.splunk.rum-mapping-file-plugin' version '2.0.0' }
Configure the extension block in your application-level
build.gradle
orbuild.gradle.kts
:splunkRum { enabled = true realm = "your-realm" apiAccessToken = "your-api-access-token-here" failBuildOnUploadFailure = false }
Build your application. The plugin automatically:
Generates a unique build ID for each variant with minification enabled.
Injects the build ID into your app's manifest for runtime correlation by the agent.
Uploads the mapping file after a successful build.
About the Splunk RUM Gradle plugin
The Splunk RUM Gradle plugin automates the upload of ProGuard and R8 mapping files and the injection of build IDs for Android applications. This enables accurate crash symbolication in Splunk Observability Cloud by correlating obfuscated stacktraces with the correct mapping files.
When you build obfuscated Android applications (with minification enabled), the plugin automatically:
Generates unique build IDs for each variant to correlate stacktraces with their respective mapping files.
Injects build IDs into your app's
AndroidManifest.xml
for runtime access by the Splunk RUM agent.Uploads mapping files to Splunk Observability Cloud after successful builds.
- Prerequisites
Android Gradle Plugin 7.0 or higher
Splunk RUM Android agent integrated in your application
Valid Splunk Observability Cloud API access token and realm
- Installation
- Add the plugin to your application-level
build.gradle
orbuild.gradle.kts
:- Kotlin DSL
plugins { id("com.splunk.rum-mapping-file-plugin") version "2.0.0" }
- Groovy
plugins { id 'com.splunk.rum-mapping-file-plugin' version '2.0.0' }
Configure the extension block in your application-level
build.gradle
orbuild.gradle.kts
:splunkRum { enabled = true realm = "your-realm" apiAccessToken = "your-access-token-here" failBuildOnUploadFailure = false }
- Add the plugin to your application-level
- Configuration options
enabled
: Enable or disable the mapping file plugin functionality. When enabled, it generates unique build IDs for each variant, injects the build ID into the intermediateAndroidManifest.xml
files of your application, and uploads the mapping file. Default:true
failBuildOnUploadFailure
: Whether to fail the build if mapping file cannot be found, or the mapping file upload fails. If set tofalse
, upload failures are logged but don't stop the build. Default:false
.apiAccessToken
: Access token for Splunk API authentication. If not set, the plugin attempts to use thesplunk.accessToken
project property or theSPLUNK_ACCESS_TOKEN
environment variable, both of which are alternative ways of setting this field.realm
: Splunk realm for API endpoint. If not set, the plugin attempts to use thesplunk.realm
project property orSPLUNK_REALM
environment variable, both of which are alternative ways of setting this field.
- Usage
- Once configured, the plugin works automatically. When enabled, it only processes build variants with minification enabled. Variants without minification are automatically skipped.
- Troubleshooting upload failures
- By default, mapping file upload failures don't break your build, but this can be configured with the
failBuildOnUploadFailure
option. If you set this option totrue
, failure to locate the mapping file also results in a build failure. If you configure the mapping file to be generated in a custom location, the plugin will not be able to automatically locate it. In that case, disable the plugin and upload the mapping file using the Splunk Observability Cloud UI or thesplunk-rum
CLI.