Android error tracking installation
Contents
We currently don't support demangling stacktraces of minified builds (isMinifyEnabled=true) or source code context associated with an exception.
These features will be added in a future release.
- 1
Install PostHog Android SDK
RequiredSDK version requirementA minimum SDK version of 3.24.0 is required, but we recommend keeping up to date with the latest version to ensure you have all of error tracking's features.
The best way to install the PostHog Android library is with a build system like Gradle. This ensures you can easily upgrade to the latest versions.
All you need to do is add the
posthog-android
module to your App'sbuild.gradle
orbuild.gradle.kts
:app/build.gradleConfiguration
The best place to initialize the client is in your
Application
subclass.Kotlin - 2
Set up exception autocapture
RecommendedClient-side configuration onlyThis configuration is client-side only. Support for remote configuration in the error tracking settings will be added in a future release.
You can autocapture exceptions by setting the
errorTrackingConfig.autoCapture
argument totrue
when initializing the PostHog SDK.KotlinWhen enabled, this automatically captures
$exception
events when errors are thrown by wrapping theThread.UncaughtExceptionHandler
listener. - 3
Manually capture exceptions
OptionalIt is also possible to manually capture exceptions using the
captureException
method:KotlinThis is helpful if you've built your own error handling logic or want to capture exceptions that are handled by your application code.