如何开始通过命令行的Android示例项目? [英] how to start Android example project from command-line?
问题描述
我不喜欢使用Eclipse和希望开始在命令行的例子Android项目,我怎么能做到这一点?有没有办法使用的Android创建项目命令在例如code自动拉从SDK的方法吗?类似的方法或许下面?
Android的创建项目--package com.example.helloandroid \\
--activity HelloAndroid \\
--target 1 \\
--path HelloAndroid
下面是一个例子,如何构建和运行 ApiDemos
示例项目。
- 转到您的SDK文件夹,然后到
../样本/机器人 - #/ ApiDemos
,其中#是API级别。 - 此文件夹中启动终端。
- 运行
安卓列表目标
并找到等于或高于你所选择的东西#在步骤1 API级别目标让我们把这个目标X.在我的情况下,X等于21,它看起来像你的情况X等于1。 - 运行
Android的更新项目-p。 -n ApiDemos -t X
(x更改为正确的) - 运行
蚂蚁调试
- 运行
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.
- Go to your SDK folder, then to
../samples/android-#/ApiDemos
, where # is API Level. - Start terminal in this folder.
- 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. - Run
android update project -p . -n ApiDemos -t X
(change X to correct value) - Run
ant debug
- 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.
这篇关于如何开始通过命令行的Android示例项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!