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:

Note:

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.

Note:

This feature is not available in the us2 region at this time.

Note:

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.

  1. 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:

    • Install the splunk-rum CLI.

  2. Build your application.

  3. Upload your application's mapping file and specify its applicationID and versionCode 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 the SPLUNK_REALM and SPLUNK_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 packaged AndroidManifest.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 the SPLUNK_REALM and SPLUNK_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]
  4. (Optional) Verify that your upload succeeded:
    splunk-rum android list --app-id=applicationID

Use splunk-rum for pre-production builds

  1. 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:

    • Install the splunk-rum CLI.

  2. Since pre-production builds don't update the versionCode property for each build, add a unique identifier named splunk.build_id as metadata to the AndroidManifest.xml file in your source directory before building the application binary:

    1. Add this snippet to the <application> block of the AndroidManifest.xml file in your source directory:

      <meta-data
      android:name="splunk.build_id"
      android:value="${splunkBuildId}" />
    2. 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 }
          }
      }
      
  3. Build your application.

  4. Upload your application's mapping file and specify its applicationID, versionCode, and splunk.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 added splunk.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 packaged AndroidManifest.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]
  5. (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 --path path --app-id value --version-code int [optional-parameters]

Upload the mapping file mapping.txt with the application ID and version code that you specify.

Parameters:

  • --path path Required. Path to the mapping.txt file.

  • --app-id applicationID Required. The applicationId property in your application's build.gradle file.

  • --version-code int Required. The versionCode property of your application.

  • --splunk-build-id value Optional. Splunk build ID for the upload.

  • --realm value Optional. Realm for your organization. For example, us0. You can omit this parameter and set the environment variable SPLUNK_REALM instead.

  • --token your-splunk-org-access-token Optional. API access token. You can omit this parameter and set the environment variable SPLUNK_ACCESS_TOKEN instead.

  • --dry-run=[true|false] Perform a trial run with no changes made. Default: false.

  • --debug Enable debug logs.

  • -h, --help Display help for this command.

upload-with-manifest --manifest path --path path [optional-parameters]

Upload the Android mapping.txt file with required metadata extracted from the AndroidManifest.xml file.

Parameters:

  • --manifest path Required. Path to the merged or the packaged AndroidManifest.xml file that is generated when the application is built.

  • --path path Required. Path to the mapping.txt file.

  • --realm value Optional. Realm for your organization. For example, us0. You can omit this parameter and set the environment variable SPLUNK_REALM instead.

  • --token your-splunk-org-access-token Optional. API access token. You can omit this parameter and set the environment variable SPLUNK_ACCESS_TOKEN instead.

  • --dry-run=[true|false] Preview the file that will be uploaded and the parameters that will be extracted from AndroidManifest.xml.

  • --debug Enable debug logs.

  • -h, --help Display help for command.

list --app-id value [optional-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:

  • --app-id applicationID Required. The applicationId property in your app's build.gradle file.

  • --realm value Optional. Realm for your organization. For example, us0. You can omit this parameter and set the environment variable SPLUNK_REALM instead.

  • --token your-splunk-org-access-token Optional. API access token. You can omit this parameter and set the environment variable SPLUNK_ACCESS_TOKEN instead.

  • --dry-run=[true|false] Perform a trial run with no changes made. Default: false.

  • --debug Enable debug logs.

  • -h, --help Display help for this subcommand.

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 or build.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 or build.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
  1. Add the plugin to your application-level build.gradle or build.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'
    }
  2. Configure the extension block in your application-level build.gradle or build.gradle.kts:

    splunkRum {
        enabled = true
        realm = "your-realm" 
        apiAccessToken = "your-access-token-here"
        failBuildOnUploadFailure = false
    }
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 to false, 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 the splunk.accessToken project property or the SPLUNK_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 the splunk.realm project property or SPLUNK_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 to true, 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 the splunk-rum CLI.