avdmanager
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
avdmanager
是一个命令行工具,可以用于从命令行创建和管理 Android 虚拟设备 (AVD)。借助 AVD,您可以定义要在 Android 模拟器中模拟的 Android 手机、Wear OS 手表或 Android TV 设备的特性。
如果您使用的是 Android Studio,则无需使用此工具,而是可以从 IDE 中创建和管理 AVD。
avdmanager
工具包含在 Android SDK 命令行工具软件包中(位于 android_sdk/cmdline-tools/version/bin/avdmanager
)。
语法
如需使用 avdmanager
,请使用以下语法:
avdmanager [global options] command [command options]
全局选项
表 1. avdmanager 的全局选项列表。
全局选项
|
说明
|
-s | --silent
|
静默模式:仅输出错误。
|
-h | --help
|
使用帮助。
|
-v | --verbose
|
详细模式:输出错误、警告和参考性消息。
|
--clear cache
|
清除 SDK 管理器代码库清单缓存。
|
命令和命令选项
表 2. avdmanager 的命令和选项列表。
命令和选项
|
说明
|
create avd -n name -k "sdk_id" [-c
{path|size}] [-f] [-p path]
|
创建新的 AVD。您必须为该 AVD 提供 name,并使用加引号的 sdk_id 指定要用于该 AVD 的 SDK 软件包的 ID。例如,以下命令会使用 x86 系统映像(API 级别 25)创建名为 test 的 AVD:
avdmanager create avd -n test -k "system-images;android-25;google_apis;x86"
下面介绍了其他选项的用法:
-
-c {path|size} :此 AVD 的 SD 卡映像的路径,或要为此 AVD 创建的新 SD 卡映像的大小(以 KB 或 MB 为单位,分别以 K 或 M 表示)。例如,-c path/to/sdcard/ 或 -c 1000M 。
-
-f :强制创建 AVD。如果您需要用同名的新 AVD 覆盖现有的 AVD,请使用此选项。
-
-p path :用于从中创建此 AVD 的文件的目录所在位置的路径。如果您未指定路径,则系统会在 ~/.android/avd/ 中创建 AVD。
|
delete avd -n name
|
删除 AVD。您必须使用 name 指定该 AVD。
|
move avd -n name [-p path] [-r
new-name]
|
移动或重命名 AVD。您必须使用 name 指定该 AVD。下面介绍了其他选项的用法:
-
-p path :用于接收此 AVD 的文件的目录所在位置的绝对路径。如果您不添加此参数,则系统不会移动 AVD。如果您想在原位重命名 AVD,则可以选择不添加此参数。
-
-r new-name :要重命名的 AVD 的新名称。
|
list [target|device|avd] [-c]
|
列出所有可用的目标、设备定义或 AVD。如果您未指定 target 、device 或 avd ,则 avdmanager 会列出全部三项。添加 -c 参数可以接收适合脚本的简洁输出。将全部三个选项一起列出时,-c 参数不可用。
|
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# avdmanager\n\nThe `avdmanager` is a command-line tool that lets you create and manage\nAndroid Virtual Devices (AVDs) from the command line. An AVD lets you define the\ncharacteristics of an Android handset, Wear OS watch, or Android TV device\nthat you want to simulate in the Android Emulator.\n\nIf you're using Android Studio, then you don't need to use this tool and you\ncan instead\n[create and manage AVDs from the IDE](/studio/run/managing-avds).\n\nThe `avdmanager` tool is included in the Android SDK Command-Line Tools package\nat\n\u003cvar translate=\"no\"\u003eandroid_sdk\u003c/var\u003e`/cmdline-tools/`\u003cvar translate=\"no\"\u003eversion\u003c/var\u003e`/bin/avdmanager`.\n\nSyntax\n------\n\nTo use `avdmanager`, use the following syntax: \n\n```\navdmanager [global options] command [command options]\n```\n\n### Global options\n\n**Table 1.** List of global options for\navdmanager.\n\n| Global option | Description |\n|---------------------|-------------------------------------------------------------------------|\n| `-s` \\| `--silent` | Silent mode: only errors are printed out. |\n| `-h` \\| `--help` | Usage help. |\n| `-v` \\| `--verbose` | Verbose mode: errors, warnings, and informational messages are printed. |\n| `--clear cache` | Clear the SDK Manager repository manifest cache. |\n\n### Commands and command options\n\n**Table 2.** List of commands and options\nfor avdmanager.\n\n| Command and options | Description |\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `create avd -n `\u003cvar translate=\"no\"\u003ename\u003c/var\u003e` -k \"`\u003cvar translate=\"no\"\u003esdk_id\u003c/var\u003e`\" [-c {`\u003cvar translate=\"no\"\u003epath\u003c/var\u003e`|`\u003cvar translate=\"no\"\u003esize\u003c/var\u003e`}] [-f] [-p `\u003cvar translate=\"no\"\u003epath\u003c/var\u003e`]` | Create a new AVD. You must provide a \u003cvar translate=\"no\"\u003ename\u003c/var\u003e for the AVD and specify the ID of the SDK package to use for the AVD using \u003cvar translate=\"no\"\u003esdk_id\u003c/var\u003e wrapped in quotes. For example, the following command creates an AVD named `test` using the x86 system image for API level 25: ``` avdmanager create avd -n test -k \"system-images;android-25;google_apis;x86\" ``` The following describes the usages for the other options: - `-c {`\u003cvar translate=\"no\"\u003epath\u003c/var\u003e`|`\u003cvar translate=\"no\"\u003esize\u003c/var\u003e`}`: The path to the SD card image for this AVD or the size of a new SD card image to create for this AVD in KB or MB, denoted with `K` or `M`. For example, `-c path/to/sdcard/` or `-c 1000M`. - `-f`: Force creation of the AVD. Use this option if you need to overwrite an existing AVD with a new AVD using the same name. - `-p `\u003cvar translate=\"no\"\u003epath\u003c/var\u003e: Path to the location where the directory for this AVD's files will be created. If you don't specify a path, the AVD is created in `~/.android/avd/`. |\n| `delete avd -n `\u003cvar translate=\"no\"\u003ename\u003c/var\u003e | Delete an AVD. You must specify the AVD with \u003cvar translate=\"no\"\u003ename\u003c/var\u003e. |\n| `move avd -n `\u003cvar translate=\"no\"\u003ename\u003c/var\u003e` [-p `\u003cvar translate=\"no\"\u003epath\u003c/var\u003e`] [-r `\u003cvar translate=\"no\"\u003enew-name\u003c/var\u003e`]` | Move or rename an AVD. You must specify the AVD with \u003cvar translate=\"no\"\u003ename\u003c/var\u003e. The following describes the usages for the other options: - `-p `\u003cvar translate=\"no\"\u003epath\u003c/var\u003e: The absolute path to the location at which to create the directory where this AVD's files will be moved. If you don't include this argument, the AVD won't be moved. You might choose not to include this argument if you want to rename the AVD in place. - `-r `\u003cvar translate=\"no\"\u003enew-name\u003c/var\u003e: The new name of the AVD being renamed. |\n| `list [target|device|avd] [-c]` | List all available targets, device definitions, or AVDs. If you don't specify `target`, `device`, or `avd`, `avdmanager` lists all three. Include the `-c` argument to receive a compact output suitable for scripts. The `-c` argument is not available when listing all three options together. |"]]