Command-line Android

We often use Eclipse for Android programming. Of-course creating an Android project is simple and easy for a beginner and advance user using Eclipse. Eclipse creates a file hierarchy needed for an Android project. Also building and running an apk is even simpler. But for those who don’t want to switch to GUI or who want to stick to the terminal for Android programming, read on ..

Creating an Android project

Provided you have an android-sdk in your path.


android create project \
    --name project-name \
    --target target-API \
    --path path-to-your-project \
    --package package-name \
    --activity name-of-your-main-activity


android create project \
    --name HelloAndroid \
    --target android-15 \
    --path . \
    --package \
    --activity MainActivity

Building an apk

Building an apk is also simple, type

android update project --path . --target android-15 --subprojects

which will create a necessary build.xml file required for ant, and run

ant debug

this will create an unsigned-debug apk inside the bin directory of your project.

Testing your app

Starting emulator

Start the AVD using,


emulator -avd name-of-your-avd


emulator -avd test

If you want to list all your virtual disks, type

android list avd

Installing an apk

To install an apk, visit your project directory and run


adb install path-to-your-apk


adb install bin/

Launching your app

To test your app, type


adb shell am start -a android.intent.action.MAIN -n your-package-name/.your-main-activity-name


adb shell am start -a android.intent.action.MAIN -n