Skip to content

Lustro

Lustro Lustro

Lustro is a debugging library for the debug builds of an Android app. It runs a small web server in the app's process and shows the app's data as tabs in a desktop browser. Every tab is also a JSON API, so AI agents, scripts, and the lustro command-line tool can use the same data without a browser.

Pre-1.0

Lustro is pre-1.0. Until 1.0.0, a minor version, such as 0.2.0, can change the Kotlin API and the HTTP API in ways that are not compatible. The CHANGELOG lists each change.

The Network tab in a desktop browser: the sample app's requests, and the JSON response of one of them

What you get

Tab What it shows and does
Network Captures OkHttp traffic, the messages of WebSockets, and, when you opt in, HttpURLConnection traffic. Mocks responses, throttles requests, sends requests through the app's own clients, and exports HAR files.
Logs The app's own logcat, with filters for level, tag, text, and time.
Preferences Reads and edits the app's SharedPreferences and Preferences DataStores.
SQLite Reads the app's SQLite and Room databases, and runs SQL. Writes only to the databases that the app allows.
WorkManager The app's work, the events of each run, and Cancel and Prune.
Screen For agents and scripts, through the API only: every window of the app and the UI tree in each, the classic Views and the Compose semantics nodes, read in the app's process in milliseconds.
Your own tabs A DebugTab subclass with JSON routes and, if you want, a view in the browser.

The Network tab is built in: it is in the main artifact, lustro. Logs, Preferences, SQLite, WorkManager, and Screen are plugins, each with an artifact of its own.

A release build gets no server. Each artifact has a no-op half with the same API and empty method bodies: you add the runtime with debugImplementation and the no-op half with releaseImplementation, and the same code compiles for both build types.

Quick start

  1. Add the runtime for debug builds and the no-op half for release builds, in the app module's build.gradle.kts. The artifacts are on Maven Central:

    dependencies {
        debugImplementation("io.github.twinsen81:lustro:0.1.0")
        releaseImplementation("io.github.twinsen81:lustro-noop:0.1.0")
    }
    
  2. Build Lustro once, in Application.onCreate(), add its interceptor to your OkHttp client, and start it on the main thread:

    val lustro = Lustro.builder(application)
        .addTab(NetworkDebugTab.create())
        .build()
    
    val httpClient = OkHttpClient.Builder()
        .addInterceptor(lustro.networkInterceptor())
        .build()
    
    lustro.start()
    
  3. Run the debug build, keep the app in the foreground, and open the console. Forward the port and read the token:

    adb forward tcp:8080 tcp:8080
    adb logcat -d -s LustroToken      # Lustro ready endpoint=... token=<token>
    

    Then open http://localhost:8080/#lustro_token=<token> in a desktop browser. The lustro CLI does these steps with one command, lustro open.

Lustro needs minSdk 24, compileSdk 35, Android Gradle Plugin 8.6, and Kotlin 2.0. It does not raise the versions of your app's own dependencies: see Minimum versions.

Next steps