Android Tutorial
Software Setup and Configuration
Android Studio
File Structure
Components
Core Topics
Layout
View
Button
Intent and Intent Filters
Toast
RecyclerView
Fragments
Adapters
Other UI Component
Image Loading Libraries
Date and Time
Material Design
Bars
Working with Google Maps
Chart
Animation
Database
Advance Android
Jetpack
Architecture
App Publish
App Monetization
The Android Application Manifest file, often simply referred to as the manifest file, is an essential file in every Android application. It is named AndroidManifest.xml
and resides at the root of your app module directory. This file provides essential information about the app to the Android system, which the system must have before it can run any app code.
Here's an overview of its primary roles and components:
Package Name & Version:
versionCode
(an integer value) and versionName
(a string) for your app.Components Declaration:
<activity>
element.Permissions:
Features & Requirements:
Intents & Intent Filters:
App Metadata:
Here's a simple AndroidManifest.xml
file for an app with a single activity:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.myapp"> <!-- Version information --> <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="30" /> <!-- Permissions --> <uses-permission android:name="android.permission.INTERNET" /> <application android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme"> <!-- Main activity declaration --> <activity android:name=".MainActivity"> <intent-filter> <!-- This filter tells the system that this activity should be the starting point of the app --> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <!-- Other components like services, receivers, etc. would be declared here --> </application> </manifest>
When developing an Android app, you must keep the manifest file updated to ensure that it accurately describes your app's components, permissions, and other critical attributes. Android Studio provides a visual editor for the manifest file, but understanding the XML structure is essential for complex apps or manual modifications.
Components of the AndroidManifest.xml file:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.myapp"> <!-- Components, permissions, and other declarations go here --> </manifest>
AndroidManifest.xml file structure:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.myapp"> <!-- Components, permissions, and other declarations go here --> </manifest>
Permissions in AndroidManifest.xml explained:
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.CAMERA" />
Adding activities to AndroidManifest.xml:
<application> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application>
Application configuration in AndroidManifest.xml:
<application>
element in AndroidManifest.xml allows you to configure global settings for your app, such as theme, icon, label, and more.<application android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme"> <!-- Other components and configurations go here --> </application>
AndroidManifest.xml uses-feature element:
<uses-feature>
element in AndroidManifest.xml specifies the hardware and software features required by the app. It helps filter apps on the Play Store based on device capabilities.<uses-feature android:name="android.hardware.camera" />