lionscope

v0.13.0
io.github.risyadul/lionscope Checked 12 hours ago Published 14 days ago

Android profiler and Layout Inspector: CPU, memory, frames, stalls, layouts, network, logcat

Lionscope is a lightweight Android profiler and Layout Inspector in your browser, and your AI agent can use it too. No Android Studio needed: run npx lionscope@latest, pick a device and an app. The local performance baseline records dashboard, SDK and emulator mirror measurements, with their test conditions and limits. Results depend on the app, capture settings and device; those measurements are not a general overhead guarantee.

Summary extracted from the README.

Lionscope

Lionscope is a lightweight Android profiler and Layout Inspector in your browser, and your AI agent can use it too. No Android Studio needed: run npx lionscope@latest, pick a device and an app.

  • Profile: CPU, memory, frame rendering, main-thread stalls, layout inflation and logcat for one app, on a single shared time axis. With the SDK, each stall names the line that blocked and where its work came from (an RxJava chain and the line that subscribed it, a coroutine, a posted Runnable, a click).
  • Inspect: freeze the screen, click a view, and see its attributes; with the SDK, also the XML layout and line it came from and the Fragment that owns it, the composables of Compose screens with the Kotlin line that calls them, and live edits of a View's properties (padding, size, colors with a picker, text…) on the running app.
  • Network: with the SDK's OkHttp interceptor, see the app's HTTP requests (headers, bodies, timings) on the same time axis, copy complete requests as cURL, and mock responses or failures. Protocol 14 preserves original captured values, including auth credentials.
  • Storage: browse SharedPreferences and registered Room databases, edit row drafts including primary keys, and run SQL in the Query console or through MCP/CLI tools. Permissions start enabled and can be changed live from the dashboard or CLI.
  • Operate: see and control emulators (which it can also boot headless) and USB devices right next to the charts, and move them to another location on a map.
  • AI agents: the same data as tools over MCP or a CLI (Claude Code, Cursor, VS Code, Codex, …). Select a view in the Inspector and ask your agent about "this element".

The local performance baseline records dashboard, SDK and emulator mirror measurements, with their test conditions and limits. Results depend on the app, capture settings and device; those measurements are not a general overhead guarantee.

It works in two modes:

  • ADB-only (no app changes): everything is collected through adb shell (/proc, dumpsys, logcat).
  • With the optional SDK in the app's debug build: adds which screen is on top (Activity, Fragment, DialogFragment), per-frame FrameMetrics with a stage-by-stage breakdown, grouped per screen, and main-thread stalls with the app code line that caused them and where their work came from (plus opt-in StrictMode violations), layout inflation timing, the Layout Inspector's own view tree with layout sources and owners, the composables of Compose screens, live edits of Views, and (with one line in your OkHttpClient) the app's HTTP traffic and mock responses.

The bundled sample app on a headless emulator, operated from the Device column: screen bands across all charts, SDK FrameMetrics in the Rendering lane, logcat below the timeline, and the Screens tab ranking the screens by jank.

What the dashboard shows

Five workspaces: Profiler (charts on one time axis, logcat, Screens, Stalls, Layouts and Saved State), Layout Inspector, Network, Storage and Device. See What the dashboard shows, and each part in detail:

Requirements

  • Node.js ≥ 22.12
  • Android SDK platform-tools (adb). Lionscope looks for it in LIONSCOPE_ADB, $ANDROID_HOME, $ANDROID_SDK_ROOT, ~/Library/Android/sdk, then PATH.
  • A device or emulator with USB debugging enabled, running Android 6.0 (API 23) or newer for profiling. SDK FrameMetrics and UI-helper tree operations require API 24. See Known limitations.

Quick start

npm install -g lionscope@latest
lionscope
# open http://localhost:8701

lionscope starts the server in the background and returns your terminal. Closing the terminal leaves it running. Use lionscope status, lionscope logs --follow and lionscope stop to manage it. For a server attached to this terminal, run lionscope --foreground. It starts on demand; run it again after a reboot.

For a one-off run without global installation, use npx lionscope@latest.

All four permissions start enabled: agent device control, Network bodies for agents, Storage read and Storage write. Open Permissions in the dashboard to turn any off without restarting. CLI equivalents include lionscope permissions --disable-storage-write and lionscope --disable-device-control; flags also update a running server. Choices are saved locally per server port. See Configuration.

@latest makes npx check for a new release; a bare npx lionscope can keep running a version it cached earlier.

From source instead (the npm package may lag the latest git tag): git clone https://github.com/risyadul/Lionscope.git && cd Lionscope && npm install && npm run lionscope.

Pick the device, pick the app, press Start. Nothing needs to be installed on the device for the ADB-only mode. npx lionscope --help lists the options (--port, --device-port, --adb, --allow-device-control, --allow-network-bodies, --allow-storage-read, --allow-storage-write) and the mcp and query commands for AI agents; the lionscope package is a single bundled file plus the built dashboard, with no runtime dependencies.

Adding the SDK (optional, debug builds only)

The SDK is published on JitPack. It is a public artifact: no credentials or opt-in property are needed.

// settings.gradle (dependencyResolutionManagement) or app/build.gradle repositories
maven { url "https://jitpack.io"; content { includeGroup "com.github.risyadul.Lionscope" } }
// app/build.gradle
debugImplementation "com.github.risyadul.Lionscope:lionscope:0.13.0"

If the project uses dependencyResolutionManagement, the maven block goes in settings.gradle; otherwise in the module's repositories. The content { includeGroup … } filter keeps JitPack from serving anything except Lionscope.

No code changes are needed for automatic profiling: the SDK starts itself through androidx.startup, and only does anything in a debuggable build and in the app's main process. When a session starts, the server runs adb reverse tcp:8700 tcp:<gateway port> for the selected device itself and removes it when the session stops. If an app removes androidx.startup's InitializationProvider, call Lionscope.install(context) from Application.onCreate.

Apps that call the SDK's API (Lionscope.install(), Lionscope.trackNavigation(), Lionscope.okHttpInterceptor(), Lionscope.trackDatabase(), …) also need the lionscope-noop artifact in release builds. That, screen names, Navigation Compose, the Network interceptor and what the SDK costs when no dashboard is connected are in The SDK.

Use with AI agents

AI coding agents (Claude Code, Cursor, VS Code, Codex, …) get the dashboard's data as tools, over MCP (npx -y lionscope mcp) or the shell (npx lionscope query <tool>). Device tools follow the enabled-by-default device-control permission and any client restrictions. Setup for each client, the tools, the agent skill and the safety notes are in Use with AI agents.

Architecture

The server, the dashboard, the SDK and how they connect: Architecture.

Security model

What the server accepts, from where, and what reaches an agent: Security model.

Known limitations

See Known limitations.

Configuration

Flags and environment variables: Configuration.

Development

Building and testing from source: Development.

License

Licensed under the Apache License, Version 2.0. See NOTICE.