# Upload ProGuard mapping files

Upload the R8 or ProGuard mapping file of each Android release build, so its stack traces show your class and method names, and see how mappings are applied and how long they are kept.

R8 renames the classes and methods of an Android release build: a crash then reads `a.b.c`. The
build's mapping file turns those names back into yours. The Sentry Android Gradle plugin and
`sentry-cli` upload it to App Monitoring with nothing changed but the URL and `SENTRY_AUTH_TOKEN`.

## Prerequisites

- `errors:UploadSourceMaps` on the project, for whoever owns the token.
- A token: an auth token, or an upload token of one project (see
  [Upload source maps](upload-source-maps.md)).

## Upload with the Gradle plugin

1. Configure the plugin in `app/build.gradle.kts` as shown in
   [Set up a mobile app](set-up-a-mobile-app.md), with `url` set to your App Monitoring URL and
   `autoUploadProguardMapping` turned on.
2. Set `SENTRY_AUTH_TOKEN` in the environment of the release build.
3. Build the release (`./gradlew assembleRelease` or `bundleRelease`). The plugin writes a UUID
   into the app, uploads the mapping file under it, and the SDK names that UUID in every event.

Version 6 of the plugin (with `sentry-cli` 3) and version 5 (with `sentry-cli` 2) both upload
here.

## Upload with sentry-cli

When the mapping is uploaded by a separate step, upload it with its UUID:

```sh
sentry-cli proguard upload --uuid 5c3b1f84-0d6e-5b6a-9e8f-1a2b3c4d5e6f \
  app/build/outputs/mapping/release/mapping.txt
```

`sentry-cli upload-proguard` is the same command under its older name. The app must send the same
UUID: the Gradle plugin writes it into the app; without the plugin, set it in
`AndroidManifest.xml` as the `io.sentry.proguard-uuid` meta-data.

## How mappings are applied

- An event is retraced when it arrives, with the mapping of the UUID it names. A mapping uploaded
  later does not change events already received.
- A frame is shown with your class, method, file and line. A call R8 inlined into its caller is
  shown as its own frame again; turn on **Minified** on the issue page to see the frames as they
  were sent.
- An exception type R8 renamed is shown under its own name, in the title too.
- When the mapping was never uploaded, your app's frames are marked **no mapping file** and are
  left out of the fingerprint, since their names change with every build (see
  [Issues and grouping](issues-and-grouping.md)).
- A frame without a line number whose obfuscated name stands for several methods shows the first
  of them and is marked **ambiguous**.

## How long mappings are kept

A mapping file is kept for 30 days after its upload, and after that for as long as events use it:
it is deleted 30 days after the last event that needed it. An app version still in use keeps its
mapping.

## Related

- [Set up a mobile app](set-up-a-mobile-app.md)
- [Upload source maps](upload-source-maps.md)
- [Read events](read-events.md)
