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 metho开发者_Go百科d 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.
精彩评论