The structure of an Android project

In my notes for the first session on the “Developing Android applications with Java” course, I forgot to mention about the project structure, which Tony (the instructor) explained. So this is a follow-up post to my previous post where I wrote about the notes, which I took during the session.

Android project structure

After you create a new project in eclipse, you will see the following top-level folders in your package explorer.

android-project-structure-1

Let me explain each of them in detail

/srcandroid-project-structure-2

This folder will contain the Java source files that you will be creating. In the screenshot you can see the ‘activity’ files that were created for the sample project. The files inside this  folder will be organized according to the package structure. This is similar to the /src folder which is present in any normal Java project.

/genandroid-project-structure-3

This is also a source folder, but will be contain Java source files that will be automatically generated by the android platform. Notable among the generated Java files is the R class, which you see in the screenshot. The framework will generate R class file and you can read more about it in the android documentation.

/Android {version Number}

This is the folder, which will contain the libraries (jars) that are need for the project. In the screenshot, you can see that it contains the framework jar file. This is similar to the /lib folder which is present in any normal Java project.

/resandroid-project-structure-4

This directory contains all the external resources (images, data files etc) that are used by the android application. These external resources (content) will be referenced in the android application.

This contains the following sub-folders

  • /res/drawable
  • /res/layout
  • /res/Values

/res/drawable

This folder contains all images, pictures etc. If you want to include an image or an icon in your android application, then you will be placing it in this folder.

/res/layout

This folder contains the UI layouts that will be used in the project. These UI layouts are stored as XML files. You can read more about the UI layouts in the android documentation.

/res/Values

This folder again contains XML files, which contain key values pairs that will be referenced in the application. These XML files declare Arrays, colors, dimensions, strings etc. The main idea of having these values in a separate XML file is that the values can be used based on the locale without actually changing the source code. For example the messages in the application can be in different languages based on the use locale.

/assets

This folder also contains external resources used in the application like the /res folder. But the main difference is that the resources are stored in raw format and can be read only programmatically.

AndroidManifest.xml

This is an XML file which contains meta information about the android application and is important file for every android application project. It contains information about various activities, views, services etc. It also contains the list of user permissions that are needed to run the android application.

That explains the project structure of the android application. You can read more about it in the android documentation.

BTW how is your homework coming along? Hope you all were able to finish it quickly. I will be posting the source code for the homework together with the explanation soon. So stay tuned. :)

Update: I have also completed the homework for this session and have posted my source code and explanation.

You can also subscribe to my blog’s RSS feed or follow me in Twitter to receive updates about my notes for the next sessions.

Related posts

Tags: , , ,

6 Comments so far

Follow up comments through RSS Feed | Post a comment

2 Tweetbacks so far

3 Trackbacks/Pingbacks so far

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>