> AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt # Android Session Replay installation 1. 1 ## Install the dependency Required Add the PostHog Android SDK to your `build.gradle` dependencies: build.gradle ```kotlin dependencies { implementation("com.posthog:posthog-android:3.+") } ``` **SDK version** Session replay requires PostHog Android SDK version 3.4.0 or higher. We recommend always using the latest version. 2. 2 ## Enable session recordings in project settings Required Go to your PostHog [Project Settings](https://us.posthog.com/settings/project-replay) and enable **Record user sessions**. Session recordings will not work without this setting enabled. 3. 3 ## Configure PostHog with session replay Required Add `sessionReplay = true` to your PostHog configuration. Here are all the available options: SampleApp.kt ```kotlin import com.posthog.android.replay.PostHogScreenshotColorMode class SampleApp : Application() { companion object { const val POSTHOG_TOKEN = "" const val POSTHOG_HOST = "https://us.i.posthog.com" } override fun onCreate() { super.onCreate() val config = PostHogAndroidConfig( apiKey = POSTHOG_TOKEN, host = POSTHOG_HOST ) // Enable session recording. Requires enabling in your project settings as well. // Default is false. config.sessionReplay = true // Whether text and text input fields are masked. Default is true. // Password inputs are always masked regardless config.sessionReplayConfig.maskAllTextInputs = true // Whether images are masked. Default is true. config.sessionReplayConfig.maskAllImages = true // Capture logs automatically. Default is true. // // Support for remote configuration // in the [session replay settings](https://app.posthog.com/settings/project-replay#replay-log-capture) // requires SDK version 3.32.0 or higher. config.sessionReplayConfig.captureLogcat = true // Whether replays are created using high quality screenshots. Default is false. // If disabled, replays are created using wireframes instead. // The screenshot may contain sensitive information, so use with caution config.sessionReplayConfig.screenshot = false // Experimental screenshot settings require SDK 3.63.0+ and screenshot = true. // We recommend the values below to balance performance and image quality. // Lower resolution and RGB_565 reduce capture time and memory use. // Scale each screenshot dimension from 0.1 to 1.0. Default is 1.0. config.sessionReplayConfig.screenshotScale = 0.5f // RGB_565 uses two bytes per pixel instead of four, with lower color precision // and no transparency. Transparent window regions appear black. Default is ARGB_8888. config.sessionReplayConfig.screenshotColorMode = PostHogScreenshotColorMode.RGB_565 // WebP compression quality from 0 to 100. Default is 30. config.sessionReplayConfig.screenshotCompressionQuality = 30 // Throttle delay used to reduce the number of snapshots captured. Default is 1000ms config.sessionReplayConfig.throttleDelayMs = 1000 // Sample rate for session recordings. A value between 0.0 and 1.0. // 1.0 means 100% of sessions will be recorded. 0.5 means 50%, and so on. // Default is null (all sessions are recorded). // // Support for remote configuration // in the [session replay triggers](https://us.posthog.com/settings/project-replay#replay-triggers) // requires SDK version 3.34.0 or higher. config.sessionReplayConfig.sampleRate = null PostHogAndroid.setup(this, config) } } ``` For more configuration options, see the [Android session replay docs](/docs/session-replay/installation?tab=Android.md). **Requirements** Requires Android API 26 or higher. Jetpack Compose is only supported if `screenshot` is enabled. 4. 4 ## Watch session recordings Recommended Visit your site or app and interact with it for at least 10 seconds to generate a recording. Navigate between pages, click buttons, and fill out forms to capture meaningful interactions. [Watch your first recording →](https://app.posthog.com/replay/home) 5. 5 ## Next steps Recommended Now that you're recording sessions, continue with the resources below to learn what else Session Replay enables within the PostHog platform. | Resource | Description | | --- | --- | | [Watching recordings](/docs/session-replay/how-to-watch-recordings.md) | How to find and watch session recordings | | [Privacy controls](/docs/session-replay/privacy.md) | How to mask sensitive data in recordings | | [Network recording](/docs/session-replay/network-recording.md) | How to capture network requests in recordings | | [Console log recording](/docs/session-replay/console-log-recording.md) | How to capture console logs in recordings | | [More tutorials](/docs/session-replay/tutorials.md) | Other real-world examples and use cases | ### Still have questions? Ask PostHog AI ### Was this page useful? HelpfulCould be better