Android Tutorials - Herong's Tutorial Examples
Dr. Herong Yang, Version 2.1

Detailed Output of "ant -verbose debug" Command

This section describes the output of the 'ant -verbose debug' command, which provides more details how each of 'aidl', 'aapt', 'javac', 'dex', 'apkbuilder' and 'zipalign' tools are invoked in the Ant build process.

Looking at the default output of the "ant debug" command, we get the idea of what development tools are used in the Ant build file to finish the full build process of an Android project. But if you want to know how those tools are invoked, you need to use the "-verbose" option to see more details.

Let's remove all generated by the previous build process and run "ant -verbose debug" command on the HelloAndroid project:

C:\herong\HelloAndroid>\local\apache-ant-1.8.3\bin\ant all clean

C:\herong\HelloAndroid>\local\apache-ant-1.8.3\bin\ant -verbose debug

Apache Ant(TM) version 1.8.3 compiled on February 26 2012
Trying the default build file: build.xml
Buildfile: C:\herong\HelloAndroid\build.xml
Detected Java version: 1.7 in: C:\Progra~1\Java\jdk1.7.0_03\jr
Detected OS: Windows 7
parsing buildfile C:\herong\HelloAndroid\build.xml with URI = file...
Project base dir set to: C:\herong\HelloAndroid
parsing buildfile jar:file:/C:/local/apache-ant-1.8.3/lib/ant.jar!...
 [property] Loading C:\herong\HelloAndroid\local.properties
 [property] Loading C:\herong\HelloAndroid\ant.properties
Importing file C:\herong\HelloAndroid\custom_rules.xml from C:\her...
Cannot find C:\herong\HelloAndroid\custom_rules.xml imported from ...
Importing file C:\local\android-sdk-windows\tools\ant\build.xml fr...
Overriding previous definition of reference to ant.projectHelper
parsing buildfile C:\local\android-sdk-windows\tools\ant\build.xml...
Property "key.store" has not been set
 [macrodef] creating macro  do-only-if-not-library
 [macrodef] creating macro  do-only-if-manifest-hasCode
 [macrodef] creating macro  dex-helper
 [macrodef] creating macro  package-helper
 [macrodef] creating macro  zipalign-helper
 [macrodef] creating macro  run-tests-helper
 [macrodef] creating macro  record-build-key
 [macrodef] creating macro  record-build-info
 [macrodef] creating macro  uninstall-helper
