我在Mac上,在终端上进行Android开发。我已经成功地创建了HelloWorld项目,现在我试图从Android模拟器中的命令行运行它。哪个命令运行HelloWorld项目的模拟器?

我已经有Android工具和平台工具在我的路径。

编辑:

如何告诉模拟器从命令行运行HelloWorld项目?我已经用ant构建了这个项目。


当前回答

(Linux) 在你的终端复制粘贴和改变三个蓝色的字段

/home/YouUser/Folder/adt-bundle-linux-x86_64-20140702/sdk/tools/emulator64-x86 -avd Android5.1.1

YouUser = user of session in linux
Folder = path of folfer
Android5.1.1 = You version of android in the emulator,for example (Android4.4.2)

你可以在你的文件夹home中查看模拟器 cd /home/Youuser/.android/avd/

其他回答

如果你有Git Bash,你可以双击打开模拟器,进行一些初始设置(仅在Windows 10中测试):

Open Git Bash. Run cd ~/AppData/Local/Android/sdk/emulator Run ./emulator -list-avds and keep note of the emulator's name. MY_EMULATOR for example. Open Notepad and add these two lines (insert your emulator's name instead of MY_EMULATOR): cd ~/AppData/Local/Android/sdk/emulator; ./emulator -avd MY_EMULATOR Save the file somewhere convinient as myfile.sh. You can change "myfile" as suits you best, but the extension .sh is needed. Open Git Bash at the directory where you stored myfile.sh and run chmod +x myfile.sh. Remember to put your file's name instead of myfile.

就是这样!从现在开始,每次你需要启动模拟器,只要找到你的myfile.sh,双击它,等待你的Android模拟器启动!

在Mac(我认为还有Linux)上,创建AVD后,你可以创建一个别名: alias run-android='~/Library/Android/sdk/tools/emulator -avd ${YOUR_AVD_NAME} &'

注意:别名的执行不会锁定你的终端,如果你想这样做,只需删除最后一个'&'。

运行模拟器它自己会给你一个错误,因为他期望,在你当前的位置,你有:/emulator/qemu/${YOUR_PATFORM}/qemu-system-x86_64'来启动模拟器。

在cmd中轻松地键入此命令。 替换Users\您的用户名\ 如果你没有这个文件重新安装android studio。

如果您严格地试图从命令行运行模拟器,请在OSX中尝试此操作。

"/Applications/Android Studio.app/sdk/tools/emulator" -avd <NAMEOFDEVICE> -netspeed full -netdelay none

您可以通过向.bash_profile添加别名并将其发送到后台作业来简化它。

alias android='/Applications/Android\ Studio.app/sdk/tools/emulator <NAMEOFDEVICE> -netspeed full -netdelay none &'

让Bash知道这些变化。

source ~/.bash_profile

在windows中,我使用这个PowerShell脚本来启动它。

$em = $env:USERPROFILE+"\AppData\Local\Android\sdk\tools\emulator.exe"; 
Start-Process $em " -avd Nexus_5X_API_24" -WindowStyle Hidden;