如何开始通过命令行的Andr​​oid示例项目? [英] how to start Android example project from command-line?

查看:115
本文介绍了如何开始通过命令行的Andr​​oid示例项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不喜欢使用Eclipse和希望开始在命令行的例子Android项目,我怎么能做到这一点?有没有办法使用的Android创建项目命令在例如code自动拉从SDK的方法吗?类似的方法或许下面?

  Android的创建项目--package com.example.helloandroid \\
--activity HelloAndroid \\
--target 1 \\
--path HelloAndroid


解决方案

下面是一个例子,如何构建和运行 ApiDemos 示例项目。


  1. 转到您的SDK文件夹,然后到 ../样本/机器人 - #/ ApiDemos ,其中#是API级别。

  2. 此文件夹中启动终端。

  3. 运行安卓列表目标并找到等于或高于你所选择的东西#在步骤1 API级别目标让我们把这个目标X.在我的情况下,X等于21,它看起来像你的情况X等于1。

  4. 运行 Android的更新项目-p。 -n ApiDemos -t X (x更改为正确的)

  5. 运行蚂蚁调试

  6. 运行 ADB安装斌/ ApiDemos-debug.apk

有关第6步成功,你需要通过USB将设备连接到计算机。请确保您已检查设置 - >应用 - >&开发 - GT; USB调试。您还可以验证亚行可以看到你的设备上运行 ADB设备终端。

现在示例项目建成并安装在设备上。

I dislike using Eclipse and wish to start an example Android project from the command-line, how can i do this? Is there a way to use "android create project" command to automatically pull in example code from the SDK? A similar method to the following perhaps?

android create project --package com.example.helloandroid \
--activity HelloAndroid \
--target 1 \
--path HelloAndroid

解决方案

Here is an example how to build and run ApiDemos sample project.

  1. Go to your SDK folder, then to ../samples/android-#/ApiDemos, where # is API Level.
  2. Start terminal in this folder.
  3. Run android list targets and find target with API Level that is equal or higher then what you've chosen for # on step 1. Lets call this target X. In my case X equals 21. It looks like in your case X equals 1.
  4. Run android update project -p . -n ApiDemos -t X (change X to correct value)
  5. Run ant debug
  6. Run adb install bin/ApiDemos-debug.apk

For Step 6 to succeed you need to connect your device to computer via USB. Make sure you've checked Setting->Applications->Development->USB Debugging. Also you can verify that adb can see your device running adb devices in the terminal.

Now sample project is built and installed on your device.

这篇关于如何开始通过命令行的Andr​​oid示例项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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