Overriding previous definition of reference to ant.projectHelper
Build sequence for target(s) `debug' is [-set-mode-check, -set-deb...
Complete build sequence is [-set-mode-check, -set-debug-files, -se...

-set-mode-check:

-set-debug-files:

-set-debug-mode:

-debug-obfuscation-check:

-setup:
     [echo] Creating output directories if needed...
    [mkdir] Skipping C:\herong\HelloAndroid\res because it already...
    [mkdir] Skipping C:\herong\HelloAndroid\libs because it alread...
    [mkdir] Created dir: C:\herong\HelloAndroid\bin
    [mkdir] Created dir: C:\herong\HelloAndroid\bin\res
     [echo] Gathering info for HelloAndroid...
    [setup] Android SDK Tools Revision 17
    [setup] Project Target: Google APIs
    [setup] Vendor: Google Inc.
    [setup] Platform Version: 4.0.3
    [setup] API level: 15
    [setup] 
    [setup] ------------------
    [setup] Resolving library dependencies:
    [setup] No library dependencies.
    [setup] 
    [setup] ------------------
    [setup] API<=15: Adding annotations.jar to the classpath.
    [setup] 
    [setup] ------------------
    [setup] WARNING: No minSdkVersion value set. Application will ...

-build-setup:
 [property] Loading C:\herong\HelloAndroid\bin\build.prop
 [property] Unable to find property file: C:\herong\HelloAndroid\b...
    [mkdir] Created dir: C:\herong\HelloAndroid\gen
    [mkdir] Created dir: C:\herong\HelloAndroid\bin\classes

-pre-build:

-code-gen:
     [echo] ----------
     [echo] Handling aidl files...
     [aidl] No AIDL files to compile.
     [echo] ----------
     [echo] Handling RenderScript files...
[renderscript] No RenderScript files to compile.
     [echo] ----------
     [echo] Handling Resources...
Property "android.library" has not been set
     [aapt] Generating resource IDs...
     [aapt] Current OS is Windows 7
     [aapt] Executing \
'C:\local\android-sdk-windows\platform-tools\aapt.exe' with arguments:
     [aapt] 'package'
     [aapt] '-f'
     [aapt] '-m'
     [aapt] '-M'
     [aapt] 'C:\herong\HelloAndroid\AndroidManifest.xml'
     [aapt] '-S'
     [aapt] 'C:\herong\HelloAndroid\bin\res'
     [aapt] '-S'
     [aapt] 'C:\herong\HelloAndroid\res'
     [aapt] '-I'
     [aapt] \
'C:\local\android-sdk-windows\platforms\android-15\android.jar'
     [aapt] '-J'
     [aapt] 'C:\herong\HelloAndroid\gen'
     [aapt] '--generate-dependencies'
     [aapt] 
     [aapt] The ' characters around the executable and arguments are
     [aapt] not part of the command.
     [echo] ----------
     [echo] Handling BuildConfig class...
[buildconfig] Generating BuildConfig class.

-pre-compile:

-compile:
Property "tested.project.absolute.dir" has not been set
Property "tested.project.absolute.dir" has not been set
    [javac] com\herongyang\HelloAndroid.java added as com\herongya...
    [javac] C:\herong\HelloAndroid\gen\R.java.d skipped - don't kn...
    [javac] com\herongyang\BuildConfig.java added as com\herongyan...
    [javac] com\herongyang\R.java added as com\herongyang\R.class ...
    [javac] Compiling 3 source files to \
C:\herong\HelloAndroid\bin\classes
    [javac] Using modern compiler
    [javac] Compilation arguments:
    [javac] '-d'
    [javac] 'C:\herong\HelloAndroid\bin\classes'
    [javac] '-classpath'
    [javac] 'C:\herong\HelloAndroid\bin\classes; \
C:\herong\HelloAndroid; \
C:\local\android-sdk-windows\tools\support\annotations.jar'
    [javac] '-sourcepath'
    [javac] 'C:\herong\HelloAndroid\src;C:\herong\HelloAndroid\gen'
    [javac] '-target'
    [javac] '1.5'
    [javac] '-bootclasspath'
    [javac] 'C:\local\android-sdk-windows\platforms\android-15\and...
    [javac] '-encoding'
    [javac] 'UTF-8'
    [javac] '-g'
    [javac] '-source'
    [javac] '1.5'
    [javac] 
    [javac] The ' characters around the executable and arguments are
    [javac] not part of the command.
    [javac] Files to be compiled:
    [javac] \herong\HelloAndroid\src\com\herongyang\HelloAndroid.java
    [javac] \herong\HelloAndroid\gen\com\herongyang\BuildConfig.java
    [javac] \herong\HelloAndroid\gen\com\herongyang\R.java

-post-compile:

-obfuscate:

-dex:
[dex] Converting compiled files and external libraries into \
C:\herong\HelloAndroid\bin\classes.dex...
 [dx] Current OS is Windows 7
 [dx] Executing \
'C:\local\android-sdk-windows\platform-tools\dx.bat' with arguments:
 [dx] '--dex'
 [dx] '--output'
 [dx] 'C:\herong\HelloAndroid\bin\classes.dex'
 [dx] 'C:\herong\HelloAndroid\bin\classes'
 [dx] 'C:\local\android-sdk-windows\tools\support\annotations.jar'
 [dx] 
 [dx] The ' characters around the executable and arguments are
 [dx] not part of the command.

-crunch:
   [crunch] Current OS is Windows 7
   [crunch] Executing \
'C:\local\android-sdk-windows\platform-tools\aapt.exe' with arguments:
   [crunch] 'crunch'
   [crunch] '-v'
   [crunch] '-S'
   [crunch] 'C:\herong\HelloAndroid\res'
   [crunch] '-C'
   [crunch] 'C:\herong\HelloAndroid\bin\res'
   [crunch] 
   [crunch] The ' characters around the executable and arguments are
   [crunch] not part of the command.
   [crunch] Crunching PNG Files in source dir: \
C:\herong\HelloAndroid\res
   [crunch] To destination dir: C:\herong\HelloAndroid\bin\res
   [crunch] Processing image to cache: \
C:\herong\HelloAndroid\res\drawable-hdpi\ic_launcher.png => \
C:\herong\HelloAndroid\bin\res\drawable-hdpi\ic_launcher.png
   [crunch]   (processed image to cache entry C:\herong\HelloAndro...
   [crunch] Processing image to cache: \
C:\herong\HelloAndroid\res\drawable-ldpi\ic_launcher.png => \
C:\herong\HelloAndroid\bin\res\drawable-ldpi\ic_launcher.png
   [crunch]   (processed image to cache entry C:\herong\HelloAndro...
   [crunch] Processing image to cache: \
C:\herong\HelloAndroid\res\drawable-mdpi\ic_launcher.png => \
C:\herong\HelloAndroid\bin\res\drawable-mdpi\ic_launcher.png
   [crunch]   (processed image to cache entry C:\herong\HelloAndro...
   [crunch] Crunched 3 PNG files to update cache

-package-resources:
[aapt] Creating full resource package...
[aapt] Current OS is Windows 7
[aapt] Executing \
'C:\local\android-sdk-windows\platform-tools\aapt.exe' with arguments:
[aapt] 'package'
[aapt] '--no-crunch'
[aapt] '-f'
[aapt] '--debug-mode'
[aapt] '-M'
[aapt] 'C:\herong\HelloAndroid\AndroidManifest.xml'
[aapt] '-S'
[aapt] 'C:\herong\HelloAndroid\bin\res'
[aapt] '-S'
[aapt] 'C:\herong\HelloAndroid\res'
[aapt] '-I'
[aapt] 'C:\local\android-sdk-windows\platforms\android-15\android.jar'
[aapt] '-F'
[aapt] 'C:\herong\HelloAndroid\bin\HelloAndroid.ap_'
[aapt] '--generate-dependencies'
[aapt] 
[aapt] The ' characters around the executable and arguments are
[aapt] not part of the command.

-package:
[apkbuilder] Current build type is different than previous build: \
forced apkbuilder run.
[apkbuilder] Creating HelloAndroid-debug-unaligned.apk and signing \
it with a debug key...

-post-package:

-do-debug:
 [zipalign] Running zip align on final apk...
[zip-align] Current OS is Windows 7
[zip-align] Executing \
'C:\local\android-sdk-windows\tools\zipalign.exe' with arguments:
[zip-align] '-f'
[zip-align] '4'
[zip-align] \
'C:\herong\HelloAndroid\bin\HelloAndroid-debug-unaligned.apk'
[zip-align] 'C:\herong\HelloAndroid\bin\HelloAndroid-debug.apk'
[zip-align] 
[zip-align] The ' characters around the executable and arguments are
[zip-align] not part of the command.
     [echo] Debug Package: \
C:\herong\HelloAndroid\bin\HelloAndroid-debug.apk
[propertyfile] Creating new property file: \
C:\herong\HelloAndroid\bin\build.prop
[propertyfile] Updating property file: \
C:\herong\HelloAndroid\bin\build.prop
[propertyfile] Updating property file: \
C:\herong\HelloAndroid\bin\build.prop
[propertyfile] Updating property file: \
C:\herong\HelloAndroid\bin\build.prop

-post-build:

debug:

BUILD SUCCESSFUL
Total time: 4 seconds

Wow! I can see more useful information in the output now:

  • "aapt package" command is used in the resource code generation step. Command options and arguments are clearly printed out in the output. We can actually try it ourself without use "ant".
  • Command options and arguments of "javac" command are also printed in the output for the Java compilation step.
  • The "dex" tool is actually invoked from the dx.bat batch file for the byte code conversion step.
  • The "aapt crunch" tool is actually used in the packaging step.
  • There are no details about the "apkbuilder" in package signing step.
  • Command options and arguments of "zipalign" command are also printed in the output for the package optimization step.

In next tutorials, I will try to run those "aapt", "javac", "dex", "apkbuilder" and "zipalign" tools without using "ant".

Last update: 2012.

Table of Contents

 About This Book

 Installation of Android SDK R17 and Emulator

 Installing JDK 1.7 on Windows System

 Installing Apache Ant 1.8 on Windows System

 Developing First Android Application - HelloAndroid

 Android Application Package (APK) Files

 Android Debug Bridge (adb) Tool

 Android File Systems

 AboutAndroid - Application to Retrieve System Information

 android.app.Activity Class and Activity Lifecycle

 View Objects and Layout Resource Files

 Using "adb logcat" Command for Debugging

Build Process and Package File Content

 "android create project" Command Options

 Android Project Folder Structure

 Android Application Project Build Process

 Project Build Process Done by "ant debug" Command

Detailed Output of "ant -verbose debug" Command

 "aapt" - Android Asset Packaging Tool

 "aapt package" Command - Resource Code Generation

 "javac" - Java Compilation Command

 "dx.bat --dex" Command - Converting .class Files into .dex File

 "apkbuilder" Command - Packaging and Signing .apk File

 "zipalign" Command - Aligning File Locations in .apk Package

 "aapt dump" Command - Printing Contents of .apk Package

 META-INF Files - Digests, Signature and Certificate

 Building Your Own Web Browser

 Android Command Line Shell

 Android Phone - LG-P925g

 USB Debugging Applications on LG-P925g Phone

 Android Tablet - LG-V905R

 USB Debugging Applications on LG-V905R Tablet

 References

 PDF Printing Version

Dr. Herong Yang, updated in 2012
Build Process and Package File Content