Android manifest file is one of the must-have files that are generated any time a new project is created. The file is always auto-generated and contains project-related features as defined by the user while creating a project.
The android manifest file is not static and therefore keeps on changing depending on the features or items that are added to the project.
In this article, we shall understand what is a manifest file in android, why is android manifest a must-have file in an android project, which elements or features are added in the android manifest file and where can you locate the android manifest file.
What is a manifest file in android
The android manifest file is an XML file in android studio that is specific for a project that contains the Metadata for a given app project.
The Metadata contained in the android manifest file includes the activities, the app package name, the launcher activity, the permissions that the app will use, and also the support version.
The manifest file defines the essential features that your app project has such that without it, your application will not execute.
Why is it a must to have an android manifest file
From the definition of a manifest file, we have highlighted that it contains the Metadata of the app project. This Metadata contained in the manifest file is the one that drives your application without which the app will not execute.
You will also notice that any time you are creating a project in android studio, the android manifest file is auto-generated meaning it is a core file for every project.
The android manifest file determines which activity will be opened first when the app is launched without this the app will misbehave and therefore not execute.
Features in android manifest file
The features included in the manifest file includes;
- The app package name
This acts as the unique identifier for the application such that when you want to publish the app in the google play store, the package name acts as the application id and must be unique for every app.
In a previous article, we highlighted the importance of package name including how you can change or rename the package name. Every app must have a unique package name
The package name in manifest file is defined as follows
<?xml version="1.0" encoding="utf-8"?>
- App icon, round icon and theme
The app icon gives identity of your app when it is installed in the mobile device. Other devices uses the round icon depending on the phone manufacturer that’s why it is also included
The app theme which is defined in the values section of the res folder is declared in the manifest file so that it can be used in the app
The manifest file code for icon, round icon and theme is as follows
- Defines all activities
All activities present in your project are defined in the android manifest file. This ensures that your app knows the exact screens and functions that are available in the app.
The activities forms an important aspect in the app since they provide the interface into which the user will interact on
Every activity is defined as follows inside the application tag
<!-- activity 1 starts here -->
- Sets the launcher activity
In the manifest file, this is where the launcher activity is defined or set. The activity which is set as the launcher activity will be the one that will be opened first when the application is opened on the mobile device. Learn how to set an activity as the launcher activity in android.
In the manifest file, the activity with the below code is the one which is regarded as the first activity or launcher activity for the app project.
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
- Defines the permissions for app
All the permissions that your app will use, for example, internet connection, check network state and many more are all defined in the manifest file. If a permission is not found in the manifest file and the permission feature be used in the activities, it will not work
The permissions in manifest file are defined as follows
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Remember to note the difference between permission and uses permission as highlighted here.
Locate android manifest file
To locate the android manifest file in your project;
- In the android studio, open your project
- In the left sidebar at the top, below app the manifest folder will be visible
- Open the manifest folder, AndroidManifest.xml will be seen
- Click to open it and then you can make changes
That’s it for this article, hope you have now understood what is a manifest file, what it does, the features that are included in the manifest file, why it is a must to have a manifest file, and where to locate it in android studio project.