我如何启动命令行Android模拟器? [英] How do I launch the Android emulator from the command line?

查看:139
本文介绍了我如何启动命令行Android模拟器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Mac上,努力从终端Android的发展。我已经成功地创建了的HelloWorld 项目,现在我想在命令行中运行在Android模拟器。其中命令运行模拟器我的HelloWorld项目?

I'm on Mac, working on Android development from the terminal. I have successfully created the HelloWorld project and now I'm trying to run it from the command line in the Android emulator. Which command runs the emulator for my HelloWorld project?

我已经在我的道路了Android工具和平台的工具。

I already have the Android tools and platform-tools in my PATH.

编辑:

我如何告诉模拟器来运行我的命令行HelloWorld项目?我已经建有蚂蚁的项目。

How do I tell the emulator to run my HelloWorld project from the command line? I've already built the project with ant.

推荐答案

我假设你已经建立您的项目,只需要启动它,但你没有创建任何AVDS和必须使用命令行所有动作。你必须做到以下几点。

I assume that you have built your project and just need to launch it, but you don't have any AVDs created and have to use command line for all the actions. You have to do the following.

  1. 创建一个新的虚拟设备(AVD)您需要的平台。如果你必须使用命令行来创建你的AVD,你可以叫的Andr​​oid创建AVD -n<名称> -t<目标ID> ,其中目标ID是你需要的API级别。如果可以使用图形用户界面,只需键入 Android的AVD ,它将启动管理器,在这里你可以这样做。你可以阅读更多有关 AVD管理通过GUI 和的通过命令行
  2. 运行AVD通过使用命令模拟器-avd<名称> 通过或previously启动GUI。等到模拟器完全加载,它需要一些时间。你可以阅读有关其他选项这里
  3. 现在,您必须安装应用程序到您的AVD。通常在开发过程中,你只需要使用你用来建造项目同样Ant脚本,只需选择安装目标。但是,您可以使用命令 ADB安装&LT手动安装应用程序,路径到您的-APK>
  4. 现在,切换到仿真器并启动应用程序就像任何普通的设备,通过发射器。或者,作为替代,可以使用下面的命令:亚行外壳上午开始-a -n android.intent.action.MAIN<包装> /<活动类> 。例如:亚行外壳上午开始-a -n android.intent.action.MAIN org.sample.helloworld / org.sample.helloworld.HelloWorld 。作为一个评论者建议,您也可以替换 org.sample.helloworld.HelloWorld 上面只用行 .HelloWorld ,它也可以工作。
  1. Create a new virtual device (AVD) for the platform you need. If you have to use command line for creating your AVD, you can call android create avd -n <name> -t <targetID> where targetID is the API level you need. If you can use GUI, just type in android avd and it will launch the manager, where you can do the same. You can read more about AVD management through GUI and through command line.
  2. Run the AVD either by using command emulator -avd <name> or through previously launched GUI. Wait until the emulator fully loads, it takes some time. You can read about additional options here.
  3. Now you have to install the application to your AVD. Usually during development you just use the same Ant script you used to build the project, just select install target. However, you can install the application manually using command adb install <path-to-your-APK>.
  4. Now switch to emulator and launch your application like on any normal device, through the launcher. Or, as an alternative, you can use the following command: adb shell am start -a android.intent.action.MAIN -n <package>/<activity class>. For example: adb shell am start -a android.intent.action.MAIN -n org.sample.helloworld/org.sample.helloworld.HelloWorld. As a commenter suggested, you can also replace org.sample.helloworld.HelloWorld in the line above with just .HelloWorld, and it will work too.

这篇关于我如何启动命令行Android模拟器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