# Android (Kotlin) SDK Configuration Options Reference


The RudderStack Android (Kotlin) SDK provides various configuration options to customize its behavior according to your requirements. This guide covers all the available configuration options and their usage.

## Configuration class

The `Configuration` class is used to initialize the RudderStack SDK in your Android application. It defines the required parameters and optional configuration settings to customize the SDK behavior.

## SDK configuration options

| Parameter | Type | Description |
| :----------| :------------| :-------------|
| `writeKey` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | String | The source write key obtained from the RudderStack dashboard used for authentication. |
| `application` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | Application | The Android `Application` instance used to initialize the SDK. It is used for accessing Android-specific functionality and tracking lifecycle events. |
| `dataPlaneUrl` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | String | The URL of your RudderStack data plane (backend) where the events are sent. |
| `trackApplicationLifecycleEvents` | Boolean | Enables automatic tracking of [application lifecycle events]({{< ref "sources/event-streams/sdks/client-side-features/lifecycle-events-tracking.md" >}}) (app start, background, and foreground transitions). <br /><br />**Default value:** `true`  |
| `trackDeepLinks` | Boolean | Enables automatic tracking of [deep link events]({{< ref "sources/event-streams/sdks/client-side-features/deep-link-tracking.md" >}}). <br /><br />**Default value:** `true`  |
| `trackActivities` | Boolean | Enables [automatic tracking]({{< ref "sources/event-streams/sdks/client-side-features/automatic-screen-tracking.md#activity-tracking" >}}) of the activity lifecycle, triggering `screen` events for each activity. <br /><br />**Default value:**  `false`  |
| `collectDeviceId` | Boolean | Enables [automatic collection](#device-id-collection) of the device's unique ID. <br /><br />**Default value:** `true` |
| `sessionConfiguration` | SessionConfiguration | Configuration settings for managing user sessions. <br /><br /><ul><li>See [Session Tracking]({{< ref "sources/event-streams/sdks/client-side-features/session-tracking.md" >}}) for more information on session management in the Android (Kotlin) SDK.</li><li>See [Session configuration](#session-configuration) for more information on the session configuration options and their default values.</li></ul> |
| `controlPlaneUrl` | String | URL for remote configuration management. <br /><br />**Default value:**  `https://api.rudderlabs.com` |
| `flushPolicies` | List of flush policies | Specifies when and how events are sent to the RudderStack backend. <br /><br />See [Flush policies in Android (Kotlin) SDK]({{< ref "sources/event-streams/sdks/mobile-sdk-apis/flush-api.md#flush-policies" >}}) for more information. <br /><br />**Default value:**  `listOf(CountFlushPolicy(), FrequencyFlushPolicy(), StartupFlushPolicy())`  |
| `gzipEnabled` | Boolean | Enables or disables [Gzip compression](#request-compression) for network requests. <br /><br />**Default value:**  `false` |

## Session configuration

The `SessionConfiguration` class provides the following parameters to customize session management:

| Parameter | Type | <div style="width: 300px;">Description</div> | 
| :----------| :------------| :-------------| 
| `automaticSessionTracking` | Boolean | Enables automatic session tracking. <br /><br /> **Default value:** `true` |
| `sessionTimeoutInMillis` | Long | Sets the timeout duration for automatic session tracking in milliseconds. It is the time between the app closed or backgrounded to being foregrounded or relaunched again. <br /><br />The SDK times out a session and starts a new session after this time has elapsed. <br /><br />**Default value:** `300000` (5 minutes) |
| `updateSessionOnBackgroundEvents` | Boolean | When `false`, background events do not extend the session lifetime. Set to `true` to allow background events to extend the session lifetime. <br /><br />See the [Session tracking]({{< ref "sources/event-streams/sdks/client-side-features/session-tracking.md#configuration-parameters" >}}) guide for details. <br /><br />**Default value:** `false` |

## Device ID collection

When you enable `collectDeviceId`, the SDK retrieves a unique device ID using the `Settings.Secure.ANDROID_ID` API and includes it in the event payload under the `device.id` field in the event's `context` object.

{{< warning >}}
If the SDK retrieves an empty or invalid value for the device ID, it will not include the `device.id` field in the event payload's `context`.
{{< /warning >}}

## Request compression

When you set `gzipEnabled` to `true`, all `/batch` requests sent by the SDK will have their payloads compressed using Gzip compression, thereby reducing the size of the network requests.

## Sample SDK initialization

The following snippet demonstrates how to initialize the Android (Kotlin) SDK with the supported configuration options:

```kotlin
val analytics = Analytics(
    configuration = Configuration(
        // Required parameters
        application = application,
        writeKey = "YOUR_WRITE_KEY",
        dataPlaneUrl = "YOUR_DATA_PLANE_URL",
        
        // Optional parameters
        controlPlaneUrl = "YOUR_CONTROL_PLANE_URL",
        trackApplicationLifecycleEvents = true,
        trackDeepLinks = true,
        trackActivities = true,
        collectDeviceId = true,
        sessionConfiguration = SessionConfiguration(
            automaticSessionTracking = true,
            sessionTimeoutInMillis = 3000
        ),
        gzipEnabled = true,
        flushPolicies = listOf(CountFlushPolicy(flushAt = 10)) // Sets custom flush policies
    )
)
```
