Android Tutorials - Herong's Tutorial Examples
∟Build Process and Package File Content
∟Android Project Folder Structure
This section describes the Android project folder structure, which has a source folder, a resource folder, a generated-code folder, and a binary folder.
In this tutorial, let's look at the Android application project folder structure using the HelloAndroid application
as an example. If you have not created the project yet, run the following command now:
C:\herong>\local\android-sdk-windows\tools\android create project \
-k com.herongyang -a HelloAndroid -t 2 -p .\HelloAndroid
Now open the project folder \herong\HelloAndroid using the "dir /s \herong\HelloAndroid" command.
You will see the following folder structure:
C:\herong\HelloAndroid
AndroidManifest.xml
ant.properties
bin - Binary folder to hold build output
build.prop
classes - Binary class files
com
herongyang
BuildConfig.class
HelloAndroid.class
R$attr.class
R$drawable.class
R$layout.class - Layout resource file
R$string.class
R.class
classes.dex
classes.dex.d
HelloAndroid-debug-unaligned.apk
HelloAndroid-debug-unaligned.apk.d
HelloAndroid-debug.apk
HelloAndroid.ap_
HelloAndroid.ap_.d
jarlist.cache
res
drawable-hdpi - High resolution icon
ic_launcher.png
drawable-ldpi - Low resolution icon
ic_launcher.png
drawable-mdpi - Medium resolution icon
ic_launcher.png
build.xml
gen
com
herongyang
BuildConfig.java
R.java
libs - Empty folder
local.properties
proguard-project.txt
project.properties
res
drawable-hdpi - High resolution icon
ic_launcher.png
drawable-ldpi - Low resolution icon
ic_launcher.png
drawable-mdpi - Medium resolution icon
ic_launcher.png
layout - Layout resource files
main.xml
values
strings.xml - String resource file
src
com
herongyang
HelloAndroid.java
Some detailed explanations of key folders and files in an Android project folder structure based on the Android document:
- .\src\ - The source folder which contains your stub Activity file, which is
stored at src/your/package/namespace/ActivityName.java.
All other source code files (such as .java or .aidl files) go here as well.
- .\bin\ - The binary folder which contains output files of the build process.
This is where you can find the final .apk file and other compiled resources.
- .\jni\ - The JNI (Java Native Interface) folder which contains native code sources developed
using the Android NDK (Native Development Kit). You will not have this folder, if you don't have any native code.
- .\gen\ - The generated-code folder which contains Java source files generated by ADT (Android Developer Tools),
such as your R.java file and interfaces created from AIDL files.
- .\assets\ - The asset folder which constrain raw asset files.
Files that you save here are compiled into an .apk file as-is, and the original filename is preserved.
You can navigate this directory in the same way as a typical file system using URIs and read files
as a stream of bytes using the the AssetManager.
For example, this is a good location for textures and game data.
- .\res\ - The resource folder which contains application resources,
such as drawable files, layout files, and string values.
- .\res\anim\ - The animation resource folder which contains resource XML files that are compiled into animation objects.
- .\res\color\ - The color resource folder which contains resource XML files that describe colors.
- .\res\drawable\ - The drawable resource folder which contains bitmap files (PNG, JPEG, or GIF), 9-Patch image files,
and XML files that describe Drawable shapes or a Drawable objects that contain multiple states (normal, pressed, or focused).
- .\res\layout\ - The layout resource folder which contains XML files that are compiled into screen layouts (or part of a screen).
- .\res\menu\ - The menu resource folder which contains XML files that define application menus.
- .\res\raw\ - The raw resource folder which contains arbitrary raw asset files.
Saving asset files here instead of in the assets/ directory only differs in the way that you access them.
These files are processed by aapt and must be referenced from the application using a resource identifier in the R class.
For example, this is a good place for media, such as MP3 or Ogg files.
- .\res\values\ - The value resource folder that contains XML files that are compiled into many kinds of resource.
Unlike other resources in the res/ directory, resources written to XML files in this folder are not referenced
by the file name. Instead, the XML element type controls how the resources is defined within them are placed
into the R class.
- .\res\xml\ - The XML resource folder which contains miscellaneous XML files that configure application components.
For example, an XML file that defines a PreferenceScreen, AppWidgetProviderInfo, or Searchability Metadata.
- .\libs\ - The library folder which contains private external libraries.
- .\AndroidManifest.xml - The project manifest file that describes the nature of the application and each of its components.
For instance, it describes: certain qualities about the activities, services, intent receivers, and content providers;
what permissions are requested; what external libraries are needed; what device features are required,
what API Levels are supported or required; and others.
- .\project.properties - The project properties files which contains project settings, such as the build target.
This file is integral to the project, so maintain it in a source revision control system.
To edit project properties in Eclipse, right-click the project folder and select Properties.
- .\local.properties - The local properties file which contains customizable computer-specific properties
for the build system. If you use Ant to build the project, this contains the path to the SDK installation.
Because the content of the file is specific to the local installation of the SDK, the local.properties should
not be maintained in a source revision control system. If you use Eclipse, this file is not used.
- .\ant.properties - The Ant properties file which contains customizable properties for the build system.
You can edit this file to override default build settings used by Ant and also provide the location
of your keystore and key alias so that the build tools can sign your application when building in release mode.
This file is integral to the project, so maintain it in a source revision control system.
If you use Eclipse, this file is not used.
- .\build.xml - The Ant build file for your project. This is only applicable for projects that you build with Ant.
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
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
Archived Tutorials
References
Full Version in PDF/EPUB