android-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Android CLI Specialist

Android CLI 专家

This skill provides instructions for using the
android
CLI tool. The tool includes various commands for creating projects, running applications, interacting with devices, and managing the CLI environment.
本技能提供
android
CLI工具的使用说明。该工具包含多种命令,可用于创建项目、运行应用、与设备交互以及管理CLI环境。

SDK management

SDK 管理

To manage the installation of Android SDKs and tools, use the
sdk
command. For example:
  • android sdk install <package>[@<version>]...
    : Install specific packages. Multiple packages can be specified, separated by spaces.
    <version>
    defaults to latest. For example:
    android sdk install platforms/android-30@2 platforms/android-34
  • android sdk update [<pkg-name>]
    : Update a specific package or all packages to the latest version.
  • android sdk remove <pkg-name>
    : Remove a package from the local SDK.
  • android sdk list --all
    : List installed and available SDK packages.
要管理Android SDK及工具的安装,请使用
sdk
命令。例如:
  • android sdk install <package>[@<version>]...
    : 安装指定包。可指定多个包,以空格分隔。
    <version>
    默认是最新版本。示例:
    android sdk install platforms/android-30@2 platforms/android-34
  • android sdk update [<pkg-name>]
    : 将指定包或所有包更新至最新版本。
  • android sdk remove <pkg-name>
    : 从本地SDK中移除某个包。
  • android sdk list --all
    : 列出已安装和可用的SDK包。

Project creation

项目创建

Create projects from templates using the
create
command.
For example:
android create empty-activity --name="My App" --output=./my-app
使用
create
命令从模板创建项目。
示例:
android create empty-activity --name="My App" --output=./my-app

Interacting with devices

与设备交互

For more information on interacting with running devices, see here
有关与运行中设备交互的更多信息,请查看此处

Running journey tests

运行流程测试

For more information on running journeys, see here
有关运行流程的更多信息,请查看此处

Doc searching

文档搜索

The
docs
command searches authoritative, high-quality Android developer documentation in the Android Knowledge Base. By providing a few keywords, this tool will return high quality articles that contain examples or guidance on how to use Android APIs or libraries. Use this tool to obtain additional information on how to achieve Android-specific tasks or to know more about Android APIs, surfaces, libraries, or devices.
Always use this tool to get the most up-to-date information about Android concepts. Typical good use cases are:
  • Finding migration guides for APIs.
  • Finding examples for APIs.
  • Finding up-to-date information about Android APIs.
  • Finding best practices for Android concepts.
docs
命令可在Android知识库中搜索权威、高质量的Android开发者文档。 只需提供几个关键词,该工具就会返回包含Android API或库使用示例及指南的优质文章。 使用此工具获取完成Android特定任务的额外信息,或了解更多Android API、界面、库或设备相关内容。
请始终使用此工具获取Android概念的最新信息。典型适用场景包括:
  • 查找API迁移指南。
  • 查找API使用示例。
  • 查找Android API的最新信息。
  • 查找Android概念的最佳实践。

Running APKs

运行APK

Use the
run
command to run Android apps.
使用
run
命令运行Android应用。

Managing emulators

模拟器管理

Manage Android Virtual Devices (AVDs) using the
android emulator
command
使用
android emulator
命令管理Android虚拟设备(AVDs)

Capturing screenshots

截图捕获

Capture an image of the current screen of a connected Android device and output it to a file using the
android screenshot
command.
使用
android screenshot
命令捕获已连接Android设备的当前屏幕图像并输出到文件。

Managing skills

技能管理

Manage antigravity agent skills for Android using the
android skills
command.
使用
android skills
命令管理Android的antigravity agent技能。

Inspecting UI Layouts

UI布局检查

Use the
android layout
command to inspect the UI layout of an Android application. It returns the layout tree of an Android application in JSON format. When debugging UI errors, this is often a much faster approach than taking a screenshot.
使用
android layout
命令检查Android应用的UI布局。它会以JSON格式返回Android应用的布局树。调试UI错误时,这通常比截图快得多。

