How-to create an Android Application: Structure I

Article by Jbeer (2,327 pts ) , published Nov 17, 2009

In this article we will find out how to create our own application for android and examine the structure of an Android application.

Creating a new Project

Once we have installed and set out environment as I taught you in the Part I, its time to start working with the environment to create an application for android. We are going to work on Eclipse.

To create a new Android project, we have to access to the "File" menu option. There, click on "New->", if the “Android” option doesn't appear in the selectable screen, you should click on “Other”.

In the next window we have to select the Android project. If it doesn't appear is something wrong with the plugin and SDK installation, back to this article to know how to do it.

We select the “Android” project and click on “Next”.

Here, its important to fill most of the input texts, I will describe them one by one:

  • Project name: This is the project name that will appear in the Eclipse projects column.
  • Contents: In the case we want to create a project from the beginning, we should mark “Create new project in workspace”, if we want to open a existing project we should mark the “Create project from existing source” and set the location of the project source.
  • Properties:

-Package name: this is the standard concept of “package” in Java, here, we set the name of the package which is going to hold the main code.

-Activity name: In Android, nomenclature is quite odd. An Activity is a single screen, in this case, the “Main Screen”.

-Application name: This is the name of the application that is going to appear in the Android emulator or Device.

Once we have filled with the information the input text, click on the "Finish" button.

Program Structure

Once we have created the new project, lets see how is its anatomy.

capture4

As we can see in the image, the project folder (AndroidProyect) holds some folders and files, lets explain them step by step to know what are they and what function they have in our application.

In the “src” folder, we have allocated the source code, ordered in packages (do you remember when we create the project? Here is the package name).

The “Android Library” icon, contains all libraries we need to work with Android. You can have a look at them.

The next important folder is “res”, here is where resources are stored, we can have “drawable” (images), "layouts" (in other article I will explain what a layout is) and "values" (we have the chance of using this to store static values of strings that were are going to use in the app).

The last item is “AndroidManifest.xml”, every Android app has his own AndroidManifest. This is a xml file where all information about the project is stored. From privileges to how to run the app. From now, just put in your mind that this is VIF (Very Important File).

Want to know more?

In the next section I will show you one by one the most important files in the Android application

Follow Up

If you want to know when new articles are released, subscribe yourselft to the Google Android RSS

Otherwise, you can follow my research, articles and work in my profesional twitter: jbeerdev