Android Setup
Add the native Android SDK to a development build, initialize it from Application, and verify the first connection.
Use ai.ansight:ansight-android
for the first integration. It includes the runtime, pairing, and standard native
tools. Use core and individual tool packages only when you need a narrower
surface.
1. Add the package
Add the aggregate package to the app module. Keep it in a dedicated development variant when the dependency must be absent from distributable builds.
Kotlin DSL
dependencies {
implementation("ai.ansight:ansight-android:1.4.0-preview.1")
}
Groovy
dependencies {
implementation 'ai.ansight:ansight-android:1.4.0-preview.1'
}
2. Initialize the development build
Initialize from the app’s Application subclass, inside onCreate() after
super.onCreate(). Register the class in AndroidManifest.xml with
android:name=".MyApplication" if the app does not already have a custom
Application.
import ai.ansight.Ansight
import android.app.Application
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
if (BuildConfig.DEBUG) {
Ansight.initializeAndActivateDeveloperMode(
application = this,
clientName = "Android App",
)
}
}
}
Use the app’s explicit QA or internal-build flag instead of BuildConfig.DEBUG
when that is the approved Ansight variant. Keep MainActivity for pairing UI
and other flows that require an Activity.
The developer preset enables host auto-probe, session capture, and standard native tools. Screen capture has a runtime cost; disable periodic JPEG capture for trend-focused runs unless visual evidence is required.
3. Add stable view ids
Give important Android views stable resource ids so visual-tree evidence stays easy to query across runs:
<Button
android:id="@+id/login_button"
android:text="Sign in" />
Use the equivalent stable test tag for controls owned by another UI framework.
4. Run and verify
Start the host in one terminal:
ansight host run
Launch the debug app on an emulator. From another terminal, confirm its session and tool catalog:
ansight session list --connected --json
ansight app tools <session-id> --detail summary --include-unavailable --max-results 50 --json
A physical device requires the one-time pairing flow.
Troubleshooting
- No connected session: confirm the host is running, the app is a Debug or
approved internal build, and
MyApplicationis registered in the manifest. - Dependency does not resolve: confirm
mavenCentral()is available to the app module and refresh Gradle dependencies. - The tool catalog is empty: confirm the developer preset ran and the active tool guard permits read access.
Platform Requirements
- The aggregate
ansight-androidpackage and QR pairing UI require Android API 23 or newer. - Core and individual tool artifacts can support lower API levels; use the highest minimum required by the selected package set. JNI reference diagnostics require API 21 or newer.
- The published libraries target Java 8 bytecode. The host app can use a newer Java or Kotlin toolchain.
Core-Only Setup
Choose the core, pairing, and individual tool dependencies on
Android Packages, then initialize the core from
the same Application.onCreate() startup location:
import ai.ansight.runtime.AnsightOptions
import ai.ansight.runtime.AnsightRuntime
AnsightRuntime.initializeAndActivate(
application = application,
options = AnsightOptions(
sampleFrequencyMilliseconds = 500,
retentionPeriodSeconds = 600,
),
)
Core defaults keep the tool guard disabled. Register tool packages explicitly and choose a guard before expecting tools to be discoverable.
Keep enrollment UI and broad remote tools out of Play Store, CI release, or other distributable builds.