我在Mac上,在终端上进行Android开发。我已经成功地创建了HelloWorld项目,现在我试图从Android模拟器中的命令行运行它。哪个命令运行HelloWorld项目的模拟器?
我已经有Android工具和平台工具在我的路径。
编辑:
如何告诉模拟器从命令行运行HelloWorld项目?我已经用ant构建了这个项目。
我在Mac上,在终端上进行Android开发。我已经成功地创建了HelloWorld项目,现在我试图从Android模拟器中的命令行运行它。哪个命令运行HelloWorld项目的模拟器?
我已经有Android工具和平台工具在我的路径。
编辑:
如何告诉模拟器从命令行运行HelloWorld项目?我已经用ant构建了这个项目。
当前回答
如果你有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模拟器启动!
其他回答
不建议使用android create avd命令。现在建议使用avdmanager来代替从命令行启动模拟器。
首先,如果模拟器不存在,创建一个新的模拟器:
avdmanager create avd --name "MyEmulator" -k "system-images;android-
26;google_apis;x86"
这里假设您已经安装了一个与API 26匹配的X86系统映像,并安装了谷歌API。
然后,您可以使用emulator @MyEmulator启动模拟器。
我迟到了,在这里,但想要分享,所以它可能会帮助别人和我以后需要的时候:), 下面是使用bash脚本从命令行打开模拟器的方法。 我使用MX Linux,但在所有操作系统上的过程是相同的
1-首先检查已安装的仿真器
emulator -list-avds
结果如下所示
emulator -list-avds
Nexus_4_API_28
Pixel_2_API_28
2-打开任何纯文本或代码编辑器,创建一个新文件,并如下所示
#!/bin/sh
emulator -avd Nexus_4_API_28
Nexus_4_API_28是模拟器,我想打开你写你从第一步得到的
以.sh扩展名保存此文件
3-然后,更改文件的权限,使其可执行:
chmod u+x emu.sh
4-现在打开模拟器,用下面的命令执行这个bash脚本文件
./emu.sh
上可用的avd名称列表
android - avd。 SDK_PATH/工具/ emuls / netdelay no -netspeed full -avd “AVD_NAME”
运行第一个可用的模拟器:
~/Library/Android/sdk/tools/emulator -avd `~/Library/Android/sdk/tools/emulator -list-avds | awk '{print $1}'`
如果你有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模拟器启动!