How to Create an Android Application: Structure I

Written by:  • Edited by: Simon Hill
Updated Mar 3, 2011
• Related Guides: Android | Libraries

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

Creating a New Project

Once we have installed and set out the environment as I explained in the How to set up Eclipse to work in Android article, it's 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 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 then something is wrong with the plugin and SDK installation, go back to this article to learn how to do it.

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

Here, it's important to fill out 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: If we want to create a project from the beginning, we should mark “Create new project in workspace”, if we want to open an 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 out the information, click on the "Finish" button.

Program Structure

Once we have created the new project, let's see how it looks.

capture4
click to enlarge

As we can see in the image, the project folder (AndroidProyect) holds some folders and files, let's explain them step by step so we 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 created the project? The package name is here).

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”, this is where resources are stored, we can have “drawable” (images), "layouts" (in another article I will explain How to Work With Android Layouts) and "values" (we have the chance of using this to store static values of strings that we are going to use in the app).

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

Want to know more?

In the next article I will show you one by one the most important files in the Android application - How Do I Develop an Android Application? Structure II.

Follow Up

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

Otherwise, you can follow my research, articles and work in my professional Twitter: jbeerdev


Comments

Showing all 17 comments
 
Anna Mar 30, 2011 2:51 PM
RE: How to Create an Android Application: Structure I
Thanks Jbeerdev. I did a lot of trial and error today and finally succeeded, don't remember which configurations worked now. It took just...50 minutes for AVD to start working :) Will switch to a laptop in the nearest future.
Jbeerdev Mar 30, 2011 3:43 AM
RE: How to Create an Android Application: Structure I
Hi Anna.

I had very bad experiences with neetbooks... I could hardly make the emulator run, so develop without a real device was very painful. Try working with a more powerful machine... Android emulator consumes lot of resources.
Anna Mar 29, 2011 1:27 PM
How to Create an Android Application: Structure I
Hi Jbeerdev

I'be got the same problem as Sri had, and as far as there is no answer here, would like to ask again. When I try to run the AVD, the emulated device appears but it just sits
blinking ANDROID in a fancy font and never becomes usable

Is it a problem with a netbook?
Jbeerdev May 30, 2010 9:45 AM
RE: How to Create an Android Application: Structure I
Hi Sri.

What can you see in the Log of eclipse? Any error?
Sri May 28, 2010 12:19 AM
Not able to view output on Emulator.
Hi, I am trying use Android SDK on my Netbook, IDE Eclipse Galileo,
I am able to execute the program, but was not able to see the result in the emulator.
It is taking ages, i waited for almost 30 min still it didnot come.
Intel 270 N Atom processor, 1.66 Ghz , 1GB Ram, Windows Vista OS
nagaraju May 9, 2010 1:46 PM
I have the same problem with build target
cud any one help me pls with this prob?
Jbeerdev Mar 12, 2010 3:05 AM
RE: How to Create an Android Application: Structure I
Hi Jack

I understand you, sometimes I have problems like that in my own netbook. Hope you could install the SDK properly!
Jack Hauer Mar 11, 2010 3:14 PM
Android SDK limitation
Just wanted to pass along the solution to my dilemma regarding choosing an SDK Build in the Android Project Creation screen. I was not able to choose a build number. Turns out that if you are using a vertically challenged screen (a netbook) the center of that screen is hidden. Thus not giving the option to choose a build number. My work around was to change resolution temporarily to create the project. I know it's crazy but I like using the netbook for this kind of thing.
Jack Hauer Mar 11, 2010 8:13 AM
Still no droid love
Thanks for the tip. Still no love. I've tried reinstalling Android SDK according to your newer tutorial, but no help. I still get an empty box in the 'Build Target' area of the Android project creation screen and a msg that a build target must be specified. I'm using XP, do you think that could be an issue?
Jbeerdev Mar 11, 2010 2:58 AM
RE: How to Create an Android Application: Structure I
Hi Jack

Try this tutorial I have created:

http://www.brighthub.com/mobile/google-android/articles/62261.aspx

Some things have changed since I wrote those articles.
Jack Hauer Mar 10, 2010 8:27 PM
Newbie blues
I'm also having the issue of "An SDK Target must be specified". I've run the setup in the Android SDK but still no love. Any suggestions?
Cooper Clauson Dec 18, 2009 5:03 PM
Thank you
Just noticed your responses. Thanks so much!

Cooper
Jbeerdev Dec 18, 2009 2:35 AM
RE: How to Create an Android Application: Structure I
Thats it. This is a new feature in the new SDK. Older ones were just download-and-plug.
Cooper Clauson Dec 17, 2009 10:15 PM
Solved
I figured out the problem.

When the SDK is first installed, it doesn't come with platforms (the "platforms" folder will be empty). You have to run setup to install these.
Jbeerdev Dec 17, 2009 6:45 AM
RE: How to Create an Android Application: Structure I
Do you have the latest version of the SDK in Android? In the last version you have to install the SDK version you want to work in. Go to your SDK version and have a look to an executable. There you can install the "real" SDK (because now you have just like an installer).

I have to explain about the new way to install the SDK in next article.
Cooper Clauson Dec 17, 2009 6:35 AM
Problem with procedure
This isn't going smoothly for me. Basically, even after I do the Windows > Preferences thing and add the SDK, I still get an "An SDK Target must be specified" when I try to create a new project. A Google search revealed that I'm not the only one to have this problem:

http://androidforums.com/android-developers/11432-new-project-sdk-target-must-specified.html

I've tried a few versions of Eclipse (Europa and Galileo) and still no luck. Frustrating...
Cooper Clauson Dec 17, 2009 6:34 AM
Problem with procedure
This isn't going smoothly for me. Basically, even after I do the Windows > Preferences thing and add the SDK, I still get an "An SDK Target must be specified" when I try to create a new project. A Google search revealed that I'm not the only one to have this problem:

http://androidforums.com/android-developers/11432-new-project-sdk-target-must-specified.html

I've tried a few versions of Eclipse (Europa and Galileo) and still no luck. Frustrating...
 
blog comments powered by Disqus
Email to a friend