Thursday, 13 November 2014

Android Project Structure

Any Android project contain things such as application source code and resource files. Some are generated for you by default, while others should be created if required. Lets have a look at android eclipse project directory structure below :


 Src :

           The src folder contains the Java source code files of your application organized into packages. You can have more than one package in your Android application. Its always a good practice to break the source code of your application into different packages based on its core functionality.  All the source files of your Activities, Services etc. Goes into this folder. In the above screen, you can see the source file of the Activity that we created for our project.


Gen :

         The files in the gen folder are automatically generated by the ADT. Here the R.java file contains reference/id's  to all the resources in the res we use in our program. Each time we add a new resource to the project, ADT will automatically regenerate the R.java file containing reference to the newly added resource. You should not edit the contents of R.java file manually or otherwise your application may not compile.


ANDROID <version number> :

              This folder is also called Android target library in Android project structure. The version number will be  same as the build target version that we choose while creating a new project. The android.jar file contains all the essential libraries required for our program.

ASSETS

             The assets folder is used to store raw asset files. You can keep any raw data in the assets folder and there’s an asset manager in Android to read the data stored in the folder. The raw data can be anything such as audio, video, images etc. On important point about assets folder is that the data stored in this folder can’t be referenced by an ID. To access a data in this folder, we have to work with bits and bytes.

BIN :

      Bin folder is where our compiled application files go. When we successfully compile an application, this folder will contain java class files, dex files which are executable under Dalvik virtual machine, apk archives etc.

RES :

         Res folder is where we store all our external resources for our applications such as images, layout XML files, strings, animations, audio files etc.

Sub folders:

res/drawable

This folder contains the bitmap file to be used in the program. There are three different folders to store drawables. They are drawable-ldpi, drawable-mdpi, drawable-hdpi. The folders are to provide alternative image resources to specific screen configurations. Ldpi, mdpi & hdpi stands for low density, medium density & high density screens respectively. The resources for each screen resolutions are stored in respective folders and the android system will choose it according to the pixel density of the device.

res/layout

XML files that defines the User Interface goes in this folder.

res/values

XML files that define simple values such as strings, arrays, integers, dimensions, colors, styles etc. are placed in this folder.

res/menu

XML files that define menus in your application goes in this folder.

ANDROID MANIFEST FILE :

          AndroidManifest.xml is one of the most important file in the Android project structure. It contains all the information about your application. When an application is launched, the first file the system seeks is the AndroidManifest file. It actually works as a road map of your application, for the system.

              The Android Manifest file contains information about:

                               Components of your application such as Activities, services etc.
                               User permissions required
                               Minimum level of Android API required

IC_LAUNCHER-WEB.PNG :

             This is an icon to be used in Google play. Applications on Google Play require a high fidelity version of the application icon. It is not used in your actual app or the launcher, so it is not packaged in the APK.. The specifications for the high-resolution icon are:
32-bit PNG with an alpha channel
512 x 512 pixels
Maximum size of 1024KB

PROGUARD-PROJECT.TXT :

            Everything in the proguard-project.txt file will be in commented out state, because in general most people don't have any project specific needs, just to run ProGuard tool with standard settings.
The ProGuard tool shrinks, optimizes, and obfuscates your code by removing unused code and renaming classes, fields, and methods with semantically obscure names. The result is a smaller sized .apk file that is more difficult to reverse engineer.

PROJECT.PROPERTIES :

             Project.properties is the main project’s properties file containing information such as the build platform target and the library dependencies has been renamed from default.properties in older SDK versions. This file is integral to the project.


No comments:

Post a Comment