Build Android Eclipse Project from Command Line

In this tutorial, I will show you how to build an application APK file from command line.

Generate the Ant Scripts

This needs to be done only once per project. From  the main application project folder, run this command:

~/ADT/sdk/tools/android update project --path .

Where ADT stands for the folder where you have Android ADT extracted. This will create the build.xml file.

If you have any library project, repeat the above step to generate the build.xml file.

Fix File Permission

The version of Ant that ships with Eclipse doesn’t have executable permission enabled. Let’s fix that.

chmod a+x ~/ADT/eclipse/plugins/org.apache.ant_1.8.3.v201301120609/bin/ant

Build the Project

From the main application project folder, run Ant:

~/ADT/eclipse/plugins/org.apache.ant_1.8.3.v201301120609/bin/ant debug

This will create the APK file in the bin/ folder.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s