Upload mappings for Android
- 1
Install hog
RequiredGradle plugin 1.9.0 or later uploads with hog
Install hog, PostHog's CLI:
In GitHub Actions, install hog with the
PostHog/setup-hogaction:YAMLBuilds without hogWhen hog isn't installed, the Gradle plugin uploads with posthog-cli and warns that posthog-cli is deprecated. Earlier plugin versions only run posthog-cli, version 0.7.4 or later. To keep posthog-cli while hog is installed, set
postHogExecutable = "posthog-cli". See Migrate from posthog-cli to hog. - 2
Authenticate
RequiredLog in to PostHog. This opens your browser, where you approve the login:
TerminalIf posthog-cli is already logged in on this machine, import that login instead:
TerminalThese CI providers can upload with the job's OIDC token, so you don't store a personal API key in CI.
- Logged in with
hog auth login, run this once in the repository:
Terminal- An organization admin approves the request in PostHog.
- Add the
hostandprojectIdthat hog prints toposthog.json, and add the snippet it prints to the job.
In GitHub Actions, the job needs the
id-token: writepermission:YAMLRemove any personal API key from the job. A key wins over the OIDC token.
Set these environment variables in the job:
Environment variable Description Source HOG_HOSTThe PostHog host to connect to, such as https://eu.posthog.com[default: https://us.posthog.com]Project settings HOG_PROJECT_IDPostHog project ID Project settings HOG_PERSONAL_API_KEYPersonal API key with the error_tracking:writescopeAPI key settings hog reads only the
HOG_*names. The PostHog build plugins and upload scripts still pass the oldPOSTHOG_CLI_*names to hog for now, with a warning for each one. Ahogcommand you run yourself needs theHOG_*names. The migration guide lists each rename. - 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 hog directly on the Gradle task instead of relying on the
HOG_HOST,HOG_PROJECT_ID, andHOG_PERSONAL_API_KEYenvironment variables:KotlinpostHogApiKeyis optional. Without it, hog uses the job's OIDC login fromhog ci setup, or the machine'shog auth login.You can also set
postHogExecutableto a custom CLI path. The plugin runs it as hog when the file is namedhog, and as posthog-cli otherwise. - 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. Uploads with posthog-cli need 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.





