AgentSkillsCN

android-cli

AndroidSdk.Tool CLI(`android` 命令)参考文档——一款用于 Android SDK 自动化的 .NET 全局工具。适用场景如下:(1) 管理 Android SDK 软件包(列出、安装、卸载、下载);(2) 操作 AVD/模拟器(创建、删除、启动、列出);(3) 通过 ADB 与已连接设备进行交互(列出设备、获取属性、安装/卸载 APK);(4) 查找或配置适用于 Android 开发的 JDK;(5) 为 Android 或 .NET MAUI 开发搭建 CI/CD 流程;(6) 读取 APK 清单信息;(7) 以非交互方式接受 SDK 许可证。

SKILL.md
--- frontmatter
name: android-cli
description: "Reference for the AndroidSdk.Tool CLI (`android` command) - a .NET global tool for Android SDK automation. Use when: (1) Managing Android SDK packages (list, install, uninstall, download), (2) Working with AVDs/emulators (create, delete, start, list), (3) Interacting with connected devices via ADB (list devices, get properties, install/uninstall APKs), (4) Locating or configuring JDK for Android development, (5) Setting up CI/CD for Android or .NET MAUI development, (6) Reading APK manifest information, (7) Accepting SDK licenses non-interactively."

AndroidSdk.Tool CLI Reference

The android CLI is a .NET global tool providing programmatic access to Android SDK management. Install with:

bash
dotnet tool install -g AndroidSdk.Tool

Command Groups

GroupPurpose
sdkSDK package management (list, install, download, licenses)
avdAndroid Virtual Device management (create, delete, start)
deviceConnected device operations via ADB
jdkJDK discovery and configuration
apkAPK inspection tools

Quick Start Examples

bash
# Find SDK and show info
android sdk find
android sdk info

# List available and installed packages
android sdk list --available
android sdk list --installed

# Install emulator and system image
android sdk install --package emulator
android sdk install --package "system-images;android-34;google_apis;x86_64"

# Create and start an emulator
android avd create --name TestDevice --sdk "system-images;android-34;google_apis;x86_64" --device pixel_6
android avd start --name TestDevice --wait-boot

# List connected devices and install APK
android device list
android device install --package ./app.apk

Common Options

Most commands support:

  • -f|--format <json|xml> - Output as JSON or XML instead of table
  • -h|--home <path> - Specify Android SDK home path (overrides auto-detection)

Detailed Command Reference

For complete parameter details, see:

CI/CD Workflow Example

bash
# Download SDK to specific location (for CI)
android sdk download --home /opt/android-sdk --force

# Accept all licenses non-interactively
android sdk accept-licenses --force

# Install required components
android sdk install --package "platform-tools"
android sdk install --package "emulator"
android sdk install --package "platforms;android-34"
android sdk install --package "system-images;android-34;google_apis;x86_64"

# Create headless emulator
android avd create --name CI_Emulator --sdk "system-images;android-34;google_apis;x86_64" --device pixel_6 --force

# Start emulator in headless mode and wait for boot
android avd start --name CI_Emulator --no-window --no-audio --no-boot-anim --wait-boot --timeout 300

# Run tests, then devices are cleaned up when CI job ends

Setting .NET MAUI/Xamarin Preferred Paths

Configure the SDK/JDK paths that .NET Android workloads will use:

bash
# Set preferred Android SDK for .NET builds
android sdk dotnet-prefer --home /path/to/android-sdk

# Set preferred JDK for .NET builds
android jdk dotnet-prefer --home /path/to/jdk