Creating Android applications via the command line and Apache Ant

Android projects can be created either with the ADT Plugin for Eclipse or via the command line. This blog entry explains how to do this via the command line.

You find the related command line program “android” in the folder “tools” of your Android SDK installation. Add this folder to your path and run the following command>

android create project --target "Google Inc.:Google APIs:8" --path de.vogella.android.commandline --activity TestActivity --package de.vogella.android.commandline 

I assume except –target all other options are clear. To see potential targets use the command

android list targets 

To compile your program you can use Apache Ant. You need of course to have Ant installed and add it to your path. See Apache Ant Tutorial for this. Afterwards switch into your newly created directory “de.vogella.android.commandline” and type the following to create a development release

ant debug

You can also build a real release, this requires that you setup the “key.store” and “key.alias” properties in build.properties.

ant release

To install it into an running device, e.g. the emulator, use

ant install

You find now the activity “TestActivity” on your virtual device under programs and you can test it.

I hope this help. Enjoy your Android Development.

About Lars Vogel

Lars Vogel is the founder and CEO of the vogella GmbH and works as Eclipse and Android consultant, trainer and book author. He is a regular speaker at international conferences, With more than one million visitors per month his website vogella.com is one of the central sources for Eclipse and Android programming information.
This entry was posted in Android and tagged , , . Bookmark the permalink.