How to understand the AndroidManifest.xml file in your Android Programming Environment

Article by Jbeer (2,327 pts ) , published Aug 13, 2009

In this article we will try to understand a bit more about the meaning and the why's of the lines we put in the AndroidManifest.xml file, in our Android project.

Introduction

In many of the articles I have written, the AndroidManifest.xml file has appeared in some way. Well, its a very important part of the Android application, so I'm going to gather all the information and experience I have to write about “The Manifest”.

When you create a new android application in your favorite IDE ( better using Eclipse for now, in other articles I will write about how to configure other IDE to work with Android), you will the AndroidManifest.xml in our project folder. It's automatically generated by Eclipse, so we don't have to bother about creating it by ourselves. Lets have a look to the file, inside of it, you will find something that looks like this:

AndroidManifest

As the main element we have the “manifest” tag, then, inside of it we have other elements, like “application”, “uses-sdk” and “uses-permision”.

This is the most simple AndroidManifest file you will find, in larger applications, this file could have lots of code lines, we will see why.

The AndroidManifest file is the configuration file of our application, here we set the Activities we are going to use (and how are they going to be used), the services we are going to set up in the Application, the version of the SDK we are using (this is a new feature in the 1.5 Cupcake version), and which are the permissions the application needs to make it work.

These are the most important elements, in my point of view, of the AndroidManifest file. There are lots more, but for now, we will focus on these 3:

Application, Permissions and Version

Application

The tag <application> is contained inside the “root” xml element: <manifest>. Here, using some attributes, we can define some parameters of the Android application. Lets have a look at some of them:

android:icon="drawable resource" → We can set the icon of the application. This will be shown when you install it in your Android device.

android:name="string" → This attribute is to put a name to our Android application, this string, will appear with the icon above when you install it in a device.

android:theme="resource or theme" → We can create a general theme, and use it in all application. In other article we will see how to create themes.

There are more attributes inside of this element, if you are interested you can check google Android Manifest information. Inside the <application> tag, we can have more elements like:

activity, service, provider...

I would like to explain a bit deeper what attributes can be used in this elements, but it will be done in next article. For now, just take in mind that every new Activity, Service or Content Provider we create in our application, have to be put here. If not, application wont recognize it.

Permissions

Inside the <manifest> tag we can have the <users-permission> tag. This is used to define the features the application need to access and the user need to grant:

-Recieve SMS

-Take pictures from the camera

-Making calls

-Accessing internet...

When you install an app from the market, some of them have a “Permisions” list, where the user, have to “grant” or accept them all if you want the application installed in your device.

About the tag <persmission>, I will write about it in further articles.

Version

In the <uses-sdk> tag, we are defining with which SDK the application is created, so, we can set a backward compatibility. Remember that the API “levels” are:

1.5 → API Level 3

1.1 → API Level 2

1.0 → API Level 1

Here we define the “minimum API level defined to make the app work properly”. A level 2 API Application will work in a 1.5 device but not in a 1.0 device (Obvious!)

Want more?

Those are some of the introduction features of the manifest. In further articles I will write more about this interesting element. This was just intended a little introduction. Any question or doubts? Feel free to ask me questions.