Pin Me

Guide to the Android Manifest

written by: Jbeerdev•edited by: Simon Hill•updated: 7/1/2010

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

  • slide 1 of 5

    In many of the articles I have written, the AndroidManifest.xml file has appeared in some way. Well, it's 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 another IDE to work with Android), we will have 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. Let's have a look at 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-permission".

    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 permissions the application needs to make it work.

    These are the most important elements, from 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

  • slide 2 of 5

    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. Let's 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 name our Android application, this string, will appear with the icon above when you install it on a device.

    android:theme="resource or theme" → We can create a general theme, and use it in all applications. In other articles 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 these elements, but it will be done in the next article. For now, just keep in mind that every new Activity, Service or Content Provider we create in our application, has to be put here. If not, the application won't recognize it.

  • slide 3 of 5

    Permissions

    Inside the <manifest> tag we can have the <users-permission> tag. This is used to define the features the application needs to access and the user needs 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 “Permissions" list, where the user, has to “grant" or accept them all if they want the application installed on their device.

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

  • slide 4 of 5

    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!)

  • slide 5 of 5

    Want more?

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