---
name: ansight-migrate-sdk-1-1-android
description: Migrate a native Android Kotlin or Java app from an older Ansight pairing-config integration to SDK 1.1 zero-touch developer enrollment. Use when upgrading Gradle dependencies, deleting bundled pairing JSON or host and Wi-Fi build settings, replacing manual connection startup, or adding generic QR enrollment without requesting the Android camera permission.
---

# Migrate Android to Ansight SDK 1.1

Upgrade the app to automatic emulator enrollment and one-use physical-device
QR enrollment. Remove the old pairing-config path completely.

## Migration

1. Find the application module, `Application` startup, build variants, existing
   Ansight initialization, and any developer menu.
2. Upgrade the local-development dependency:

```kotlin
dependencies {
    debugImplementation("ai.ansight:ansight-android:1.4.0-preview.1")
}
```

   Keep every direct SDK reference in the matching debug source set. If the
   app intentionally compiles the integration from shared main sources, use
   `implementation` and enforce the development-only runtime guard explicitly
   instead.
3. Delete generated assets and Gradle tasks that package pairing JSON, host
   addresses, Wi-Fi names, machine names, signing keys, or certificates.
4. Remove code that parses or passes pairing configuration. Do not preserve a
   file, environment-variable, or manual-host fallback.
5. Initialize once from `Application.onCreate()`:

```kotlin
class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        Ansight.initializeAndActivate(
            application = this,
            clientName = "Android App",
        )
    }
}
```

6. Add a developer-only physical-device action:

```kotlin
Ansight.enrollFromQrCode(activity)
```

7. Keep the dependency, scanner action, reflection, secure-storage access,
   writes, and deletes limited to the intended local-development variant.

## Enrollment behavior

- An Android emulator connects automatically to a running CLI host on the same
  development machine.
- A physical device scans the generic QR from `ansight pairing issue --qr` once;
  the SDK supplies its real App ID and does not require prior registration.
- The app stores a random installation id and enrollment state in app-private
  preferences and reconnects automatically on later launches.

## Permissions

Do not add `android.permission.CAMERA`. The SDK scanner uses Google Code
Scanner. Keep only ordinary network access and the clear-text local-development
transport merged by the SDK. Do not add location, Bluetooth, contacts, storage,
or other unrelated permissions.

## Verification

Run the debug build and relevant tests:

```shell
./gradlew :app:assembleDebug
```

When practical, build the distributable variant and confirm it omits the
developer integration:

```shell
./gradlew :app:assembleRelease
```

Launch the emulator twice with `ansight host run` active. Verify the first
launch registers through `ansight session list --connected --app-id <app-id> --json`
and the second reconnects without a QR or configuration file. Repeat
on a physical device using one terminal QR scan.
