The Application Manifest File | Android

Every project in Android includes a manifest file, which is AndroidManifest.xml, stored in the root directory of its project hierarchy. The manifest file is an important part of our app because it defines the structure and metadata of our application, its components, and its requirements.

This file includes nodes for each of the Activities, Services, Content Providers and Broadcast Receiver that make the application and using Intent Filters and Permissions, determines how they co-ordinate with each other and other applications.

The manifest file also specifies the application metadata, which includes its icon, version number, themes etc. and additional top- level nodes can specify any required permissions, unit tests and define hardware, screen, or platform requirements.

The manifest comprises of a root manifest tag with a package attribute set to the project’s package. It should also include an xmls:android attribute that will supply several system attributes used within the file.
We use versionCode attribute is used to define the current application version in the form of an integer that increments itself with the iteration of version due to updation. Also, versionName attribute is used to specify a public version that will be displayed to the users.



We can also specify whether our app should install on an SD card of the internal memory using the installLocation attribute.

We can also specify whether our app should install on an SD card of the internal memory using the installLocation attribute.

A typical manifest node looks as:

filter_none

edit
close

play_arrow

link
brightness_4
code

    package="com.paad.myapp"
    android:versionCode="1"
    android:versionName="0.9 Beta"
    android:installLocation="preferExternal">
    [....manifest nodes....]
</manifest>

chevron_right


A manifest file includes the nodes that define the application components, security settings, test classes and requirements that make up the application. Some of the manifest sub-node tags that are mainly used are:

  • uses-sdk– It is used to define a minimum and maximum SDK version that must be available on a device so that our application function properly, and target SDK for which it has been designed using a combination of minSdkVersion, maxSdkVersion, and targetSdkVersion attributes, respectively.
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <uses-sdk android:minSdkVersion=”6”
            android:targetSdkVersion=”15”/>

    chevron_right

    
    

  • uses-configuration– The uses-configuration nodes are used to specify the combination of input mechanisms that are supported by our application. It is useful for games that require particular input controls.
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <uses-configuration android:reqTouchScreen=”finger”
                    android:reqNavigation=”trackball”
                    android:reqHardKeyboard=”true
                    android:reqKeyboardType=”qwerty”/>
    <uses-configuration android:reqTouchScreen=”finger”
                    android:reqNavigation=”trackball”
                    android:reqHardKeyboard=”true
                android:reqKeyboardType=”twelvekey”/>

    chevron_right

    
    

  • uses-features– It is used to specify which hardware features your application requirement. This will prevent our application from being installed on a device that does not include a required piece of hardware such as NFC hardware, as follows:
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <uses-feature android:name=”android.hardware.nfc”/>

    chevron_right

    
    

  • supports-screens– It is used to describe the screen support for our application:
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <supports-screens android:smallScreens=”false
                       android:normalScreens=”true
                       android:largeScreens=”true
                       android:xlargeScreens=”true”/>

    chevron_right

    
    

  • permission– It is used to create permissions to restrict access to shared application components. We can also use the existing platform permissions for this purpose or define your own permissions in the manifest.
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <permission android: name=”com.paad.DETONATE_DEVICE”
                android:protectionLevel=“dangerous”
                android:label=”Self Destruct”
                android:description=”@string/detonate_description”>
    </permission>

    chevron_right

    
    

  • application– A manifest can contain only one application node. It uses attributes to specify the metadata for your application (including its title, icon and theme). During development we should include a debuggable attribute set to true to enable debugging, then be sure to disable it for your release builds.
    The application node also acts as a container for the Activity, Service, Content Provider, and Broadcast Receiver nodes that specify the application components. The name of our custom application class can be specified using the android:name attribute.

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <application android:icon="@drawable/icon"
                 android:logo-"@drawable/logo"
                 android:theme="@android:style/Theme.Light"
                 android:name=".MyApplicationClass"
                 android:debuggable="true">
                 [....application nodes.....]
    </application>

    chevron_right

    
    

References: https://developer.android.com/guide/topics/manifest/manifest-intro.html



My Personal Notes arrow_drop_up

Intern at geeksForgeeks

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.