Saturday 12 July 2014

how to build an android project in eclipse from command line using ant?


case: to build an android project in eclipse from command line using ant.

Soln:

Before starting I assume you have a running android project in eclipse. Now.

1.  Before even touching ant , first make your project  'ant ready'. To do this:
     Open command line and navigate to <ADT ISTALLATION>/sdk/tools directory.
     Run the command android update project --path <Complete path of your project directory>.
    Doing this will add build.xml file in your project. This file is read by ant during build.
    Do this for all library projects that you have.
    Doing this will make your projects 'ant ready'.
 

2. Now install ant latest version from here and set the relevant environment variables.
   http://ant.apache.org/bindownload.cgi
  If you use an old version of ant then there are chances of conflict with your adt installation.

3. Create a file named ant.properties file in you root folder of main project and specify your keystore          information on it like this:

  key.store=< your keystore file location>    (make sure u use forward slash '/' between folders)
  key.alias=<alias name>
  key.store.password=<store pwd>
   key.alias.password=<alias pwd>

If you dont specify the passwords, it will prompt you during the run and you can enter it on the command line.


4. Navigate to your project root directory in cmd line  and run the command:
       ant release

5. Wait for the build to run. After completion you will see build success in your screen. Go to the bin        directory of your project, you will see your_project_name-release.apk file. The fruit of all your effort.






No comments:

Post a Comment