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


当前回答

从控制台运行模拟器的方法(我假设你之前安装了它,使用Android Studio)是:

run

cd ~/Android/Sdk/tools/bin && ./avdmanager列表

OR

cd ~/Android/Sdk/tools && ./emulator -list-avds

您将获得虚拟安装设备的列表。我的情况是:

Available Android Virtual Devices:
  Name: Galaxy_Nexus_API_17
  Device: Galaxy Nexus (Google)
  Path: /home/piotr/.android/avd/Galaxy_Nexus_API_17.avd
  Target: Google APIs (Google Inc.)
  Based on: Android 4.2 (Jelly Bean) Tag/ABI: google_apis/x86
  Skin: galaxy_nexus
  Sdcard: /home/piotr/.android/avd/Galaxy_Nexus_API_17.avd/sdcard.img

复制要运行的设备名称,然后

cd ~/Android/Sdk/tools && ./emulator -avd NAME_OF_YOUR_DEVICE . exe

在我的例子中:

cd ~/Android/Sdk/tools && ./emulator -avd Nexus_5X_API_23

其他回答

如果你使用的是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

试试这个

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]

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

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

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

在ANDROID_HOME文件夹中有一个tools文件夹

在Mac / Linux <avd > > 在Windows 模拟器。exe -avd <avdName>

如果你正在使用API 24,你可以从列表中获得模拟器的名称 Android列表avds 如果你正在使用API 25,那么你将在工具\bin中获得avdmanager Avdmanager列出avds

从控制台运行模拟器的方法(我假设你之前安装了它,使用Android Studio)是:

run

cd ~/Android/Sdk/tools/bin && ./avdmanager列表

OR

cd ~/Android/Sdk/tools && ./emulator -list-avds

您将获得虚拟安装设备的列表。我的情况是:

Available Android Virtual Devices:
  Name: Galaxy_Nexus_API_17
  Device: Galaxy Nexus (Google)
  Path: /home/piotr/.android/avd/Galaxy_Nexus_API_17.avd
  Target: Google APIs (Google Inc.)
  Based on: Android 4.2 (Jelly Bean) Tag/ABI: google_apis/x86
  Skin: galaxy_nexus
  Sdcard: /home/piotr/.android/avd/Galaxy_Nexus_API_17.avd/sdcard.img

复制要运行的设备名称,然后

cd ~/Android/Sdk/tools && ./emulator -avd NAME_OF_YOUR_DEVICE . exe

在我的例子中:

cd ~/Android/Sdk/tools && ./emulator -avd Nexus_5X_API_23