crewdroid

v0.2.7
io.github.namyunsu/crewdroid Checked 2 hours ago Published 25 days ago

Light Android emulators for AI agents: text screen outline, per-device network, battery, location.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

devices

Use to find the emulator-<port> serial every other tool needs, or to check what is already running. Returns [{serial, avd, api, profile, screen, cores, ramMB, booted}]; empty = call up.

up

Start of the loop: boot headless emulators (1-3 min). No args = ONE device (s24ultra, newest API <= 36), the right choice for building/checking an app; count > 1 mixes Galaxy profiles and Android versions. How many: 1 to build/check an app; 2-3 to reproduce multi-user bugs (duplicate / lost / overwritten records); one per screen or Android version you must check (or name them with profiles). Each device takes about 1.5 GB of host RAM; a count the available RAM cannot hold fails before booting and says how many fit. Returns {devices:[{serial, api, profile, wmSize}]}; pass serial to every other…

ParameterTypeDescription
allowNoHelperbooleantrue = keep the devices when the on-device helper fails (screen/tap/type then use the slower uiautomator/input)
apiintegerpin the image API, e.g. 31|34|36
basePortinteger
coresintegerguest CPUs, e.g. 1|2|4|6|8 (default 2; <= host CPUs)
countinteger
idleMinutesintegerdevices stop after this many minutes without a crewdroid call, and when this MCP server exits (default 60; 0 = never)
loadstringused-phone load applied after boot (see the load tool)
profilesarrayprofile names from profiles/galaxy.json
ramintegerguest RAM MB, 896..8192 (default 896, API 31 768)
timeoutSecinteger
wifibooleantrue = each device can get its own Wi-Fi address (31 of 33 measured device boots; default: one device at a time; +9.4 % idle RAM)

down

End of the loop: kill every crewdroid (crew-*) emulator. Always call it when finished. Returns {killed: pids, ports}.

net

Set one emulator's network state (airplane|nodata|slow|flaky|online), which link is up (wifi|cellular|both|none), switch the active link while traffic flows (handover), or mark Wi-Fi metered. Returns the transport apps see: {default: wifi|cellular|none, connected, metered}.

ParameterTypeDescription
serial *stringemulator-<port>
state *string
duringintegerhandover: ms with no link between old and new (default 0 = new link up before the old one goes)
meteredbooleanstate=metered: true = Wi-Fi metered
seedinteger
tostringhandover target (default: the other link)

judge

Judge server data (unique / count / noLostUpdate) and/or a proxy request log (dupSuccess / lostUpdate / lostWrite / idle) against a rules file. ok=false lists violations.

ParameterTypeDescription
logstringproxy JSONL log (proxy tool / run with proxy), e.g. with judge/proxy.rules.json
rulesstring
sourcestringserver base URL (GETs /export) or JSON file

hammer

Virtual users hit a server API concurrently, then judge the result.

ParameterTypeDescription
url *string
jitternumber
repeatinteger
retryRatenumber
rulesstring
seedinteger
usersinteger

run

Run a multi-device scenario on any app: up, install, per-device actions (Maestro flow / intent / adb) + network schedule, drain, judge (proxy log by default), down (minutes). Give `file` (scenario JSON, docs/guide-your-app.md) OR, with no file, apk + flows + server (setupFlow, count, repeat, network optional).

ParameterTypeDescription
apkstringno-file form: your APK (package read from it)
basePortinteger
countintegerdefault: the file's devices.count, else 3
filestringscenario JSON, e.g. scenarios/photo-upload.json; omit to use apk/flows/server
flowsarrayno-file form: Maestro flows run in order every iteration
networkbooleanno-file form: false = no network faults (default: all four states)
repeatintegerno-file form: iterations per device (default 5)
seedinteger
serverstringno-file form: backend as the host sees it, http://host:port
serverPortinteger
setupFlowstringno-file form: Maestro flow run once per device first
timeoutSecinteger

apk

Read an APK's manifest on the host (aapt2): package, version, min/target SDK, permissions, exported activities, deep-link filters.

ParameterTypeDescription
file *stringpath to the .apk on the host

app

Control an app on a crewdroid emulator: perm grant|revoke|show [perm…], open <uri> (deep link / App Link), links show|force <domain>|reset (API 31+), clear, backup, restore (LocalTransport), pressure doze|standby <active|working_set|frequent|rare|restricted>|trim <level>|bg-restrict|battery-saver|reset, fill-storage <GB>|free. Setters read the state back and error on mismatch.

