简体   繁体   English

如何从命令行打开 Ubuntu Linux 上的 AVD 管理器?

[英]How to open the AVD manager on Ubuntu Linux from the command line?

如何从命令行打开 Ubuntu Linux 上的 AVD 管理器?

For thoose coming here because the android avd command has been deprecated*, here's how to do it now:对于那些因为android avd命令已被弃用*而来到这里的人,现在是这样做的:

Using Android Studio使用 Android Studio

Open Android Studio with a valid studio project (if you don't have one, simply create one empty).使用有效的 Studio 项目打开 Android Studio(如果没有,只需创建一个空的)。 After you've your project open, go to Tools => Android => AVD Manager .打开项目后,转到Tools => Android => AVD Manager Note that this menu does not appear if you don't have a valid Android Studio project open .请注意,如果您没有打开有效的 Android Studio 项目,则不会出现此菜单

Now you can safely close Android Studio if you only want the AVD Manager.如果您只需要 AVD 管理器,现在您可以安全地关闭 Android Studio。

From command line从命令行

If you want to use the command line you'll first need to create the virtual device using avdmanager , located under $ANDROID_HOME/tools/bin/avdmanager like so:如果要使用命令行,首先需要使用avdmanager创建虚拟设备,位于$ANDROID_HOME/tools/bin/avdmanager如下所示:

$ANDROID_HOME/tools/bin/avdmanager create avd --force --name testAVD --abi google_apis/x86_64 --package 'system-images;android-23;google_apis;x86_64'

After you created the device to emulate, then you need to open it with emulator , which is located under $ANDROID_HOME/tools/emulator .创建要模拟的设备后,您需要使用emulator打开它,它位于$ANDROID_HOME/tools/emulator The command for the previously created device should be something like:先前创建的设备的命令应该类似于:

emulator -avd testAVD

If it crashes saying something like...如果它崩溃说类似...

[140022905190208]:ERROR:./android/qt/qt_setup.cpp:28:Qt library not found at ../emulator/lib64/qt/lib

Ensure you're running the emulator command inside the $ANDROID_HOME/tools folder, otherwise may not work.确保您在$ANDROID_HOME/tools文件夹中运行emulator命令,否则可能无法运行。

If you already added a device VM you can list them all with如果您已经添加了设备 VM,则可以将它们全部列出

emulator -list-avds

Check out the official documentation for more details (thanks to Jeff Xiao for this—in comments).查看官方文档以获取更多详细信息(感谢 Jeff Xiao 对此的评论)。

* The depreaction note says: * 弃用说明说:

The android command is no longer available.
For manual SDK and AVD management, please use Android Studio.
For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager

使用android avd打开 AVD 管理器。

对我来说, ./android avd工作,其中androidandroid-studio/sdk/tools下的shell脚本。

./android avd is deprecated use ~/Android/Sdk/tools/bin/avdmanager --help instead! ./android avd已弃用,请改用~/Android/Sdk/tools/bin/avdmanager --help

or if it is easier for you, move to the directory and use it like in the old version:或者如果对您来说更容易,请移至该目录并像在旧版本中一样使用它:

cd ~/Android/Sdk/tools/bin/
./avdmanager

check new [options] with --help or -h before you use avdmanager在使用 avdmanager 之前,使用--help-h检查新的[options]

first occurence in Android Studio 2.3 !首次出现在 Android Studio 2.3 中!

Sadly commands android sdk and android avd stopped working so to run emulator we need to use different commands to download and build all devices and its dependencies:可悲的是,命令android sdkandroid avd停止工作,因此要运行模拟器,我们需要使用不同的命令来下载和构建所有设备及其依赖项:

  1. Download sdk-tools-linux (tar.gz) from :从以下位置下载 sdk-tools-linux (tar.gz)

https://developer.android.com/studio#downloads https://developer.android.com/studio#downloads

  1. Unpack tools to : ...android-sdk/tools (...wherever you want)将工具解压到...android-sdk/tools (...任何你想要的地方)

  2. Go to : android-sdk/tools/bin转到android-sdk/tools/bin

  3. Install needed sdk libraries :安装所需的 sdk 库

Execute in cmd在cmd中执行

sdkmanager --update

sdkmanager "platform-tools" "platforms;android-29" 

sdkmanager "build-tools;29.0.1" "extras;android;m2repository" "tools"

sdkmanager "system-images;android-29;google_apis_playstore;x86_64"

sdkmanager "emulator"
  1. Setup environment variables设置环境变量

Add env to system by editing ~/.bashrc (Linux) in Windows just setup system enviroments.通过在 Windows 中编辑 ~/.bashrc (Linux) 将 env 添加到系统中,只需设置系统环境。

export ANDROID_HOME=../android-sdk

export ANDROID_SDK_ROOT=$ANDROID_HOME

export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin

alias emulator="sh $ANDROID_HOME/tools/emulator"

Note: There is possible that You need JAVA_HOME too.注意:您可能也需要 JAVA_HOME。

Restart computer or cmd to load environments重启电脑或者cmd加载环境

  1. Create device :创建设备

Go to /bin转到 /bin

avdmanager create avd -n myDevice -k "system-images;android-29;google_apis_playstore;x86_64"
  1. run device:运行设备:

Got to dir and run进入目录并运行

cd android-sdk/tools
emulator -avd myDevice (or sh $ANDROID_HOME/tools/emulator -avd myDevice)

Issues:问题:

qemu emulator not found in /bin....在 /bin 中找不到 qemu 模拟器....

cd android-sdk/tools/bin
ln -s  android-sdk/emulator/ emulator

Android studio:v3.0.1安卓工作室:v3.0.1

Get name:获取名称:

/home/user/Android/Sdk/tools$ android list avd

Start emulator:启动模拟器:

/home/user/Android/Sdk/tools$ emulator -avd Nexus_6_API_23

First of all to show all devices run the following command from the location - ~/Android/Sdk/tools首先要显示所有设备从位置运行以下命令 - ~/Android/Sdk/tools

/home/user/Android/Sdk/tools> ./emulator -list-avds

then you will see the list of devices id, in my case i got following devices然后您将看到设备 ID 列表,在我的情况下,我有以下设备

Nexus_5X_API_28
Nexus_9_API_28

Now just run following command with the device id you want to run.现在只需使用您要运行的设备 ID 运行以下命令。

/home/user/Android/Sdk/tools> ./emulator -avd Nexus_9_API_28

I created shortcut with this command我用这个命令创建了快捷方式

 /path/to/Android/emulator/emulator -avd Nexus_5X_API_26

Where "Nexus_5X_API_26" is my virtual device I created in Android Studio (2.3.3).其中“Nexus_5X_API_26”是我在 Android Studio (2.3.3) 中创建的虚拟设备。 Correct name can be checked from ~/.android/avd/ folder, where are one subfolder (with extension .avd) and one file (with extension .ini) for each.可以从 ~/.android/avd/ 文件夹中检查正确的名称,其中每个文件夹都有一个子文件夹(扩展名为 .avd)和一个文件(扩展名为 .ini)。 There are qcow2 files which I think could be also run directly with qemu (have not tested yet).有 qcow2 文件,我认为也可以直接用 qemu 运行(尚未测试)。

I used a sudo bash command and that worked for me:我使用了 sudo bash 命令,这对我有用:

sudo ./avdmanager list

运行 sudo ./avdmanager list 后

Here's the command-line usage for creating an AVD:这是用于创建 AVD 的命令行用法:

android create avd -n -t [- ] ... android 创建 avd -n -t [-] ...

Example : android create avd -n my_android1.5 -t 2示例: android create avd -n my_android1.5 -t 2

If the target you selected was a standard Android system image ("Type: platform"), the android tool next asks you whether you want to create a custom hardware profile.如果您选择的目标是标准的 Android 系统映像(“类型:平台”),那么 android 工具接下来会询问您是否要创建自定义硬件配置文件。

Android 1.5 is a basic Android platform. Android 1.5 是一个基本的 Android 平台。 Do you wish to create a custom hardware profile [no]您是否希望创建自定义硬件配置文件 [否]

Use the create avd command to create a new AVD, specifying the --skin option with a value that references either a default skin name (such as "WVGA800") or a custom skin resolution (such as 240x432).使用 create avd 命令创建新的 AVD,指定 --skin 选项的值,该值引用默认皮肤名称(例如“WVGA800”)或自定义皮肤分辨率(例如 240x432)。 Here's an example:下面是一个例子:

android create avd -n -t --skin WVGA800 android 创建 avd -n -t --skin WVGA800

or you can refer from :-或者您可以参考:-

http://developer.android.com/tools/devices/managing-avds-cmdline.html http://developer.android.com/tools/devices/managing-avds-cmdline.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM