Preparations on Using Apache Ant Tool

This section describes how to prepare yourself to use the Apache Ant tool: create proper folder structure; define smaller build steps; put build steps into an Ant build file; implement each build step with Ant commands.

In order to use Apache Ant to help you to build a Java application, you need to prepare the following items:

1. Organize your application files in a nice folder structure. Here is an example:

.\              - Home folder to store all files of the application
.\src           - Source folder to store Java source files
.\build         - Build output folder
.\build\classes - Class folder to store resulting class files
.\build\jar     - JAR folder to store resulting JAR files

2. Divide the build process into smaller steps. Here are some examples of build steps:

clean    - To clean up the build output folder
compile  - To compile all Java source files into class files
jar      - To build the JAR file from class files
run      - To execute the main class from the JAR file

3. Define all build steps in an Ant build file called .\build.xml. The build file is an XML file with the following structure:

    <target name="build_step_1">
    <target name="build_step_2">

4. Implement each build step with Ant commands. Here is an example of implementing the "compile" build step with 3 Ant commands:

    <target name="compile">
        <delete dir="build/classes"/>
        <mkdir dir="build/classes"/>
        <javac srcdir="src" destdir="build/classes"/>

After finishing implementing all build steps in the build file, you are ready to run the Ant tool to build your application. See next tutorial for a simple build file example.

Table of Contents

 About This Book

 Installing JDK 1.8 on Windows System

 Installation of Android SDK R24 and Emulator

Installing Apache Ant 1.9 on Windows System

 Downloading and Installing Apache Ant 1.9

Preparations on Using Apache Ant Tool

 First Apache Ant Build File Example

 Developing First Android Application - HelloAndroid

 Android Application Package (APK) Files

 Android Debug Bridge (adb) Tool

 Android File Systems

 AboutAndroid - Application to Retrieve System Information Class and Activity Lifecycle

 View Objects and Layout Resource Files

 Using "adb logcat" Command for Debugging

 Build Process and Package File Content

 Building Your Own Web Browser

 Android Command Line Shell

 Samsung Galaxy Tab 3 Mini Tablet

 USB Debugging Applications on Samsung Tablet

 Android Tablet - LG-V905R

 USB Debugging Applications on LG-V905R Tablet

 Android Phone - LG-P925g

 USB Debugging Applications on LG-P925g Phone

 Archived Tutorials


 Full Version in PDF/EPUB