> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mobileboost.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Setup

> Set up the MobileBoost SDK with your Espresso test suite

The MobileBoost SDK for Espresso supports both **Jetpack Compose** and **View/XML** based Android apps.

## Installation

Add the MobileBoost Android library to your dependencies ([Maven Central](https://central.sonatype.com/artifact/io.mobileboost.gptdriver/gptdriver-compose)):

```gradle title="build.gradle.kts (:app)" theme={null}
dependencies {
    // ...
    androidTestImplementation("io.mobileboost.gptdriver:gptdriver-compose:2.1.2")
    // ...
}
```

If needed, add packaging exclude rules in the `android` section of your `build.gradle.kts (:app)` file to resolve build failures caused by duplicate metadata files from dependencies:

```kotlin title="build.gradle.kts (:app)" theme={null}
android {
    // ...
    packaging {
        resources {
            excludes.addAll(listOf("META-INF/INDEX.LIST", "META-INF/io.netty.versions.properties"))
        }
    }
    // ...
}
```

If not already present, add internet permissions to your `AndroidManifest.xml`:

```xml title="AndroidManifest.xml" theme={null}
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- ... -->
    
    <uses-permission android:name="android.permission.INTERNET" />
    
    <application>
        <!-- ... -->
    </application>
    <!-- ... -->
</manifest>
```

## Jetpack Compose

Import the SDK and create a `GptDriver` instance in your test, passing the `ComposeTestRule`:

```kotlin theme={null}
import io.mobileboost.gptdriver_ktl.GptDriver

@get:Rule
val composeTestRule = createComposeRule()

val sdkInstance = GptDriver(
    apiKey = "<YOUR_API_KEY>",
    deviceName = "Emulator",
    platformVersion = "N/A",
    additionalUserContext = "",
    cachingMode = "INTERACTION_REGION",
    testId = "",
    composeTestRule = composeTestRule
)
```

### Caching modes

| Mode                 | Description                                               |
| -------------------- | --------------------------------------------------------- |
| `NONE`               | No caching                                                |
| `FULL_SCREEN`        | Cache hit only if the full screen matches                 |
| `INTERACTION_REGION` | Cache hit if the interaction region matches (recommended) |

## View/XML based apps

For traditional View-based apps, the setup is similar but uses an `ActivityScenarioRule` instead of `ComposeTestRule`.
