scripting-adb-for-ci

Parses instrumentation status codes and orchestrates adb-based Android test runs for CI.

303|10|Updated May 15, 2026
One-click install
npx skills add https://github.com/skydoves/android-testing-skills --skill scripting-adb-for-ci
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: scripting-adb-for-ci
Source: https://github.com/skydoves/android-testing-skills/tree/main/adb/automation/scripting-adb-for-ci
Command: npx skills add https://github.com/skydoves/android-testing-skills --skill scripting-adb-for-ci

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill solves flaky and misleading Android test CI pipelines caused by unreliable adb scripting, incorrect pass/fail detection, and missing cleanup between runs.

Core Features & Use Cases

  • Correct CI pass/fail parsing for am instrument: ensures you do not trust $? from am instrument and instead parse INSTRUMENTATION_STATUS_CODE lines to distinguish -1/-2 failures from -3/-4 skips.
  • Reliable device orchestration: supports sharded execution (--num-shards / --shard-index via -e) and parallel fan-out across multiple devices while keeping setup/installation serialized.
  • Fewer infrastructure incidents: adds bounded retries for transient adb transport errors with adb kill-server/adb start-server, enforces host-side timeouts with timeout (not adb -t), and performs idempotent setup plus trap-based cleanup (port forwards, animation scales, pm clear/force-stop/uninstall).
  • Better failure forensics: captures screencap and logcat -d on failure to make debugging actionable.
  • Test Orchestrator wiring: installs and uses Android Test Orchestrator via androidTestUtil("androidx.test:orchestrator:1.6.1") (not androidTestImplementation) for hermetic per-test execution.

Quick Start

Use the scripting-adb-for-ci skill to run your instrumented tests in CI while safely parsing results and collecting artifacts on failure.

Frequently Asked Questions about scripting-adb-for-ci

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does `am instrument` always exit 0 in CI, and how do I detect test failures?

The `am instrument` command always exits with code 0, so CI scripts must parse `INSTRUMENTATION_STATUS_CODE` lines to distinguish failures (-1/-2) from skips (-3/-4) for correct pass/fail detection.

How do I parallelize Android instrumentation tests across multiple devices using sharding?

Parallelize Android tests by passing `--num-shards` and `--shard-index` via the `-e` flag to `am instrument`, allowing simultaneous fan-out execution across multiple connected devices while keeping setup serialized.

What is the best way to handle transient adb transport errors during automated test runs?

Handle transient adb transport errors by implementing bounded retries that execute `adb kill-server` and `adb start-server`, ensuring reliable device orchestration and fewer infrastructure incidents during CI runs.

How do I enforce host-side timeouts for `am instrument` commands in CI?

Enforce host-side timeouts for `am instrument` by wrapping the command with the Unix `timeout` utility rather than relying on `adb -t`, ensuring hung instrumentation processes are terminated properly.

Do I need Android Test Orchestrator for hermetic per-test execution in CI?

Yes, use Android Test Orchestrator for hermetic per-test execution by installing it via `androidTestUtil` (not `androidTestImplementation`), which isolates test state and crashes across individual test methods.

How do I capture debugging artifacts when an Android instrumentation test fails?

Capture debugging artifacts on failure by scripting `screencap` and `logcat -d` commands within a trap-based cleanup block, ensuring screenshots and logs are collected immediately after a test failure.