9 June 2014

Explanation of the directory structure of an Android Project

The directory structure of Android is not considered important by some of the blogs .
But not knowing it is a big blunder . Consider you want to make a application with images and don't know where to store the images .Then what's the use !

Where are the project directories of Android stored ?
  1. Remember you had chosen the workspace while opening your adt or eclipse in one of the previous post
  2.   Just Search for a folder with the name of your Android project (e.g. MyFirstProject ) .
  3. Just open it and you will get the folders like the below screenshot .
location of directory
The directory structure will resemble the below chart .
directory chart
Directory structure of Android Project

1) .settings
       It contains a preferences file which stores the versions of compiler platform, source etc used in eclipse .
The preference file name is org.eclipse.jdt.core.prefs and it contains the following data .
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.source=1.6

The version per user may vary according to the API and rev level of android prefigured in a previous post

2) assets 
  • This are like our properties (By default they are empty) .
  • Files stored here are directly converted to .apk file which is executable in an Android phone.
  •  Usually used to make Game data .

3) bin
It contains folders like classes , dexedLibraries , res and files like AndroidManifest.xml, classes.dex, jarlist.cache, apk file resources.ap_

classes -  It contain the .class files of the java classes that are generated by the system . Class files are made by the java compiler when the .java files are compiled and ready for execution . If you open the class file with help of a TextEditor you will see the bytecode in it which is unreadable by humans .
Location of class file -> classes -> com ->example -> MyFirstProject .
An example of class file is shown below .
class bytecode
Various class files found will be BuildConfig.class, R.class, RLayout.class etc.

dexedLibs - It contains a library named
android-support-v4-2cd46353beaf28f4c082bd7930beb1d3.jar which contains MANIFEST.MF file and the classes.dex file
The MANIFEST.MF contains the manifest versions dex_location and name of the creator (Sun) .

res - it contains icon of our application in various sizes for various devices
  • drawable-hdpi is for device of screen size 4-5 inch
  • drawable-ldpi is for device of screen size 2-3 inch
  • drawable-mdpi is for device of screen size 3-4 inch
  • drawable-xhdpi is for device of screen size greater than 5 inches (Tablets) .
AndroidManifest.xml - It is an xml file which keeps information about various activities (for now consider it as various java classes) and API version , permissions etc.

classes.dex - It is usually a intermidiate file between java file and a apk file . While converting class file to apk file it is converted to dex file in between by the Dalvik Virtual machine .

jarlist.cache - It is like a log file made in a pc. It records various activities going on in the adt .

Apk file - It is a compressed file like a exe file in Windows or .gz file in Linux . It can be directly installed in an Android phone and executed .

resources.ap_ - It contains the resources needed to make the apk file. Usually they are zipped and unreadable .

4) gen
It conatains the system generated java files BuldConfig.java and R.java
Do not change the contents of these files since the contain information  about unique ids associated with every single element used in the application .
Find java files in com -> example -> MyFirstProject  .

5) libs
It contains the same jar file as in bin -> dexedLibs .

6) res
It contains user defined resources, layouts etc to make the application .

drawables -  It is used to store the images used by us to make the application . Usually images used are stored in drawable-hdpi folder .
  • drawable-hdpi is for device of screen size 4-5 inch
  • drawable-ldpi is for device of screen size 2-3 inch
  • drawable-mdpi is for device of screen size 3-4 inch
  • drawable-xhdpi is for device of screen size greater than 5 inches (Tablets) .
layout - It stores the xml files used to design the User Interface of our application . Method associated is onCreate() .

menu - The contents are same as /layout but is used when java method associated with xml is onCreateOptionsMenu() .

values v11 - We can define our customization to various element like button , list etc. in styles.xml found in values folder v11 is used till API 11 .

values v14 - We can define our customization to various element like button , list etc. in styles.xml found in values folder v14 is used from API 11 till API 14.

7) src
It contains java files which we have defined as the backend or buisness logic for our application .
Find java files in com -> example -> MyFirstProject  .

8) .classpath
It contains the path for the entry classes if form of of xml .
The content of the folder bt=y default is :

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
    <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="src" path="gen"/>
    <classpathentry kind="output" path="bin/classes"/>
</classpath>

 
 
9) .project
It contains project related information same as .settings file in xml format . 

10) AndroidManifest.xml
Explained earlier in res folder .

11) ic_launcher-web.png 
Icon for your application. 

12) proguard-project.txt
It is a special feature in Android . it contains tools to guard your apk file against decompilation by adding tricky code to your project to confuse the decompiler.
It also reduces the size of your apk file by removing unused files from your project .
For more information about ProGuard click here

13) project_properties
It is automatically generated and contains the following information to enable proguard and the highest API level which can be used in your project .
Sample properties file.
project properties

Stay Tuned with Made In Android

Previous Page Next Page Home

No comments:

Post a Comment

Top