Android Error Tracking installation
Install with the wizard
Run this command in your project directory to add PostHog to your Android project. The wizard detects your framework, installs the SDK, and sets up your first events.
Or set it up manually by following the rest of this guide.
- 1
Install the dependency
RequiredAdd the PostHog Android SDK to your
build.gradledependencies:build.gradle - 2
Configure PostHog
RequiredInitialize PostHog in your Application class:
SampleApp.kt - 3
Send events
RecommendedOnce installed, PostHog will automatically start capturing events. You can also manually send events to test your integration:
Kotlin - 4
Set up exception autocapture
RecommendedClient-side configuration onlySupport for remote configuration in the error tracking settings requires SDK version 3.32.0 or higher.
You can autocapture exceptions by setting the
errorTrackingConfig.autoCaptureargument totruewhen initializing the PostHog SDK.KotlinWhen enabled, this automatically captures
$exceptionevents when errors are thrown by wrapping theThread.UncaughtExceptionHandlerlistener.Planned featuresWe currently don't support source code context associated with an exception.
These features will be added in a future release.
- 5
Manually capture exceptions
OptionalIt is also possible to manually capture exceptions using the
captureExceptionmethod:KotlinThis is helpful if you've built your own error handling logic or want to capture exceptions that are handled by your application code.
- 6













