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

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

编辑:

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


当前回答

如果你已经有模拟器,并想使用使用命令,只需使用这一行代码

cd  C:\Users\yourUserName\AppData\Local\Android\Sdk\emulator | ./emulator -avd Pixel_5_API_32

回头谢谢我……

其他回答

在这里,你可以通过命令行查看执行该命令的选项:

emulator -avd avd_name [-option [value]] ... [-qemu args]

例如,我是这样使用它的:

emulator -avd ICS_ARM -wipe-data -no-boot-anim -cpu-delay 0

在这里补充一下,每当你得到“错误:设备离线”意味着与模拟器和adb桥接器的连接由于模拟器启动所花费的时间而中断。

而不是重新启动模拟器在这一点上,尝试以下两个命令停止&启动adb桥再次。

亚行kill-server 亚洲开发银行启动服务器

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

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

列出所有模拟器:

emulator -list-avds

运行一个带-avd标志的模拟器:

emulator -avd name-of-your-emulator

模拟器可执行文件在下面:

${ANDROID_SDK}/tools/emulator

或者,对于更新的sdk,尝试:

cd ${ANDROID_HOME}/emulator
emulator -avd name-of-your-emulator

如果你有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模拟器启动!