"aapt package" Command - Resource Code Generation

This section describes the 'aapt package' command to perform the resource code generation step in the Android project build process. The main output is the R.java file in the .\gen folder.

Looking at the output of "ant -verbose debug", I have created this "aapt package" command to perform the resource code generation step of the build process. This is how the command works on the HelloAndroid project:

C:\herong\HelloAndroid> 
   \local\android-sdk-windows\build-tools\22.0.1\aapt 
   package -v -f -m -M AndroidManifest.xml -S .\bin\res -S .\res 
   -I C:\local\android-sdk-windows\platforms\android-22\android.jar 
   -J .\gen --generate-dependencies
   
Configurations:
 (default)
 hdpi
 ldpi
 mdpi

Files:
  drawable\ic_launcher.png
    Src: (hdpi) .\res\drawable-hdpi\ic_launcher.png
    Src: (ldpi) .\res\drawable-ldpi\ic_launcher.png
    Src: (mdpi) .\res\drawable-mdpi\ic_launcher.png
  layout\main.xml
    Src: () .\res\layout\main.xml
  values\strings.xml
    Src: () .\res\values\strings.xml
  AndroidManifest.xml
    Src: () AndroidManifest.xml

Resource Dirs:
  Type drawable
    drawable\ic_launcher.png
      Src: (hdpi) .\res\drawable-hdpi\ic_launcher.png
      Src: (ldpi) .\res\drawable-ldpi\ic_launcher.png
      Src: (mdpi) .\res\drawable-mdpi\ic_launcher.png
  Type layout
    layout\main.xml
      Src: () .\res\layout\main.xml
  Type values
    values\strings.xml
      Src: () .\res\values\strings.xml
Including resources from package: \
C:\local\android-sdk-windows\platforms\android-15\android.jar
applyFileOverlay for drawable
trying overlaySet Key=ic_launcher.png
baseFile 0 has flavor ,,,,,,,,,,,hdpi,,,,,,,
baseFile 1 has flavor ,,,,,,,,,,,ldpi,,,,,,,
baseFile 2 has flavor ,,,,,,,,,,,mdpi,,,,,,,
overlayFile 0 has flavor ,,,,,,,,,,,hdpi,,,,,,,
overlayFile 1 has flavor ,,,,,,,,,,,ldpi,,,,,,,
overlayFile 2 has flavor ,,,,,,,,,,,mdpi,,,,,,,
found a match (0) for overlay file ic_launcher.png, \
for flavor ,,,,,,,,,,,hdpi,,,,,,,
found a match (1) for overlay file ic_launcher.png, \
for flavor ,,,,,,,,,,,ldpi,,,,,,,
found a match (2) for overlay file ic_launcher.png, \
for flavor ,,,,,,,,,,,mdpi,,,,,,,
applyFileOverlay for layout
applyFileOverlay for anim
applyFileOverlay for animator
applyFileOverlay for interpolator
applyFileOverlay for xml
applyFileOverlay for raw
applyFileOverlay for color
applyFileOverlay for menu
applyFileOverlay for mipmap
    (new resource id ic_launcher from \
    .\bin\res\drawable-hdpi\ic_launcher.png)
    (new resource id ic_launcher from \
    .\bin\res\drawable-ldpi\ic_launcher.png)
    (new resource id ic_launcher from \
    .\bin\res\drawable-mdpi\ic_launcher.png)
    (new resource id main from .\res\layout\main.xml)
  Writing symbols for class R.

I think my "aapt" package command is working. The main output is the .\gen\com\herongyang\R.java file. What do you think?

Last update: 2015.

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

 Developing First Android Application - HelloAndroid

 Android Application Package (APK) Files

 Android Debug Bridge (adb) Tool

 Android File Systems

 Android 4.0.3 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

 Output of "ant -verbose debug" - Android SDK R17

 "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

 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

 Outdated Tutorials

 References

 PDF Printing Version