Upload mappings for Android
- 1
Download CLI
Required - 2
Authenticate
RequiredTo authenticate the CLI, call the
logincommand. This opens your browser where you select your organization, project, and API scopes to grant:TerminalIf you are using the CLI in a CI/CD environment such as GitHub Actions, you can set environment variables to authenticate:
Environment Variable Description Source POSTHOG_CLI_HOSTThe PostHog host to connect to [default: https://us.posthog.com] Project settings POSTHOG_CLI_PROJECT_IDPostHog project ID Project settings POSTHOG_CLI_API_KEYPersonal API key with error tracking writeandorganization readscopesAPI key settings You can also use the
--hostoption instead of thePOSTHOG_CLI_HOSTenvironment variable to target a different PostHog instance or region. For EU users:Terminal - 3
Inject and upload
RequiredAGP v8 or later
Automatic mappings uploading is handled through the Gradle build process on Android.
Install the PostHog Android Gradle Plugin on your app's
build.gradle.ktsfile.KotlinIf you are running this in CI/CD, you can configure the CLI directly on the Gradle task instead of relying on
POSTHOG_CLI_HOST,POSTHOG_CLI_PROJECT_ID, andPOSTHOG_CLI_API_KEYenvironment variables:KotlinYou can also set
postHogExecutableif you want to use a customposthog-clipath. - 4
Upload native debug symbols (NDK)
OptionalRequires PostHog Android SDK 3.60.0 or later with
errorTrackingConfig.captureNativeCrashesenabled, Gradle plugin 1.5.0 or later, and CLI 0.7.32 or later.If your app includes native C or C++ code built with the NDK, upload the
.sodebug symbols so native crash stack traces resolve to function names, files, and line numbers.Enable the upload in your app's
build.gradle.kts:KotlinWhen enabled, the Gradle plugin's
uploadPostHogNativeSymbols<Variant>task reads the variant's unstripped native libraries and uploads every one carrying debug info and a build ID, automatically afterassemble,install, orbundle. This covers native code you build with the NDK as well as.sofiles bundled fromjniLibsor dependencies, for minified and non-minified builds alike. Debuggable variants are skipped, so day-to-day debug builds don't upload symbols.To include source context around resolved crash frames, also bundle the project sources referenced by the debug info:
KotlinYou can also run the upload task explicitly, for any variant, without enabling the automatic upload:
TerminalYou can also upload a directory of
.sofiles directly, without the Gradle plugin:TerminalPostHog matches crash frames to uploaded symbols by each library's GNU build ID, which the NDK emits by default. Each build has its own build ID, so symbols must be re-uploaded for every build you ship.
Native crash events are captured on the next app launch, so event properties like
$app_versionreflect the app at capture time, not at crash time. If the app updated in between, check the crash's release (matched by build ID) rather than the event's version properties when investigating.