ParameterTypeDescription
pkg *stringapplication id, e.g. dev.crewdroid.probe
serial *stringemulator-<port>
what *string
argsarray
onlyThisPackagebooleanopen only: restrict the intent to pkg

install

Use after each build: adb install -r [-g] a host .apk on one emulator or `all` crew devices (replaces the old version, keeps data). Returns ok and per device package + Success or the adb failure code (INSTALL_FAILED_*).

ParameterTypeDescription
apk *stringhost path to the .apk
target *stringemulator-<port> or all
grantboolean-g: grant all runtime permissions

launch

Use to open the app after install, or restart it (restart:true) after a change. am start -W, then checks the process 2 s later. Returns component, totalTime ms and crashed; crashed:true comes with crash {exception, topFrame} (then call logs or triage).

ParameterTypeDescription
pkg *string
serial *stringemulator-<port>
activitystringe.g. .MainActivity; default = launcher activity
extrasarrayam start extras, e.g. ["--es","check","crash"]
restartboolean

logs

Use to see what the app printed or why it failed: one app's logcat lines only (its pid; its last pid when not running). Default: the last 40 lines at level >= I, one text line each `HH:MM:SS.mmm L Tag: message`, equal lines in a row folded `(xN)`, stack traces cut to the top 8 app frames. all:true = today's whole output at level V (max 500 lines); since:"1m" limits to recent lines; format:"json" = {lines:[{time, level, tag, message}]}.

ParameterTypeDescription
pkg *string
serial *stringemulator-<port>
allboolean
formatstring
levelstringdefault I (V with all)
secondsintegerfollow for N s
sincestring60s | 90 | 2m

env

Change or read a crewdroid emulator's environment: geo <lon> <lat> [alt], battery <0-100> [ac|unplugged], rotate <0-3>, sensor acceleration x:y:z, dark on|off, font <scale>, locale <pkg> <tags> (API 33+), gsm data <home|roaming|searching|denied|off|on>, gsm signal <0-31>, sms <from> <text>, call <number> [accept|cancel], show. Every setter reads the state back and errors on mismatch.

ParameterTypeDescription
serial *stringemulator-<port>
what *string
argsarray
holdSecondsintegergsm signal only: keep re-sending for this long

fold

Fold (cover screen) or unfold (main screen) a fold/flip-profile emulator: the app gets a configuration change with the new size. No hinge/posture emulation on ATD.

ParameterTypeDescription
serial *stringemulator-<port>
to *stringcover = folded, main = unfolded

tap

Use to press a button or field: by text/content-desc (text), resource-id (id), a point x,y, or index alone = the [n] line of the last screen outline (no new tree read while that window still has focus). Element match = exact first, then case-insensitive contains. 0 or several matches (text/id without index) fail and list the candidates; retry with index (0-based among the matches) or id. Returns the tapped point and the new screen outline once it settled (screen:false to skip), so no separate screen call is needed.

ParameterTypeDescription
serial *stringemulator-<port>
formatstring
idstringresource-id, full or the part after :id/
indexintegeralone: [n] of the last screen; with text/id: 0-based among the matches
screenbooleanfalse = do not return the new screen
textstring
xinteger
yinteger

type

Use to fill a text field: appends any text (Korean, emoji included) to the focused field through the on-device helper; into = text or resource-id of the field to tap first. Returns the field typed into and the new screen outline (screen:false to skip). Without the helper it falls back to `input text`, where non-ASCII fails with the reason.

ParameterTypeDescription
serial *stringemulator-<port>
text *string
formatstring
intostring
screenbooleanfalse = do not return the new screen

swipe

Use to scroll or page: swipe up|down|left|right (finger direction, middle 50 % of the screen; up scrolls content down) `times` times, or a line x1,y1 -> x2,y2 in ms. Returns the from/to points and the new screen outline (screen:false to skip).

ParameterTypeDescription
serial *stringemulator-<port>
directionstring
formatstring
linearray[x1,y1,x2,y2]
msinteger
screenbooleanfalse = do not return the new screen
timesinteger

key

Use for navigation and hardware keys: back|home|enter|delete|tab|menu or any KEYCODE_*. Returns the focused window and the new screen outline (screen:false to skip).

ParameterTypeDescription
key *string
serial *stringemulator-<port>
formatstring
screenbooleanfalse = do not return the new screen

layout

Use to find broken screens of any installed app across Galaxy screens x font sizes on ONE device (default 5 profiles x fonts 1.0/1.3/2.0 = 15 combos, ~2-4 min). Per combo the app is restarted and the launch activity (or the screen a Maestro flow reaches) is judged from the accessibility tree: wrap (button label on 2+ lines, word broken), clip (ellipsized/cut text), offscreen (no scroll can reach it), overlap (> 20 %), target (< 48 dp). Returns {ok, combos:[{profile, font, ok, findings:[{kind, text|id, bounds, detail}], png?}], summary}; png = screenshot with the finding boxes drawn. The device…

