Agent skill

Android Debugging

by rcosteira79 in rcosteira79/android-skills

Android and KMP debugging techniques for crashes, ANRs, memory leaks, R8 traces, Gradle failures and Compose recomposition, built on finding the root cause first.

MITAuto-check passedMobile

Install Android Debugging

skills CLI
$ npx skills add rcosteira79/android-skills --skill android-debugging -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install rcosteira79/android-skills android-debugging --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/rcosteira79/android-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/android-skills/skills/android-debugging .claude/skills/android-debugging && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
android-debugging
GitHub stars
150
Token cost
~2.6k tokens
SKILL.md length
1,001 words
Files
1
Skills in repo
21
Repo updated
First seen
Licence
MIT

At a glance

Android and KMP debugging techniques for crashes, ANRs, memory leaks, R8 traces, Gradle failures and Compose recomposition, built on finding the root cause first.

  • Works in 4 steps: Layout Inspector (Android Studio) →… → Add SideEffect { Log.d("Recompose",… → Check that State objects are not created… → …
  • Investigating an Android crash from a Logcat stack trace
  • SKILL.md covers Overview, Evidence-Gathering by Problem…, Multi-Component Evidence… and Red Flags
  • Calls adb and java

What it does

This skill gives the agent Android-specific ways to gather evidence while following a root-cause-first rule: no fix until the cause is found, observed values instead of assumed ones, and after three failed guesses a step back to question the architecture. It can sit on top of a general debugging-discipline skill but does not need one.

Techniques are grouped by problem type. For crashes it streams Logcat filtered to the app process and reads the full stack trace down to the bottom of the `Caused by:` chain. For ANRs it pulls trace files over ADB and looks for a blocked main thread. For memory leaks it adds LeakCanary and can dump a heap for Android Profiler. For wider bottlenecks it captures a Perfetto trace and queries it with SQL. The description also covers R8 stack trace decoding, Gradle build failures and Compose recomposition.

When your agent uses it

  • Investigating an Android crash from a Logcat stack trace
  • Diagnosing an ANR where the main thread is blocked
  • Tracking down a memory leak with LeakCanary or a heap dump
  • Decoding an obfuscated R8 stack trace from a release build
  • Fixing a failing Gradle build or unexpected Compose recomposition

Example prompts

  • “My app crashes on launch. Pull the Logcat output with adb and find the root cause.”
  • “Users report ANRs after the login screen. Here is traces.txt; what is blocking the main thread?”
  • “Find out why the profile screen leaks an Activity and tell me how to fix it.”

Requirements

  • ADB with a connected device or emulator
  • An Android or KMP project

Workflow steps

4 steps, taken from the first numbered list in SKILL.md.

  1. Layout Inspector (Android Studio) → enable "Show recomposition counts" to identify hot paths. For headless/CLI workflows, android layout…
  2. Add SideEffect { Log.d("Recompose", "MyComposable recomposed") } temporarily to confirm
  3. Check that State objects are not created inside the composition (use remember)
  4. Verify equals() on state data classes — a new object with same values still triggers recomposition if equals is not implemented

What it can do on your machine

Read from SKILL.md and the folder at commit 0f9af5a. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • adb
    • java

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • github.com
    • square.github.io
    • ui.perfetto.dev

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Android Debugging loads about 2.6k tokens when it runs. Until then it costs about 63 tokens; SKILL.md has 1,001 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~63
When it runs · the whole SKILL.md, loaded when a task matches
~2.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from rcosteira79/android-skills at commit 0f9af5a, republished under its MIT licence (© rcosteira79). 1,001 words, ~2,578 tokens.

Download SKILL.mdSave it as .claude/skills/android-debugging/SKILL.md (or your agent's skills folder).
name
android-debugging
description
Use when debugging Android or KMP issues — Android-specific techniques covering Logcat, ADB, ANR traces, R8 stack trace decoding, memory leaks, Gradle build failures, and Compose recomposition bugs, on a root-cause-first foundation.

Android Debugging

Overview

Android-specific evidence-gathering and investigation techniques on a root-cause-first foundation.

Root-cause-first foundation:

  • No fix before the root cause is found. Investigate first — reproduce, gather evidence (observed values, not assumed), trace the cause. Patching a symptom you don't understand creates two bugs.
  • Three failed guesses ⇒ stop and question the architecture rather than guessing again.

The Android-specific tools below serve that investigation. Optional: if you run a dedicated debugging-discipline skill (e.g. superpowers:systematic-debugging or ace:systematic-debugging), this layers on top of it — but it requires none.

Evidence-Gathering by Problem Type

Crashes & Exceptions
bash
# Stream crash logs filtered by app package
adb logcat --pid=$(adb shell pidof -s com.example.app)

# Save full logcat to file for analysis
adb logcat -d > crash_log.txt

# Filter by tag
adb logcat -s "YourTag:E"

Key logcat log levels: V (verbose) D (debug) I (info) W (warn) E (error) F (fatal)

Read the full stack trace — the root cause is usually at the bottom of the Caused by: chain, not the top-level exception.

ANR (Application Not Responding)

ANRs mean the main thread was blocked. Evidence:

bash
# Pull ANR trace from device
adb pull /data/anr/traces.txt ./anr_traces.txt

# Or stream while reproducing
adb logcat -s "ActivityManager:E" | grep -A 30 "ANR in"

Look for: main thread in state MONITOR (waiting for a lock) or blocking I/O on main. Trace backward to find what holds the lock.

Common causes: Database/network call on main thread, runBlocking on main thread, deadlock between coroutine scopes.

Memory Leaks

Add LeakCanary to debugImplementation. It surfaces leak traces automatically in a notification.

Read the leak trace top-to-bottom: the first bold line is the leaking object, the path shows what's holding the reference. Fix by clearing the reference in the appropriate lifecycle callback.

bash
# Dump heap manually for Android Profiler analysis
adb shell am dumpheap com.example.app /data/local/tmp/heap.hprof
adb pull /data/local/tmp/heap.hprof ./heap.hprof
Performance Trace Investigation (Perfetto)

For bottleneck investigation across CPU, graphics, I/O, IPC, memory, or power — beyond what Logcat and ANR traces show — capture a Perfetto trace and query it with SQL.

Measure before you fix. For performance regressions, logs usually mislead — capture a baseline measurement before changing anything, then bisect against it. A trace tells you where time goes; only a comparison against a known-good baseline tells you what actually regressed.

bash
# Capture a trace (system-level, all categories)
adb shell perfetto -c - --txt -o /data/misc/perfetto-traces/trace.pftrace \
  <<'EOF'
buffers { size_kb: 65536 }
data_sources { config { name: "linux.ftrace" } }
data_sources { config { name: "android.surfaceflinger.frame" } }
duration_ms: 10000
EOF

adb pull /data/misc/perfetto-traces/trace.pftrace ./

Then open the trace at https://ui.perfetto.dev and run SQL against it (SELECT name, dur FROM slice WHERE dur > 16e6 for frames slower than 16ms, etc.).

For an agent-driven workflow — translating an investigation intent (jank, slow startup, battery drain) into the right Perfetto SQL and iterating across the trace — see Google's perfetto-sql and perfetto-trace-analysis skills (android skills list to check for a local install; android skills add perfetto-sql perfetto-trace-analysis otherwise). They provide Domain Hints (CPU/Graphics/I/O/IPC/Memory/Power), a mandatory scratchpad chain-of-evidence pattern, and GLOB-over-LIKE query rules.

R8 / ProGuard — Obfuscated Stack Traces

Release crash stack traces are obfuscated. Decode them with the mapping file generated at build time.

bash
# retrace a crash (AGP 7+)
./gradlew :app:retrace --stacktrace-file crash.txt

# Or use the retrace CLI directly
java -jar retrace.jar mapping.txt crash.txt

Mapping files are in app/build/outputs/mapping/<variant>/mapping.txt. Always archive them alongside release builds.

If a class is unexpectedly removed or renamed, add a -keep rule in proguard-rules.pro and verify with:

bash
./gradlew :app:assembleRelease
# Then inspect: app/build/outputs/mapping/release/usage.txt (removed) and seeds.txt (kept)

For the inverse problem — reading obfuscated third-party code or decoding a stack trace from a library where the mapping file isn't yours — retrace doesn't apply. Use jadx --deobf (consistent renames across the decompiled output) or jadx --deobf-map (when the SDK ships a mapping). The android-reverse-engineering plugin covers the full workflow including the anchor-via-strings strategy for navigating obfuscated code by string literals and framework class names that survive obfuscation (check if it's already installed locally first — it ships as android-reverse-engineering:* skills).

Gradle Build Failures

Read the error from the bottom up — Gradle wraps errors in multiple layers.

Common patterns:

ErrorInvestigation
Manifest merger failedCheck app/build/intermediates/merged_manifests/ for the merged output; look for conflicting android: attributes
Duplicate classRun ./gradlew dependencies and look for the same class in multiple transitive deps; use exclude or force a version
Could not resolveCheck repository declarations, VPN/proxy, dependency version exists
D8/R8: Type not presentMissing keep rule or desugaring issue; check minSdk vs API used
KSP / KAPT errorLook for the processor's own error above the Gradle wrapper message
bash
# Full dependency tree for a configuration
./gradlew :app:dependencies --configuration releaseRuntimeClasspath

# Run with stacktrace for deeper Gradle errors
./gradlew assembleDebug --stacktrace --info 2>&1 | grep -A 20 "FAILED"
Show full SKILL.md (401 more words)Show less
Runtime UI Inspection

When a bug is visual (wrong element state, missing content, overlap), dump the layout tree directly instead of reasoning from a screenshot:

bash
# Full layout tree as JSON — search by class/text/bounds instead of parsing an image
android layout --pretty

# Only elements that changed since last call — useful for animations or transient state
android layout --diff --pretty

# Target a specific device, write to file
android layout --device=emulator-5554 -o layout.json

Prefer android layout over adb screencap whenever the question is "what is the UI state?" rather than "what does it look like?". The JSON tree is grep-able and survives --diff state across invocations.

Compose Recomposition Bugs

For deeper Compose performance analysis (stability, recomposition skipping, baseline profiles), see android-skills:compose → compose/references/performance.md.

Wrong state or unexpected re-renders:

  1. Layout Inspector (Android Studio) → enable "Show recomposition counts" to identify hot paths. For headless/CLI workflows, android layout --diff gives a JSON tree of what changed between frames.
  2. Add SideEffect { Log.d("Recompose", "MyComposable recomposed") } temporarily to confirm
  3. Check that State objects are not created inside the composition (use remember)
  4. Verify equals() on state data classes — a new object with same values still triggers recomposition if equals is not implemented

Note: Since Compose compiler 2.0+ (Kotlin 2.0+), strong skipping mode is enabled by default and the compiler automatically memoizes lambdas that capture stable references. Manual remember {{ }} wrapping is no longer necessary in most cases. If you see excessive recomposition from lambdas, check whether the captured references are unstable (mutable collections, non-data classes) rather than wrapping in remember.

(Standard adb commands — devices, install -r, am start, pm clear, ps, run-as … ls /data/data/<pkg>/ — aren't covered here; for visual-state bugs prefer android layout over screencap as noted above.)

Multi-Component Evidence Template

For issues spanning multiple layers (e.g. Repository → ViewModel → UI):

kotlin
// Temporarily instrument each boundary with a UNIQUE run-specific tag
// (pick a fresh suffix per session, e.g. DEBUG-a4f2) so the SAME tag both
// filters logcat at runtime and greps cleanly at teardown.
class UserRepository(...) {
    suspend fun fetchUser(id: String): User {
        Log.d("DEBUG-a4f2", "Repository: fetching user $id")
        val result = api.getUser(id)
        Log.d("DEBUG-a4f2", "Repository: received ${result}")
        return result
    }
}

Run once to identify which layer produces the bad value. Filter the run at runtime with adb logcat -s "DEBUG-a4f2", then tear the instrumentation back out with a single grep -rl "DEBUG-a4f2". A unique per-session tag is what makes both one-liners work — a shared tag like DEBUG_LAYER collides across sessions and leaves orphaned logs behind. Then investigate the implicated layer in isolation before proposing a fix.

Red Flags

  • Fixing a crash without reading the full Caused by: chain
  • Guessing at an R8 issue without checking the mapping file
  • Adding Thread.sleep() to "fix" an ANR or race condition
  • Resolving a dependency conflict by adding exclude without understanding why the duplicate exists
  • Fixing a Compose bug by wrapping in key() without understanding what triggers recomposition
  • Leaving temporary instrumentation in the tree — tag every debug log with a unique per-session prefix (e.g. DEBUG-a4f2) so cleanup is one grep, and remove them all before declaring the fix done

© rcosteira79, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in plugins/android-skills/skills/android-debugging of rcosteira79/android-skills.

Open the folder on GitHubat commit 0f9af5a

Compare with similar skills

Android Debugging next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Android Debugging compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Android Debugging this skillrcosteira79/android-skills150—~2.6kAutomated safety check: PassMIT
Slay the Amethyst Feedback DiagnosisModinMobileSTS/SlayTheAmethystModded400—~2.6kAutomated safety check: PassCustom licence
Run Jetpack Android Appwordpress-mobile/WordPress-Android3.2k—~886Automated safety check: PassGPL-2.0
Orca Android Emulator Controlstablyai/orca87k—~558Automated safety check: PassApache-2.0
Android CLI (acli)ErikHellman/cli-for-android119—~709Automated safety check: PassMIT
Inspect Network TrafficHedvigInsurance/android154—~756Automated safety check: PassAGPL-3.0

Similar skills

  • Slay the Amethyst Feedback Diagnosis

    ModinMobileSTS/SlayTheAmethystModded

    Reads Slay the Amethyst diagnostics bundles to decide whether a problem comes from the launcher, a mod or the device, citing exact files and lines.

    400 GitHub stars~2.6k tokensUpdated 7 days ago
    MobileAuto-check passed
  • Run Jetpack Android App

    wordpress-mobile/WordPress-Android

    Builds the Jetpack debug app with Gradle and installs it on a connected Android device or an emulator started from an available AVD.

    3.2k GitHub stars~886 tokensUpdated today
    MobileAuto-check passed
  • Android device and emulator control from inside Orca over adb, with the live device view in Orca's emulator pane. Use when driving an adb-connected emulator…

    87k GitHub stars~558 tokensUpdated today
    MobileAuto-check passed
  • Android CLI (acli)

    ErikHellman/cli-for-android

    Drives Android devices, emulators, SDK packages and Gradle builds through the acli command, with JSON output and per-device targeting.

    119 GitHub stars~709 tokensUpdated 6 mo ago
    MobileAuto-check passed
  • Inspect Network Traffic

    HedvigInsurance/android

    Read the HTTP and GraphQL calls a debug build of the Android app made, with request and response bodies, status codes, timings and errors, over adb.

    154 GitHub stars~756 tokensUpdated today
    MobileAuto-check passed
  • Warpdroid UI Test

    Warp-net/warpnet

    A skill your agent uses whenever a warpdroid (Android client) change or bug needs to be verified by actually driving the app's visual UI — any task phrased as "test the warpdroid UI", "click through…

    157 GitHub stars~3.5k tokensUpdated today
    MobileAuto-check passed

More from rcosteira79/android-skills

All 21 skills in this repo
  • Guides writing correct, performant Compose and Compose Multiplatform UI across Android, desktop, iOS and web, from state and animation to design-to-code and crash fixes.

    150 GitHub stars~2.6k tokensUpdated 18 days ago
    Auto-check passed
  • Kotlin Multiplatform Boundaries

    rcosteira79/android-skills

    Helps choose how common Kotlin Multiplatform code reaches platform APIs: expect/actual, a common interface with platform bindings, or separate platform screens.

    150 GitHub stars~1.5k tokensUpdated 18 days ago
    Auto-check passed
  • Android Data Layer and Room in KMP

    rcosteira79/android-skills

    Sets out the repository pattern's error-propagation model for Android and Kotlin Multiplatform, plus the Room setup for commonMain.

    150 GitHub stars~1.2k tokensUpdated 18 days ago
    Auto-check passed
  • Android and KMP Baseline

    rcosteira79/android-skills

    Sets house defaults for Android and Kotlin Multiplatform work and routes to the right specialized skill for Compose, networking, testing or build tooling.

    150 GitHub stars~3k tokensUpdated 18 days ago
    Auto-check passed
  • Android Gradle Build Logic

    rcosteira79/android-skills

    Sets up Android Gradle convention plugins in a build-logic composite build, including the version catalog wiring and shared configuration that are easy to get wrong.

    150 GitHub stars~959 tokensUpdated 18 days ago
    Auto-check passed
  • Android Retrofit

    rcosteira79/android-skills

    A skill your agent uses when setting up or working with Retrofit in Android — service interface definitions, coroutines integration, OkHttp configuration, Hilt module setup, and error handling in…

    150 GitHub stars~942 tokensUpdated 18 days ago
    Auto-check passed

Works with

Questions about Android Debugging

What does Android Debugging do?

Android and KMP debugging techniques for crashes, ANRs, memory leaks, R8 traces, Gradle failures and Compose recomposition, built on finding the root cause first. This skill gives the agent Android-specific ways to gather evidence while following a root-cause-first rule: no fix until the cause is found, observed values instead of assumed ones, and after three failed guesses a step back to question the architecture. It can sit on top of a general debugging-discipline skill but does not need one.

When should I use Android Debugging?

Android Debugging fits situations like: investigating an Android crash from a Logcat stack trace; diagnosing an ANR where the main thread is blocked; tracking down a memory leak with LeakCanary or a heap dump; decoding an obfuscated R8 stack trace from a release build.

How do I install Android Debugging in Claude Code?

Run `npx skills add rcosteira79/android-skills --skill android-debugging -a claude-code`. Or copy the skill folder (plugins/android-skills/skills/android-debugging in rcosteira79/android-skills) into .claude/skills/android-debugging in your project. Claude Code loads it when a task matches its description.

How do I install Android Debugging in Codex?

Run `npx skills add rcosteira79/android-skills --skill android-debugging -a codex`. Or copy the skill folder (plugins/android-skills/skills/android-debugging in rcosteira79/android-skills) into .agents/skills/android-debugging in your project. Codex loads it when a task matches its description.

Can I use Android Debugging in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add rcosteira79/android-skills --skill android-debugging -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/android-debugging, .gemini/skills/android-debugging, .github/skills/android-debugging and .opencode/skills/android-debugging in your project.

What does Android Debugging need to run?

Going by SKILL.md and its folder, Android Debugging needs the command-line tools its instructions call (adb and java). Our summary lists: ADB with a connected device or emulator; An Android or KMP project.

Does Android Debugging access the network?

SKILL.md names 3 domains. As links in the text: github.com, square.github.io and ui.perfetto.dev. This is read from the text; nothing was executed.

Is Android Debugging safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Android Debugging use?

Android Debugging is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Android Debugging use?

About 2.6k tokens (SKILL.md is roughly 10k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Android Debugging?

Skills that share tags, products or a category with Android Debugging: Slay the Amethyst Feedback Diagnosis (ModinMobileSTS/SlayTheAmethystModded, 400 stars), Run Jetpack Android App (wordpress-mobile/WordPress-Android, 3.2k stars), Orca Android Emulator Control (stablyai/orca, 87k stars) and Android CLI (acli) (ErikHellman/cli-for-android, 119 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Android Debugging?

rcosteira79 (a GitHub user) maintains it in rcosteira79/android-skills, which has 150 GitHub stars. The repository holds 21 skills in this directory. The repository was last updated on September 19, 2026.

Source: rcosteira79/android-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.