Updating the CLI

更新CLI

Update the Android CLI using the
android update
command.
使用
android update
命令更新Android CLI。

android help
output

android help
输出

Usage: android [-hV] [--sdk=PARAM] [COMMAND] -h, --help Show this help message and exit. --sdk=PARAM Path to the Android SDK -V, --version Print version information and exit. Commands: create Create a new Android project describe Analyzes an Android project to generate descriptive metadata. docs Android documentation commands emulator Emulator commands help Shows the help of all commands info Print environment information (SDK Location, etc.) init Initializes the environment (eg. skills) for Android CLI. layout Returns the layout tree of an application run Deploy an Android Application screen Commands to view the device sdk Download and list SDK packages skills Manage skills update Update the Android CLI
create Usage: android create [-h] [--verbose] [--list] [--minSdk=api] --name=applicationName [-o=dest-path] [template-name] Create a new Android project [template-name] The template name -h, --help Show this help message and exit. --minSdk=api The 'minSdk' supported by the application (default is defined in the template) --name=applicationName The name of the application (e.g. 'My Application') -o, --output=dest-path The destination project directory path (default is '.') --verbose Enables verbose output --list List all available templates
describe Usage: android describe [-hV] [--project_dir=PARAM] Analyzes an Android project to generate descriptive metadata. This command identifies and outputs the paths to JSON files that detail the project's structure, including build targets and their corresponding output artifact locations (e.g., APKs). This information enables other tools and commands to locate build artifacts efficiently. -h, --help Show this help message and exit. --project_dir=PARAM The project directory to describe -V, --version Print version information and exit.
docs Usage: android docs [-h] [COMMAND] Android documentation commands -h, --help Show this help message and exit. Commands: search Search Android documentation fetch Fetch Android documentation
emulator Usage: android emulator [-h] [COMMAND] Emulator commands -h, --help Show this help message and exit. Commands: create Creates a virtual device start Launches the specified virtual device. This command will return when the emulator is fully started and ready to use. stop Stops the specified virtual device list Lists available virtual devices remove Delete a virtual device
help Usage: android help [COMMAND] Shows the help of all commands [COMMAND] The command to show help for
info Usage: android info <field> Print environment information (SDK Location, etc.) <field> The specific field to print the value of. If omitted print all.
init Usage: android init Initializes the environment (eg. skills) for Android CLI.
layout Usage: android layout [-dhp] [--device=PARAM] [-o=PARAM] Returns the layout tree of an application -d, --diff Returns a flat list of the layout elements that have changed since the last invocation of ui-dump --device=PARAM The device serial number -h, --help Show this help message and exit. -o, --output=PARAM Writes the layout tree to the specified file or directory. If omitted, prints the tree to standard output -p, --pretty Pretty-prints the returned JSON
run Usage: android run [-h] [--debug] [--activity=PARAM] [--device=PARAM] [--type=PARAM] [--apks=PARAM[,PARAM...]]... Deploy an Android Application --activity=PARAM The activity name --apks=PARAM[,PARAM...] The paths to the APKs --debug Run in debug mode --device=PARAM The device serial number -h, --help Show this help message and exit. --type=PARAM The component type (ACTIVITY, SERVICE, etc.)
screen Usage: android screen [-h] [COMMAND] Commands to view the device -h, --help Show this help message and exit. Commands: capture Outputs the device screen to a PNG resolve Target UI elements visually
sdk Usage: android sdk [COMMAND] Download and list SDK packages Commands: install Install SDK packages update Update one or all packages to the latest version remove Remove a package from the SDK list List installed and available SDK packages
skills Usage: android skills [COMMAND] Manage skills Commands: add Install a skill remove Remove a skill list List available skills find Find skills by keyword
update Usage: android update [--url=PARAM] Update the Android CLI --url=PARAM The URL to download the update from
用法: android [-hV] [--sdk=PARAM] [COMMAND] -h, --help 显示此帮助信息并退出。 --sdk=PARAM Android SDK路径 -V, --version 打印版本信息并退出。 命令: create 创建新的Android项目 describe 分析Android项目以生成描述性元数据。 docs Android文档命令 emulator 模拟器命令 help 显示所有命令的帮助信息 info 打印环境信息(SDK位置等) init 初始化Android CLI的环境(如技能)。 layout 返回应用的布局树 run 部署Android应用 screen 设备查看命令 sdk 下载并列出SDK包 skills 管理技能 update 更新Android CLI
create 用法: android create [-h] [--verbose] [--list] [--minSdk=api] --name=applicationName [-o=dest-path] [template-name] 创建新的Android项目 [template-name] 模板名称 -h, --help 显示此帮助信息并退出。 --minSdk=api 应用支持的'minSdk'(默认值由模板定义) --name=applicationName 应用名称(例如'My Application') -o, --output=dest-path 项目目标目录路径(默认是'.') --verbose 启用详细输出 --list 列出所有可用模板
describe 用法: android describe [-hV] [--project_dir=PARAM] 分析Android项目以生成描述性元数据。 此命令识别并输出详细说明项目结构的JSON文件路径,包括构建目标及其对应的输出产物位置(如APK)。该信息可帮助其他工具和命令高效定位构建产物。 -h, --help 显示此帮助信息并退出。 --project_dir=PARAM 要描述的项目目录 -V, --version 打印版本信息并退出。
docs 用法: android docs [-h] [COMMAND] Android文档命令 -h, --help 显示此帮助信息并退出。 命令: search 搜索Android文档 fetch 获取Android文档
emulator 用法: android emulator [-h] [COMMAND] 模拟器命令 -h, --help 显示此帮助信息并退出。 命令: create 创建虚拟设备 start 启动指定的虚拟设备。当模拟器完全启动并可用时,此命令将返回。 stop 停止指定的虚拟设备 list 列出可用的虚拟设备 remove 删除虚拟设备
help 用法: android help [COMMAND] 显示所有命令的帮助信息 [COMMAND] 要查看帮助的命令
info 用法: android info <field> 打印环境信息(SDK位置等) <field> 要打印值的特定字段。如果省略则打印所有信息。
init 用法: android init 初始化Android CLI的环境(如技能)。
layout 用法: android layout [-dhp] [--device=PARAM] [-o=PARAM] 返回应用的布局树 -d, --diff 返回自上次调用ui-dump以来已更改的布局元素的扁平列表 --device=PARAM 设备序列号 -h, --help 显示此帮助信息并退出。 -o, --output=PARAM 将布局树写入指定文件或目录。如果省略,则将树打印到标准输出 -p, --pretty 对返回的JSON进行格式化输出
run 用法: android run [-h] [--debug] [--activity=PARAM] [--device=PARAM] [--type=PARAM] [--apks=PARAM[,PARAM...]]... 部署Android应用 --activity=PARAM Activity名称 --apks=PARAM[,PARAM...] APK路径 --debug 以调试模式运行 --device=PARAM 设备序列号 -h, --help 显示此帮助信息并退出。 --type=PARAM 组件类型(ACTIVITY、SERVICE等)
screen 用法: android screen [-h] [COMMAND] 设备查看命令 -h, --help 显示此帮助信息并退出。 命令: capture 将设备屏幕输出为PNG格式 resolve 可视化定位UI元素
sdk 用法: android sdk [COMMAND] 下载并列出SDK包 命令: install 安装SDK包 update 将一个或所有包更新至最新版本 remove 从SDK中移除包 list 列出已安装和可用的SDK包
skills 用法: android skills [COMMAND] 管理技能 命令: add 安装技能 remove 移除技能 list 列出可用技能 find 通过关键词查找技能
update 用法: android update [--url=PARAM] 更新Android CLI --url=PARAM 下载更新的URL