Project Structure

PROJECT STRUCTURE:

When new Android Application created. It use specific directory tree structure showing in eclipse SDK platform .There are Eight key items show in project tree structure as follows

1. AndroidManifest.Xml

2. bulid.xml

3. bin/

4. libs

5. src/

6. res/

7. assests

8. gen

project structure

AndroidManifest.xml :

When creating Android application must have an AndroidManifest.xml file in its root directory. It is an XML file describing the application being built and it contains activity, services, uses permission etc.

When creating a new project automatically generated file in project it contains only single main activity of project.

  • It describes the components of the application‚ the activities, services, broadcast receivers, and content providers that the application is composed of. It names the classes that implement each of the components and publishes their capabilities .These declarations let the Android system know what the components are and under what conditions they can be launched.
  • IN AndroidManifest.xml ¬†uses-permission elements, to indicate what permissions your application will need in order to function properly,

Example

android.permission.CALL_EMERGENCY_NUMBERS
android.permission.READ_CONTACT
android.permission.SET_WALLPAPER.

  • permission elements, to declare permissions that activities or services might require other applications hold in order to use your application’s data or logic ‚
  • instrumentation elements, to indicate code that should be invoked on key system events, such as starting up activities, for the purposes of logging or monitoring
  • uses-library elements, to hook in optional Android components, such as mapping services
  • its declares the minimum level of the Android API that used in applications as well as it declare verion name and version code just like

Example

android:versionCode=“1”

android:minSdkVersion=“3”

android:versionName=“1.0”

Build.Xml:

It is an ANT script for compiling the application and installing on the device.

BIN /:

When you compile your project (via ant or the IDE), the results go into the bin/ directory under your project root.

bin/classes/ holds the compiled Java classes

Bin/classes.dex holds the executable created from those compiled Java classes

bin/nameapp.ap_ holds your application’s resources, packaged as a ZIP file

bin/namedebug.apk or bin/nameapp-unsigned.apk is the actual Android application (where nameap is the name of your application)

The .apk file is a ZIP archive containing the .dex file, the compiled edition of your resources, any un-compiled resources (such as what you put in and the AndroidManifest.xml file. )

SRC/:

It contains all source code file (.java file) of android application. E.g hello_world.java

RES/:

Resources are to store all external contents that used in android applications.

These are external elements that you want to include and reference within your application, like images, audio, video, text strings, layouts, themes, etc.It contains all resources that are used in android application

Root directory:

  1. res/drawable : its contain images ,pictures (png, jpeg etc) e.g. .icon.png
  2. res/layout : contains XML(User Interface) that UI layout used in Project or view window of an application.(E.g. main.xml)
  3. res/Values : it declare Arrays, colors, dimensions, strings, and styles.(E.g. strings.xml)
  4. res/raw : it contains non-complied file (e.g. Audio file .mp3, video file .mpg)

E.g. it create an xml file  in values directory

<?xml version=“1.0” encoding=“utf-8”?>

<resources>

<string name=“hello”>Welcome to Mobisoft Infotech! </string>

<string name=“app_name”>Hello world</string>

</resources>

ASSETS:

Assets it also store an external content refer in android applications. Just like images, audio, video, text strings .It same as resources but different in assets directory will maintain its raw file format and, in order to read it, you must use the AssetManager to read the file as a stream of bytes. So keeping files and data in resources (res/) makes them easily accessible.

libs/:

It’s holds any third-party Java JARs your application Requires.

GEN:

In Eclipse create an application that time auto generated R.java file in gen directory. The R.java file is an index (id) into all the resources defined in the file. This class files use in source code file or it gives for reference or location user interface object that uses in sources code.

Imp Note: Don’t change any code or id (assign value).