Root Contents
When you create a new Android project (e.g., via the activitycreator script, or an Android-enabled IDE), you get several items in the project’s root directory:
• AndroidManifest.xml, an XML file describing the application being built and what components—activities, services, etc.—are being supplied by that application
• build.xml, an Ant1 script for compiling the application and installing it on the device
• default.properties, a property file used by the Ant build script
• bin/ holds the application once it is compiled
• libs/ holds any third-party Java JARs your application requires
• src/ holds the Java source code for the application
• res/ holds resources, such as icons, GUI layouts, and the like, that get packaged with the compiled Java in the application
• assets/ holds other static files you wish packaged with the application for deployment onto the device.
You should know full anatomy of the android application if you want to know how applications are developed in Android.
The Sweat of Your Brow
When you create an Android project (e.g., via activitycreator), you supply the fully-qualified class name of the “main” activity for the application (e.g., com.commonsware.android.SomeDemo).
You will then find that your project’s src/ tree already has the namespace directory tree in place, plus a stub Activity subclass representing your main activity (e.g., src/com/commonsware/android/SomeDemo.java). You are welcome to modify this file and add others to the src/ tree as needed to implement your application.
The first time you compile the project (e.g., via ant), out in the “main” activity’s namespace directory, the Android build chain will create R.java. This contains a number of constants tied to the various resources you placed out in the res/ directory tree. You should not modify R.java yourself, letting the Android tools handle it for you. You will see throughout many of the samples where we reference things in R.java (e.g., referring to a layout’s identifier via R.layout.main).
The Rest of the Story
As already mentioned, the res/ directory tree holds resources—static files that are packaged along with your application, either in their original form or, occasionally, in a preprocessed form. Some of the subdirectories you will find or create under res/ include
• res/drawable/ for images (PNG, JPEG, etc.)
• res/layout/ for XML-based UI layout specifications
• res/menu/ for XML-based menu specifications
• res/raw/ for general-purpose files (e.g., a CSV file of account information)
• res/values/ for strings, dimensions, and the like
• res/xml/ for other general-purpose XML files you wish to ship
What You Get Out of It
When you compile your project (via ant or the IDE), the results go into the bin/ directory under your project root, specifically:
• bin/classes/ holds the compiled Java classes
• bin/classes.dex holds the executable created from those compiled Java classes
• bin/yourapp.ap_ holds your application’s resources, packaged as a ZIP file (where yourapp is the name of your application)
• bin/yourapp-debug.apk or bin/yourapp-unsigned.apk is the actual Android application (where yourapp is the name of your application)
The .apk file is a ZIP archive containing the .dex file, the compiled edition of your resources (resources.arsc), any un-compiled resources (such as what you put in res/raw/) and the AndroidManifest.xml file. It is also digitally signed, with the -debug portion of the filename indicating it has been signed using a debug key that works with the emulator, or –unsigned indicating that you built your application for release (ant release), but the APK still needs to be signed using jarsigner and an official key.
The great flexibility of the androids are they are customizable
0 comments