有没有一种方法可以在不启动Android Studio的情况下运行模拟器。也许是从命令行。我知道这个功能在旧版本中是可用的,但从那以后就消失了。但也许有人已经知道怎么做了?


当前回答

试试这个

1. 完整的视频教程(适用于所有windows版本)

OR

2. 文本教程

Open the command prompt and change the directory where your sdk is placed D:\Softwares\Android\sdk\tools\bin> now add your avdmanager in this,now your full code is D:\Softwares\Android\sdk\tools\bin>avdmanager list avd it will show you a list of emulator device that you have already created after few seconds now typecd.. and run your emulator with this cmd, Here my emulator name is Tablet_API_25 so I have typed this name after the -avd. D:\Softwares\Android\sdk\tools>emulator -avd Tablet_API_25

编辑:对于Android Studio 3.2或更高版本,路径更改为D:\Softwares\Android\sdk\emulator\emulator -avd Tablet_API_25

例如:%ANDROID_HOME%\tools\emulator -avd [AVD NAME]

其他回答

模拟器的路径为

/Users/<Username>/AppData/Local/Android/sdk/tools

如果你使用的是windows,那就创建一个。bat文件,然后双击这个。bat文件,这将为你每天节省一些时间。下面是我用批处理文件启动android模拟器的代码:

@echo off
title Android Emulator
color 1b
echo #################################

echo Please make sure that your android path is correct for the script
echo Change this path "C:\Users\YOUR_USER_NAME\AppData\Local\Android\Sdk\emulator" to use your curret path and save it as a .bat file on your system to launch android emulator
echo #################################
c:
cd C:\Users\YOUR_USER_NAME\AppData\Local\Android\Sdk\emulator
emulator -avd Nexus_5X_API_28

pause

一张图胜过千言万语:)

如何从MAC终端启动AVD

在Ubuntu 20.04中,我找到了以下解决方案

首先你需要导出Android路径变量。为此:

export ANDROID_SDK=~/Android/Sdk
export PATH=$ANDROID_SDK/emulator:$ANDROID_SDK/tools:$PATH

根据您的安装路径不同,路径可能会有所变化。如果Android Studio是使用Ubuntu软件安装的,那么路径将与上面所述相同。

如果导出工作正常,那么下面的命令应该列出您的AVD名称。

emulator -list-avds

在我的例子中,我得到了结果

Nexus_5_API_30

这是我的AVD的名字。

如果上面的命令列出了您的AVD名称,那么您可以通过以下方式运行您的AVD:

emulator @YOUR_AVD_NAME

对我来说

emulator @Nexus_5_API_30

您可以将导出命令添加到.bashrc文件中,以避免每次需要运行AVD时都输入导出命令。

你可以制作一个批处理文件,这将直接打开模拟器,而不需要打开Android Studio。如果你使用的是Windows:

Open Notepad New file Copy the next lines into your file: cd /d C:\Users\%username%\AppData\Local\Android\sdk\tools emulator @[YOUR_EMULATOR_DEVICE_NAME] Notes: Replace [YOUR_EMULATOR_DEVICE_NAME] with the device name you created in emulator To get the device name go to: C:\Users\%username%\AppData\Local\Android\sdk\tools Run cmd and type: emulator -list-avds Copy the device name and paste it in the batch file Save the file as emulator.bat and close Now double click on emulator.bat and you got the emulator running!