argent-android-emulator-setup

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

1. Prerequisites

1. 前提条件

  • Android SDK Platform Tools on PATH — provides
    adb
    .
  • Android Emulator on PATH — needed to boot AVDs. If you will only use an already-running emulator or a physical device, adb alone is sufficient.
  • An AVD created via Android Studio or
    avdmanager create avd
    .
Verify with
adb version
and
emulator -list-avds
.
  • Android SDK Platform Tools已添加至PATH —— 提供
    adb
    工具。
  • Android Emulator已添加至PATH —— 用于启动AVD。如果仅使用已运行的模拟器或物理设备,仅需adb即可。
  • 已通过Android Studio或
    avdmanager create avd
    创建AVD。
通过
adb version
emulator -list-avds
命令验证。

2. Setup

2. 设置步骤

  1. Find a ready device — call
    list-devices
    . Filter for entries with
    platform: "android"
    . Ready devices (
    state: "device"
    ) come first. Pick the first
    serial
    (e.g.
    emulator-5554
    ) unless the user specified one.
  2. Boot if needed — if nothing Android is ready, call
    boot-device
    with
    avdName: <name>
    from the same call's
    avds
    list. The tool transparently picks hot vs cold boot: it probes the AVD's
    default_boot
    snapshot, restores it under a tight deadline when usable, and falls back to a full cold boot otherwise. Hot path is typically ~30s; cold path takes 2–10 min. On any stage failure the tool kills the emulator process it started so your next call starts from a clean state.
  3. Metro (for React Native) — once a device is up, run
    adb -s <serial> reverse tcp:8081 tcp:8081
    so the device can reach Metro on your host. Repeat if the device restarts. See the
    argent-metro-debugger
    skill.
  1. 查找可用设备 —— 调用
    list-devices
    命令。筛选出
    platform: "android"
    的条目。可用设备(
    state: "device"
    )会排在前面。除非用户指定,否则选择第一个
    serial
    (例如
    emulator-5554
    )。
  2. 按需启动模拟器 —— 如果没有可用的Android设备,使用同一调用返回的
    avds
    列表中的
    avdName: <name>
    调用
    boot-device
    命令。该工具会自动选择热启动或冷启动:它会检测AVD的
    default_boot
    快照,若在限定时间内可用则恢复快照,否则回退到完整冷启动。热启动通常约30秒;冷启动需2–10分钟。任何阶段失败时,工具会终止其启动的模拟器进程,确保下次调用从干净状态开始。
  3. Metro(适用于React Native) —— 设备启动后,运行
    adb -s <serial> reverse tcp:8081 tcp:8081
    ,使设备能够访问主机上的Metro。设备重启后需重复此操作。详情请查看
    argent-metro-debugger
    技能。

3. Using the device

3. 使用设备

Pass the Android serial as
udid
to the unified interaction tools —
gesture-tap
,
gesture-swipe
,
describe
,
screenshot
,
launch-app
,
keyboard
, etc. Dispatch is automatic based on the id shape. See
argent-device-interact
for platform-neutral interaction tooling and the Android-specific gotchas section at the bottom of that skill.
将Android序列号作为
udid
传递给统一交互工具——
gesture-tap
gesture-swipe
describe
screenshot
launch-app
keyboard
等。工具会根据ID格式自动分发任务。有关跨平台交互工具及Android特定注意事项,请查看
argent-device-interact
技能底部的相关部分。

4. Notes

4. 注意事项

  • Serials are the adb device id. iOS UDIDs and Android serials are not interchangeable, but you do NOT need to tell the tools which platform — dispatch is automatic.
  • describe
    on Android returns a shallower tree than iOS (no accessibility-service equivalent), but covers most tap-target discovery.
  • reinstall-app
    on Android always installs with
    -g
    so first-launch runtime permissions are pre-granted.
  • To kill the emulator when you're done, run
    adb -s <serial> emu kill
    from a shell.
  • 序列号即adb设备ID。iOS UDID与Android序列号不可互换,但无需告知工具平台类型——工具会自动分发任务。
  • Android上的
    describe
    命令返回的树结构比iOS更浅(无等价的辅助功能服务),但可覆盖大多数点击目标的发现需求。
  • Android上的
    reinstall-app
    命令始终使用
    -g
    参数安装,因此首次启动时会预先授予运行时权限。
  • 使用完毕后,可从shell运行
    adb -s <serial> emu kill
    命令终止模拟器。