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


当前回答

在MacOS

首先列出已安装的模拟器

~/Library/Android/sdk/tools/emulator -list-avds

然后运行模拟器

~/Library/Android/sdk/tools/emulator -avd Nexus_5X_API_27

其他回答

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

(仅适用于Windows) 为什么要折磨自己?制作一个简单的BAT文件!:

打开记事本 创建如下所示的命令 保存为*.bat (可选)创建*.bat的快捷方式,重命名快捷方式并更改图标

命令如下:

cd /d你的cd

例子:

cd /d d:\Android_SDK\emulator && emulator -avd Nexus_5_API_28

列出您拥有的模拟器

~/Library/Android/sdk/tools/emulator -list-avds

例如,我有这个Nexus_5X_API_24

运行模拟器的命令是

cd ~/Library/Android/Sdk/tools && ./emulator -avd Nexus_5X_API_24

试试这个

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]

mac专用解决方案(applescript)

下面的applescript将显示一个简单的GUI,允许你选择你想要启动的android图像。

该脚本可以从终端或ootb脚本编辑器中运行。运行▶。

你可以通过从脚本编辑器中选择将脚本转换为独立的Mac应用程序。app文件>导出…>文件格式:应用>保存到“/应用”文件夹。

### TODO! Set the correct path to your `emulator` command
set avds to paragraphs of (do shell script "~/Library/Android/sdk/emulator/emulator -list-avds")
set avd to (choose from list avds with prompt "Please select an AVD to start" default items "None" OK button name {"Start"} cancel button name {"Cancel"})
do shell script "~/Library/Android/sdk/emulator/emulator -avd " & avd & " -no-boot-anim > /dev/null 2>&1 &"

注意:要查找模拟器的正确路径,请在终端中运行-a模拟器。

为了从终端运行脚本,让它可执行(例如chmod +x android_launcher.sh),并在顶部添加以下shebang行:

#!/usr/bin/osascript