---
name: ansight-install-android
description: Use this skill when installing or configuring Ansight in a native Android Kotlin app. Add the Maven SDK dependency, initialize the runtime from the Application, infer Studio app metadata, register the app in Studio, issue a signed pairing config, wire bundled developer pairing through Debug-only BuildConfig or resources, choose a read-only default ToolGuard, keep `reflect.*` reflection tools as development-time dependencies by default, add required local-network permissions, install or recommend the ansight-app-inspection-android skill, create ansight-readme.md, and verify the Gradle build.
---

# Ansight Android Install Skill

Use this skill when a user asks an AI agent to install or configure Ansight for a native Android app.

Do not use this skill for React Native, .NET Android, Flutter, server, desktop, or generic JVM projects.

## Goal

Produce a working native Android Ansight integration for local developer workflows, register the app with Studio, issue a signed pairing config, keep pairing and tools Debug-only or runtime-guarded, configure or recommend the companion Android app-inspection skill, create `ansight-readme.md`, verify the Gradle build, and explain remaining app UI or Studio steps.

## Package Defaults

Use the all-in-one Android artifact by default:

```kotlin
debugImplementation("ai.ansight:ansight-android:1.0.2-preview.1")
```

Published artifact: [`ai.ansight:ansight-android`](https://central.sonatype.com/artifact/ai.ansight/ansight-android).

Use `implementation(...)` only when the user explicitly wants Ansight in a non-public internal variant and accepts the security tradeoff. Use core and individual artifacts only when the user asks for a narrower surface:

- [`ai.ansight:ansight-core-android`](https://central.sonatype.com/artifact/ai.ansight/ansight-core-android)
- [`ai.ansight:ansight-pairing-android`](https://central.sonatype.com/artifact/ai.ansight/ansight-pairing-android)
- [`ai.ansight:ansight-tools-visualtree-android`](https://central.sonatype.com/artifact/ai.ansight/ansight-tools-visualtree-android)
- [`ai.ansight:ansight-tools-filesystem-android`](https://central.sonatype.com/artifact/ai.ansight/ansight-tools-filesystem-android)
- [`ai.ansight:ansight-tools-preferences-android`](https://central.sonatype.com/artifact/ai.ansight/ansight-tools-preferences-android)
- [`ai.ansight:ansight-tools-securestorage-android`](https://central.sonatype.com/artifact/ai.ansight/ansight-tools-securestorage-android)
- [`ai.ansight:ansight-tools-database-android`](https://central.sonatype.com/artifact/ai.ansight/ansight-tools-database-android)
- [`ai.ansight:ansight-tools-reflection-android`](https://central.sonatype.com/artifact/ai.ansight/ansight-tools-reflection-android)

The Android reflection suite exposes `reflect.*`. Default it to `debugImplementation` or an explicit local-development variant, including when using the all-in-one artifact. Do not enable `reflect.*` in release/distributable variants without explicit user approval and matching runtime guards.

When versions are uncertain, inspect existing project usage or verify the published SDK version before changing dependencies.

## Inputs To Confirm

- Android app module that owns the `Application` class
- Kotlin DSL or Groovy Gradle build files
- whether the app has an existing debug menu, settings row, hidden gesture, or developer screen for pairing
- whether QR pairing, screen views, lifecycle events, custom logs, JPEG session capture, or specific tool suites are requested
- Studio registration metadata only if it cannot be inferred
- pairing config duration, defaulting to `7d` or a short local-development duration when unspecified

## Required Constraints

- preserve existing Gradle, dependency, DI, logging, and app startup patterns
- initialize from `Application.onCreate()` or a bootstrap it calls
- prefer `debugImplementation` for the all-in-one artifact
- default `reflect.*` reflection tools to development-time Gradle scopes and Debug/local-development guards
- keep generated pairing JSON out of source control
- infer Studio metadata before asking the user
- use Studio MCP tools for app registration and pairing config issuance when available
- do not hand-author signed pairing configs
- default to read-only tool access
- disable tools in non-debug builds when the dependency is present
- add QR scanning only when requested or when an existing scanner flow is identified
- do not print full pairing JSON, one-time tokens, or compact pairing codes in the final response unless explicitly requested

## Workflow

1. Identify the Android app module and its `namespace`, `applicationId`, manifest package, launcher activity, and `Application` class.
2. Check whether Ansight is already installed by inspecting Gradle dependencies and imports.
3. Infer Studio metadata:
   - `appId`: Gradle `applicationId`, manifest package, or namespace
   - `appName`: manifest `android:label`, string resource, or module name
   - `codebasePath`: nearest repo root or app module root
   - icon: manifest `android:icon` resolved to the best resource path when available
4. Ensure pairing artifacts are ignored by source control:
   - `ansight.json`
   - `*.ans.json`
   - `ansight.developer-pairing.json`
5. Add the dependency to the Android app module, preferably as `debugImplementation`.
6. Register the app with Studio and issue a signed pairing config through MCP.
7. Save the returned `configJson` to a local ignored file such as `<module>/ansight.json`.
8. Wire the config into the debug build using an existing secure local mechanism, commonly a generated `BuildConfig` string or a debug-only raw asset. Do not wire it into release variants.
9. Initialize Ansight from `Application.onCreate()`.
10. Add baseline local-network permissions.
11. Add optional QR pairing or explicit pairing entry points only when requested.
12. Add or recommend the `ansight-app-inspection-android` skill.
13. Create `ansight-readme.md`.
14. Run the relevant Gradle build and report changed files, Studio ids, local config path, and remaining manual steps.

## Gradle Shape

Kotlin DSL:

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

android {
    buildFeatures {
        buildConfig = true
    }

    buildTypes {
        debug {
            val ansightConfig = project.file("ansight.json")
            buildConfigField(
                "String",
                "ANSIGHT_DEVELOPER_PAIRING_JSON",
                if (ansightConfig.exists()) "\"${ansightConfig.readText().replace("\\", "\\\\").replace("\"", "\\\"").replace("\n", "\\n").replace("\r", "\\r")}\"" else "null"
            )
        }
        release {
            buildConfigField("String", "ANSIGHT_DEVELOPER_PAIRING_JSON", "null")
        }
    }
}
```

Adapt the file path to the project. If the project already has a generated config mechanism, use that instead of introducing a new pattern.

## Runtime Setup

Initialize from the app `Application`.

```kotlin
import ai.ansight.Ansight
import ai.ansight.runtime.AnsightOptions
import android.app.Application

class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()

        val options = AnsightOptions.createBuilder(
            Ansight.developerOptions(
                bundledDeveloperConfigJson = BuildConfig.ANSIGHT_DEVELOPER_PAIRING_JSON,
                clientName = "Android App",
            )
        )
            .apply {
                if (BuildConfig.DEBUG) {
                    withReadOnlyToolAccess()
                } else {
                    withToolsDisabled()
                }
            }
            .build()

        Ansight.initializeAndActivate(this, options)
    }
}
```

Use `withReadWriteToolAccess()` or `withAllToolAccess()` only when the requested workflow needs mutation or delete-scoped tools.

## Permissions

Add baseline permissions to the app manifest:

```xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
```

Do not add `android:usesCleartextTraffic="true"` by default. Add `CAMERA` only when QR pairing is actually exposed and request camera permission at runtime before scanning.

## Studio Registration And Pairing

Use the Ansight Studio MCP tools when available:

```json
{
  "name": "ansight_register_app",
  "arguments": {
    "appId": "INFERRED_APPLICATION_ID",
    "appName": "INFERRED_APP_NAME",
    "codebasePath": "/absolute/path/to/repo-or-module"
  }
}
```

```json
{
  "name": "ansight_issue_pairing_config",
  "arguments": {
    "appId": "INFERRED_APPLICATION_ID",
    "appName": "INFERRED_APP_NAME",
    "duration": "7d"
  }
}
```

Save the returned `configJson` locally. Do not commit it. Prefer the stdio bridge `ansight-daemon mcp-stdio` for future agent access.

## Agent Inspection Skill

Install or recommend:

```text
https://www.ansight.ai/skills/android/ansight-app-inspection-android.md
```

Do not claim it was installed unless the agent configuration was actually updated.

## ansight-readme.md

Create `ansight-readme.md` near the app module or repo root:

```markdown
# Ansight Android Pairing Notes

- App id: `REPLACE_WITH_APPLICATION_ID`
- App name: `REPLACE_WITH_APP_NAME`
- Local pairing config: `REPLACE_WITH_LOCAL_ANSIGHT_JSON_PATH`
- Dependency: `ai.ansight:ansight-android`
- Default guard: read-only in Debug, disabled outside Debug
- Reflection tools: `reflect.*`, development-time dependency by default
- Recommended agent skill: `https://www.ansight.ai/skills/android/ansight-app-inspection-android.md`

## Pairing

1. Open Ansight Studio.
2. Select this app.
3. Issue or select a pairing config.
4. Launch the Android app in a Debug build.
5. If automatic bundled developer pairing is configured, the app can connect from the bundled config.
6. If QR pairing is required, wire a developer-only app UI entry point before using it.
```

## Verification

Run the relevant build:

```bash
./gradlew :app:assembleDebug
```

When practical, also run:

```bash
./gradlew :app:assembleRelease
```

Done criteria:

- app builds
- dependency is scoped to the intended variant
- app initializes Ansight from `Application.onCreate()`
- non-debug runtime guard disables tools
- debug guard is no broader than needed
- local pairing config exists and is ignored
- Studio app registration and pairing config were created
- `ansight-readme.md` documents remaining pairing UI work
- final response lists changed files, app id, pairing config id/expiry, verification commands, and remaining manual steps
