---
title: "SDK Initialization"
canonical_url: "https://apidocs.sportradar.com/resources/virtual-stadium/docs/android/usage"
markdown_url: "https://apidocs.sportradar.com/resources/virtual-stadium/docs/android/usage.md"
last_updated: "2026-04-16T10:19:11Z"
---

# SDK Initialization

Before using any Virtual Stadium UI components, you must initialize the SDK in your Android application. This guide covers the initialization process and essential configuration steps.

***

## Initialize the SDK

The SDK must be initialized once when your application starts. The recommended place to do this is in your custom `Application` class.

### Step 1: Create or Update Application Class

If you don't already have a custom Application class, create one:

***VSDemoApp.kt:***

```kotlin
import android.app.Application
import ag.sportradar.virtualstadium.uisdk.VirtualStadiumUISDK

class VSDemoApp : Application() {

    override fun onCreate() {
        super.onCreate()

        // Initialize Virtual Stadium UI SDK
        VirtualStadiumUISDK.init(applicationContext)
    }
}
```

### Step 2: Register in AndroidManifest.xml

Register your Application class in `AndroidManifest.xml`:

***AndroidManifest.xml:***

```xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.app">

    <application
        android:name=".VSDemoApp"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/Theme.App">
        
        <!-- Your activities -->
        <activity android:name=".MainActivity">
            <!-- ... -->
        </activity>
        
    </application>

</manifest>
```

> **Tip**
>
> The `init()` method should be called only once, in the `onCreate()` of your Application class. Calling it multiple times or in other locations may cause unexpected behavior.

***

## Keyboard Configuration

For proper interaction between the chat component and the soft keyboard, you need to configure window insets and input mode settings.

### Window Insets Configuration

Configure whether the window resizes to accommodate the keyboard. This setting depends on how you're using the chat component.

#### Full-Screen Chat

If the chat component **fills the entire screen**, set `decorFitsSystemWindows` to `false`:

***MainActivity.kt:***

```kotlin
import androidx.core.view.WindowCompat

class MainActivity : ComponentActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        // Chat fills the screen
        WindowCompat.setDecorFitsSystemWindows(
            window, 
            decorFitsSystemWindows = false
        )

        setContent {
            Chat(
                jwtToken = "<jwt-token>",
                channelId = "<channel-id>",
                modifier = Modifier.fillMaxSize()
            )
        }
    }
}
```

#### Partial-Screen Chat

If the chat component is **part of a larger layout**, set `decorFitsSystemWindows` to `true`:

***MainActivity.kt:***

```kotlin
import androidx.core.view.WindowCompat

class MainActivity : ComponentActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        // Chat is part of the layout
        WindowCompat.setDecorFitsSystemWindows(
            window, 
            decorFitsSystemWindows = true
        )

        setContent {
            Column {
                TopAppBar(/* ... */)
                Chat(
                    jwtToken = "<jwt-token>",
                    channelId = "<channel-id>",
                    modifier = Modifier.weight(1f)
                )
            }
        }
    }
}
```

### Input Mode Configuration

Set the soft input mode to `adjustResize` in your `AndroidManifest.xml`. This ensures the keyboard pushes content up rather than covering it.

***AndroidManifest.xml:***

```xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

    <application>
        <activity 
            android:name=".MainActivity"
            android:windowSoftInputMode="adjustResize">
            <!-- ... -->
        </activity>
    </application>

</manifest>
```

> **Info**
>
> The `adjustResize` mode is crucial for proper keyboard behavior. Without it, the keyboard may cover the input field or cause layout issues.

***

## Configuration Overview

Here's a complete checklist of the initialization and configuration steps:

| Step  | Action                     | Location                 | Required |
| ----- | -------------------------- | ------------------------ | -------- |
| **1** | Initialize SDK             | `Application.onCreate()` | ✅ Yes    |
| **2** | Register Application class | `AndroidManifest.xml`    | ✅ Yes    |
| **3** | Configure window insets    | `Activity.onCreate()`    | ✅ Yes    |
| **4** | Set input mode             | `AndroidManifest.xml`    | ✅ Yes    |

***

## Complete Example

Here's a complete example showing all configuration steps together:

***VSDemoApp.kt:***

```kotlin
import android.app.Application
import ag.sportradar.virtualstadium.uisdk.VirtualStadiumUISDK

class VSDemoApp : Application() {
    override fun onCreate() {
        super.onCreate()
        VirtualStadiumUISDK.init(applicationContext)
    }
}
```

***MainActivity.kt:***

```kotlin
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.ui.Modifier
import androidx.core.view.WindowCompat
import ag.sportradar.virtualstadium.uisdk.compose.Chat

class MainActivity : ComponentActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        // Configure window for keyboard interaction
        WindowCompat.setDecorFitsSystemWindows(window, false)

        setContent {
            Chat(
                jwtToken = "<your-jwt-token>",
                channelId = "<your-channel-id>",
                languageCode = LanguageCode.EN,
                modifier = Modifier.fillMaxSize()
            )
        }
    }
}
```

***AndroidManifest.xml:***

```xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.vsdemo">

    <application
        android:name=".VSDemoApp"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/Theme.App">
        
        <activity 
            android:name=".MainActivity"
            android:windowSoftInputMode="adjustResize"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        
    </application>

</manifest>
```

***

## Troubleshooting

### SDK Not Initialized Error

If you see an error about the SDK not being initialized:

- Verify `VirtualStadiumUISDK.init()` is called in `Application.onCreate()`
- Ensure your Application class is registered in `AndroidManifest.xml`
- Check that the Application class name includes the correct package

### Keyboard Covering Input

If the keyboard covers the chat input field:

- Verify `windowSoftInputMode="adjustResize"` is set in `AndroidManifest.xml`
- Check `WindowCompat.setDecorFitsSystemWindows()` is configured correctly
- Ensure you're using the correct `decorFitsSystemWindows` value for your layout

### Layout Issues

If you experience layout problems when the keyboard appears:

- Try toggling the `decorFitsSystemWindows` parameter
- Verify your Compose modifiers are properly configured
- Check that parent layouts use appropriate size modifiers

***

## Next Steps

Now that the SDK is initialized and configured, you're ready to implement the chat component:

**Implement Chat Component**

Learn how to add the Chat component to your app with all its parameters, features, and customization options.

[Continue to Chat →](https://apidocs.sportradar.com/resources/virtual-stadium/docs/android/chat.md)
