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


当前回答

Windows用户

创建并打开一个bat文件(.bat是文件的扩展名) 将以下代码放入文件中 cd /d SDK文件夹路径\emulator && emulator -avd emulator名称

下面是一个例子

cd /d E:\Run\Android_Installation_Final\Sdk\emulator && emulator -avd Pixel_API_28

保存它。 从任何cmd(命令提示符shell)运行它

你可以看到我的帖子自动启动模拟器时,Windows启动

其他回答

以下是我在windows中快速运行模拟器所做的: 我创建了一个这样的windows批处理文件:

start C:\Users\{Username}\AppData\Local\Android\Sdk\tools\emulator.exe -avd {Emulator_Name}

每次需要模拟器时运行批处理文件。

让它在Windows 10上工作:

C:\Users\UserName\AppData\Local\Android\Sdk\tools>emulator -list-avds
Nexus_5X_API_28
C:\Users\UserName\AppData\Local\Android\Sdk\emulator>emulator -avd Nexus_5X_API_28

如果你使用的是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
cd C:\Users\{computer_user_name}\AppData\Local\Android\Sdk\emulator

然后运行:

./emulator -list-avds
or
emulator -list-avds

输出:

PIXEL_2_API_29
PIXEL_2_XL_API_29

然后运行:

./emulator -avd PIXEL_2_XL_API_29
or
emulator -avd PIXEL_2_XL_API_29

就是这样

你可以制作一个批处理文件,这将直接打开模拟器,而不需要打开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!