Android SDK

The Android SDK is the primary runtime integration for Snapbug.

Use it to stream inspection data from your app into the Chrome Extension, the optional local service flow, or a direct localhost/desktop connection.

Requirements

  • Android minSdk 23
  • An app module applying com.android.application
  • Android toolchain floor (older project templates ship below it and fail to build until it is raised):
WhatMinimum
compileSdk36
Android Gradle plugin8.6.0
Gradle wrapper8.7
Kotlin Gradle plugin2.2

Raise only what is below the minimum. Typical errors when a floor is missed: requires … compileSdk 36, requires Android Gradle plugin 8.6.0, incompatible version of Kotlin. Upgrade the Kotlin Gradle plugin rather than downgrading Snapbug.

The debug APK grows by tens of megabytes (the inspector transport and the overlay UI). A minified release (R8) grows by only tens of kilobytes; without minification the no-op twin still brings the libraries its API names (Ktor, gRPC, Room), a couple of megabytes.

Install

Let your AI coding agent do this integration for you — see Install with an AI agent.

Add the core runtime in debug and the no-op twin in release:

dependencies {
    debugImplementation("ai.snapbug:snapbug:1.0.4")
    releaseImplementation("ai.snapbug:snapbug-no-op:1.0.4")
}

If you use a version catalog:

[versions]
snapbug = "1.0.4"
 
[libraries]
snapbug = { module = "ai.snapbug:snapbug", version.ref = "snapbug" }
snapbug-no-op = { module = "ai.snapbug:snapbug-no-op", version.ref = "snapbug" }
dependencies {
    debugImplementation(libs.snapbug)
    releaseImplementation(libs.snapbug.no.op)
}

Gradle turns - into . in catalog accessors, so snapbug-no-op becomes libs.snapbug.no.op. The artifacts come from Maven Central, so make sure mavenCentral() is in your repositories.

If your app has build types other than debug and release (for example staging), add the matching line for each one: the live artifact for builds that testers install, the no-op one for builds that reach end users.

Start the SDK

Initialize Snapbug from your launcher Activity (the one with the MAIN / LAUNCHER intent filter), right after super.onCreate. It takes an Activity, not an Application, because the overlay needs one. Repeated calls (rotation, re-creation) are safe.

import io.snapbug.sdk.Snapbug
import io.snapbug.sdk.start
 
class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        Snapbug.start(this)
    }
}

import io.snapbug.sdk.start is the extension function that provides Snapbug.start. It is required, even if your IDE shows it as unused. Do not guard the call with BuildConfig.DEBUG: the swap happens at the dependency level, and in release the no-op start does nothing.

If your app has a splash or router Activity that finishes immediately, put the call in the first Activity that stays on screen.

This one line enables the default plugin set: network, database, analytics, crash reporter, device info, deep links, logs, and the debug feedback overlay.

Optional configuration

You can customize the integration with the DSL — pick the overlay mode, toggle plugins on/off, or configure individual plugins:

Snapbug.start(this) {
    overlay = OverlayMode.BUBBLE   // BUBBLE (default), FAB, or NONE
    crashReporter { catchFatalErrors = true }
    database { room() }
    debugFeedback { screenNameProvider = { currentScreenName } }
    logs = true                    // logcat streaming (on by default)
}

Overlay modes:

  • BUBBLE — system floating bubble (requires the SYSTEM_ALERT_WINDOW permission). Default.
  • FAB — a Compose FAB, no special permissions, requires Snapbug.Overlay in your Compose tree.
  • NONE — no overlay UI, data collection only.

Logs

The logs plugin streams your app's logcat output (filtered to your process) into the Logs inspector in real time. It is part of the default plugin set — Log.d/i/w/e, println, and stack traces of uncaught exceptions all show up without extra setup. Disable it with logs = false in the start DSL.

Connection modes

Use room-code pairing and WebRTC transport. This is the main onboarding path for new users.

Optional: local service

Run snapbug serve if you need AI workflows from the extension.

Direct: localhost/desktop

Connect through the local service or the desktop app over local ports 9023 and 9024.

Network security

If you use the direct localhost path on Android 9+, cleartext traffic to localhost and 127.0.0.1 must be allowed. The debug SDK ships a network security config that does exactly that. If your app sets its own android:networkSecurityConfig, yours wins: add those two domains to it. If you are on SDK 0.1.1 and a debug build fails with resource xml/network_security_config ... not found, upgrade Snapbug.

The Chrome Extension WebRTC path does not need this configuration.

Integrations included in the SDK

ai.snapbug:snapbug is all-in-one: besides the core plugins it already contains the OkHttp, Ktor, gRPC (protobuf-lite) and Room / Room 3 integrations, and ai.snapbug:snapbug-no-op contains their no-op twins. Add only the code, no extra dependency:

// OkHttp (also Retrofit, Coil and Glide when they use this client)
val client = OkHttpClient.Builder()
    .addInterceptor(authInterceptor)              // existing interceptors stay first
    .addInterceptor(SnapbugOkhttpInterceptor())   // Snapbug goes last
    .build()
 
// Ktor
val ktor = HttpClient(OkHttp) {
    install(SnapbugKtorPlugin)
}
 
// Room
snapbugRegisterDatabase("app.db", db)

Do not add per-plugin artifacts (snapbug-okhttp-interceptor, snapbug-ktor-interceptor, snapbug-database-room, snapbug-analytics, snapbug-crashreporter, …) next to the all-in-one. In release they land next to their no-op twins and the build fails with Duplicate class.

See Network Inspector, Database Explorer and gRPC Inspector for details. Only the full-protobuf gRPC interceptor is a separate artifact.

Next docs