avdmanager
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
avdmanager
là công cụ dòng lệnh cho phép bạn tạo và quản lý Thiết bị Android ảo (AVD) từ dòng lệnh. AVD cho phép bạn xác định các đặc điểm của điện thoại di động Android, đồng hồ Wear OS hoặc thiết bị Android TV mà bạn muốn mô phỏng trong Trình mô phỏng Android.
Nếu đang sử dụng Android Studio thì bạn không cần sử dụng công cụ này mà có thể tạo và quản lý AVD từ IDE.
Công cụ avdmanager
có trong gói Công cụ dòng lệnh của SDK Android tại android_sdk/cmdline-tools/version/bin/avdmanager
.
Cú pháp
Để dùng avdmanager
, hãy sử dụng cú pháp sau:
avdmanager [global options] command [command options]
Tuỳ chọn chung
Bảng 1. Danh sách các tuỳ chọn chung cho avdmanager.
Tuỳ chọn chung
|
Nội dung mô tả
|
-s | --silent
|
Chế độ im lặng: chỉ in lỗi.
|
-h | --help
|
Trợ giúp sử dụng. |
-v | --verbose
|
Chế độ chi tiết: in lỗi, cảnh báo và tin nhắn thông báo.
|
--clear cache
|
Xoá bộ nhớ đệm của tệp kê khai kho lưu trữ Trình quản lý SDK.
|
Lệnh và các tuỳ chọn lệnh
Bảng 2. Danh sách các lệnh và tuỳ chọn cho avdmanager.
Lệnh và các tuỳ chọn
|
Mô tả
|
create avd -n name -k "sdk_id" [-c
{path|size}] [-f] [-p path]
|
Tạo một AVD mới. Bạn phải cung cấp name cho AVD và chỉ định mã của gói SDK để dùng cho AVD sử dụng sdk_id nằm trong dấu ngoặc kép.
Ví dụ: sau đây là lệnh tạo AVD có tên test sử dụng hình ảnh hệ thống x86 cho API cấp 25:
avdmanager create avd -n test -k "system-images;android-25;google_apis;x86"
Phần sau đây mô tả cách sử dụng cho các tuỳ chọn khác:
-
-c {path|size} : Đường dẫn đến hình ảnh thẻ SD cho AVD này hoặc kích thước của một hình ảnh thẻ SD mới để tạo cho AVD này, tính bằng KB hoặc MB, được biểu thị bằng K hoặc M . Ví dụ: -c path/to/sdcard/ hoặc -c 1000M .
-
-f : Buộc tạo AVD. Sử dụng tuỳ chọn này nếu bạn cần ghi đè một AVD hiện có bằng một AVD mới cùng tên.
-
-p path : Đường dẫn đến vị trí nơi thư mục cho các tệp của AVD này được tạo. Nếu bạn không chỉ định đường dẫn, AVD sẽ được tạo trong ~/.android/avd/ .
|
delete avd -n name
|
Xoá AVD. Bạn phải chỉ định AVD bằng name.
|
move avd -n name [-p path] [-r
new-name]
|
Di chuyển hoặc đổi tên AVD. Bạn phải chỉ định AVD bằng name.
Phần sau đây mô tả cách sử dụng cho các tuỳ chọn khác:
-
-p path : Đường dẫn tuyệt đối đến vị trí để tạo thư mục mà các tệp của AVD này sẽ được chuyển vào. Nếu bạn không đưa vào đối số này, AVD sẽ không được di chuyển. Bạn có thể chọn không đưa vào đối số này nếu muốn đổi tên AVD tại chỗ.
-
-r new-name : Tên mới của AVD sẽ được đổi.
|
list [target|device|avd] [-c]
|
Liệt kê tất cả các mục tiêu, định nghĩa thiết bị hoặc AVD có sẵn. Nếu bạn không chỉ định target , device hoặc avd , avdmanager sẽ liệt kê cả ba tuỳ chọn. Đưa vào đối số -c để nhận được kết quả nhỏ gọn, phù hợp với tập lệnh. Đối số -c không dùng được khi bạn liệt kê cả ba tuỳ chọn cùng nhau.
|
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-27 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-27 UTC."],[],[],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. |"]]