Size Analysis

Upload Android builds to Sentry for Size Analysis.

Size Analysis helps monitor your mobile app's size in pre-production to prevent unexpected size increases (regressions) from reaching users. Aside from being courteous to your users, a smaller app size helps boost installation and retention rates, especially for customers with limited storage or slower connections.

Accepted Formats: AAB (preferred) | APK

Upload Mechanisms: Gradle | Sentry CLI

The Gradle plugin automatically detects build metadata from your git repository. On GitHub Actions, all metadata is automatically detected. On other CI systems, you may need to manually set some values using the vcsInfo extension.

  1. Configure the Sentry Android Gradle plugin with at least version 6.0.0-beta1
  2. Set the auth token as an environment variable to be used when running your release build.

    Copied
    export SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___
  3. Enable uploading for size analysis for CI builds.

    build.gradle.kts
    Copied
    sentry {
      sizeAnalysis {
        enabled = providers.environmentVariable("GITHUB_ACTIONS").isPresent
      }
    }
  4. Invoke the following Gradle tasks to build your app and trigger the upload.

    aab
    Copied
    ./gradlew bundleRelease
  5. After an upload has successfully processed, confirm the metadata is correct in the Sentry UI

    Upload metadata

Overriding Metadata

The Gradle plugin automatically detects build metadata from your git repository. On GitHub Actions, all metadata is automatically detected. On other CI systems, you may need to manually set some values using the vcsInfo extension.

Configure overrides in your Gradle build configuration:

build.gradle.kts
Copied
sentry {
  sizeAnalysis {
    enabled = providers.environmentVariable("GITHUB_ACTIONS").isPresent
  }

  vcsInfo {
    headSha.set("abc123")
    baseSha.set("def456")
    vcsProvider.set("github")
    headRepoName.set("organization/repository")
    baseRepoName.set("organization/repository")
    headRef.set("feature-branch")
    baseRef.set("main")
    prNumber.set(42)
  }
}

Available vcsInfo properties:

PropertyTypeDescription
headShaStringCurrent commit SHA
baseShaStringBase commit SHA (for comparison)
vcsProviderStringVCS provider (e.g., "github")
headRepoNameStringRepository name (org/repo format)
baseRepoNameStringBase repository name
headRefStringBranch or tag name
baseRefStringBase branch name
prNumberIntPull request number

  1. Install the sentry-cli (version 2.58.3)

  2. Authenticate the Sentry CLI by following these steps

  3. Build your app to create an AAB (preferred) or APK

  4. Invoke the following CLI command to trigger the upload:

    Copied
    sentry-cli build upload app.aab \
      --org your-org \
      --project your-project \
      --build-configuration Release
    
  5. After an upload has successfully processed, confirm the metadata is correct in the Sentry UI

We use build metadata to organize builds in the UI and ensure correct comparisons.

FieldDescription
org*Sentry organization slug
project*Sentry project slug
build-configuration*Build configuration describing how the app was built, for example Release or Debug or Release-Bazel
head-shaCurrent commit SHA
base-shaBase commit SHA (for comparisons, recommended to use the branch's merge-base)
head-repo-nameRepository name (org/repo)
pr-numberPull request number
head-refBranch or tag name
base-refBase branch name

* required field

Build configuration metadata keeps comparisons scoped to like-for-like builds. For example, on a PR status check, the comparison will only be made for builds with the same build configuration.

The Android Gradle plugin sends the build variant (for example, freeDebug or paidRelease).

We strongly recommend integrating Size Analysis into your CI pipeline. Follow our guide on getting set up in CI.

Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").