ParameterTypeDescription
pkg *stringinstalled package
serial *stringemulator-<port>
activitystringe.g. .MainActivity; default = launcher activity
extrasarrayam start extras, e.g. ["--es","check","layout-bad"]
flowstringMaestro flow (host path) run after each start; the screen it ends on is judged
fontsarrayfont scales, default [1.0,1.3,2.0]
outstringdirectory for the PNGs (default ./crewdroid-layout-<pkg>-<time>)
profilesarrayprofile names, default s24ultra,fold5-cover,fold5-main,flip6-cover,trifold-main
timeoutSecinteger

load

Make one emulator behave like a used phone: off|low|mid|high = installed filler apps (30/80/150), background processes (5/15/30), memory ballast down to 50/30/15 % of the off-level free RAM, CPU workers at 10/25/50 % per core, alarm/job wakeups. off removes it all (keepApps keeps the fillers installed). Returns the measured guest state (MemAvailable %, load average, CPU busy %, processes, packages).

ParameterTypeDescription
level *string
serial *stringemulator-<port>
keepAppsbooleanoff only: keep the filler packages installed
timeoutSecinteger

perf

Cold start time (force-stop, 2 s, am start -W), frames/jank %/p50-p99 (gfxinfo) and PSS java/native (meminfo) of one app. ATD has no GPU: compare frame numbers relatively.

ParameterTypeDescription
pkg *string
serial *stringemulator-<port>
activitystringe.g. .MainActivity; default = launcher activity
extrasarrayam start extras, e.g. ["--es","check","jank"]

proxy

Recording HTTP proxy between the emulators and your server (no app or server change): action start points every device's system proxy at it (10.0.2.2:<port+k>), stop clears it, log returns the request log. Judge the log with the judge tool's `log` input (dupSuccess / lostUpdate / lostWrite / idle).

ParameterTypeDescription
action *string
devicesarraydefault: every running crew emulator
logstringJSONL path
loseAcksnumberfault injection: share of writes whose answer is dropped after the server committed them
portinteger
targetstringstart: server base URL as seen from the host, e.g. http://127.0.0.1:5599

screen

Use to READ the screen before tap/type (tree, not pixels). Default: a short outline, first line = focused window and size, then one line per visible element `[n] role "text" #id @x,y flags` (role btn/edit/text/img/list/check; a card's texts sit on its one line; `… N more below (swipe up)` = off-screen). tap {index:n} alone taps [n] of this outline. format:"json" = full tree {focus, nodes[{cls,text,desc,id,bounds,clickable,depth,...}], via}. While a Maestro flow runs the tree is empty and a line says why. For how it looks, use shot. On API 31 a black screen after a relaunch (emulator bug, ADR…

ParameterTypeDescription
serial *stringemulator-<port>
boundsbooleanadd [l,t,r,b] to each line
formatstring
pngstringhost path for a screenshot

setup

Use first on a new machine, or when up fails for a missing SDK/image: checks/installs the Android SDK pieces crewdroid needs (JDK 17 for sdkmanager, command-line tools, platform-tools, emulator, google_atd images). Dry run by default: returns steps [{step, status: present|missing, downloadBytes}]; yes:true installs and accepts the SDK licences.

ParameterTypeDescription
imagesarrayAndroid API levels of google_atd images, default ["34"]
onlyarraylimit to these steps
sdkstringSDK directory (default ANDROID_SDK_ROOT / ANDROID_HOME, else ~/.crewdroid/android-sdk)
yesbooleaninstall for real and accept the SDK licences

shot

Use to SEE the screen (pixels: layout, colours, clipping). Returns an image item (PNG, also saved to file or ./crewdroid-<serial>-<time>.png) and a text line with path and size. To find a button or text to tap, use screen instead. On API 31 a fully black screen after an app relaunch (emulator bug, ADR 0005) is recovered first.

ParameterTypeDescription
serial *stringemulator-<port>
filestringhost path for the PNG

triage

Why did the app die? Crashes (logcat crash buffer), ANRs (ActivityManager log, exit-info, /data/anr traces), exit reasons, the app's last 200 log lines, optional heap dump.

ParameterTypeDescription
serial *stringemulator-<port>
appstringpackage name, e.g. dev.crewdroid.probe
heapstringhost path for an .hprof (needs app running)