Android Manifest

Android Guy
3 min readNov 14, 2018

--

This is the 3rd episode of my Android Series, in which you will be learning…

  1. Android Manifest

Every Android project must have AndroidManifest.xml file which describes necessary information about the application and how to build it. For instance, the manifest contains information about the location of the source files, which is used by the Android build tools. It also describes what kind of devices or the versions of Android that the application supports. Furthermore, it defines the unique app identifier or the application’s package-name, which is used by the system and PlayStore.

The structure of the manifest file can look something like this

<?xml version="1.0" encoding="utf-8"?><manifest>    <uses-permission />
<uses-permission-sdk-23 />
<permission />
<permission-tree />
<permission-group />
<instrumentation />
<uses-sdk />
<uses-configuration />
<uses-feature />
<supports-screens />
<compatible-screens>
<screen />
...
</compatible-screens>
<supports-gl-texture />
<application> <activity>
<intent-filter>
<action />
<category />
<data />
</intent-filter>
<meta-data />
</activity>
<activity-alias>
<intent-filter>
<action />
<category />
<data />
</intent-filter>
<meta-data />
</activity-alias>
<service>
<intent-filter>
<action />
<category />
<data />
</intent-filter>
<meta-data/>
</service>
<receiver>
<intent-filter>
<action />
<category />
<data />
</intent-filter>
<meta-data />
</receiver>
<provider>
<grant-uri-permission />
<meta-data />
<path-permission />
</provider>
<uses-library /> </application></manifest>

Let’s examine the AndroidManifest.xml from the Todo project that we created in the previous episode.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.theandroidguy.todo">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".TodoActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name=
"android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.theandroidguy.todo">

A manifest file begins with <manifest ...> tag with attributes:

  • xmlns declares name spaces used in this XML file such as android , app, and tools. Think of a name space as a short-alias for a long-URI. For example, android:allowBakcup is equivalent to http://schemas.android.com/apk/res/android:allowBackup when it is read by XML parser.
  • package tells the build tools where to find relative classes and where to place auto-generated files. For example,
    .TodoActivity can be found at com.theandroidguy.todo.TodoActivity. It also represents the Application’s ID which has to be globally unique across the PlayStore in order to publish the Application. The build tools will override this attribute using applicationId from build.gradle file.

Application is defined using <application> tag that contains <activity> tag that defines an Activity. <intent-filter> tag filters the conditions in which the Activity will be launched. For example,
<action android:name=”android.intent.action.MAIN” /> tells the Android system that this is an entry point of the Application.
<category android:name= “android.intent.category.LAUNCHER” /> provides additional information about the <action> which, in this case, tells the system that this Activity should be displayed inside the top-level Launcher, which can be found in “applications” on the home screen.

For now, this is all the need-to-know basics of the AndroidManifest to get started with Android programming. For the reference, below are the list of legal elements which can be defined inside the manifest.

--

--

Android Guy

Lead Software Engineer @ Property Guru, An Android Expert and An Photography Enthusiast.