AndroidManifest.xml: Architecture, Permissions & Components

Every Android application package must have an AndroidManifest.xml file located at the root of its source set (app/src/main/AndroidManifest.xml). The manifest acts as the formal contract between your application and the underlying Android operating system. Before Android launches a process, displays an activity, or delivers a notification, it inspects this file.

Essential Responsibilities of the Android Manifest

  • Declares the unique Java/Kotlin package name and application ID.
  • Registers all 4 Core Components: Activities, Services, BroadcastReceivers, and ContentProviders. (Any component not registered in the manifest cannot be started by the system!).
  • Declares the Permissions the app requires to access protected APIs (Internet, Camera, Bluetooth, Location).
  • Specifies Hardware Features required (e.g., NFC, camera autofocus, telephony).
  • Configures application-level metadata, custom themes, icons, backup rules, and network security profiles.

Complete Production AndroidManifest.xml Annotated Example

Here is a realistic, production-ready manifest demonstrating modern configuration best practices:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <!-- Normal Permissions (Granted automatically at install time) -->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <!-- Dangerous Permissions (Requires runtime prompt on Android 6.0+) -->
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

    <!-- Hardware Feature Declarations -->
    <uses-feature
        android:name="android.hardware.camera"
        android:required="false" /> <!-- App will still install on devices without camera -->

    <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.VeewomApp"
        android:enableOnBackInvokedCallback="true"
        tools:targetApi="35">

        <!-- Launcher Activity (The entry point when user taps app icon) -->
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:theme="@style/Theme.VeewomApp">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <!-- Detail Activity (Internal component, not exported to other apps) -->
        <activity
            android:name=".DetailActivity"
            android:exported="false"
            android:parentActivityName=".MainActivity" />

        <!-- Background Work Service -->
        <service
            android:name=".services.DownloadService"
            android:exported="false" />

        <!-- Broadcast Receiver for Network Changes -->
        <receiver
            android:name=".receivers.NetworkChangeReceiver"
            android:exported="false" />

    </application>

</manifest>

Critical Manifest Attributes You Must Know

Attribute / Element Allowed Values Security & Architectural Importance
android:exported true | false Mandatory since Android 12! Determines whether external apps and the OS can invoke this component. Setting true without intent filters or permissions is a severe security vulnerability.
android:required (in uses-feature) true | false If set to true, Google Play Store hides your app from any device lacking that specific hardware sensor (e.g., tablets without telephony).
enableOnBackInvokedCallback true | false Enables modern Predictive Back system animations introduced in Android 13/14+.
intent-filter action, category, data Tells the operating system what types of explicit and implicit requests (e.g., opening a URL, sharing text) this component can handle.

Security Warning: The exported="true" Pitfall

Prior to Android 12, components with intent-filters were exported by default. This allowed malicious third-party apps on the user's phone to launch private internal activities or bind to unprotected background services. Today, any component with an intent-filter must explicitly declare android:exported="true", and any purely internal component must declare android:exported="false".

Frequently Asked Questions (FAQ) - Student & Interview Review

Q1. What happens if I forget to declare an Activity in AndroidManifest.xml?

If your code attempts to launch an Activity via an Intent and that Activity is not registered inside the `` tag of the manifest, the app will crash immediately with an `ActivityNotFoundException`.

Q2. What is the difference between normal and dangerous permissions?

Normal permissions (like `INTERNET` or `ACCESS_NETWORK_STATE`) pose minimal risk to user privacy and are granted automatically upon installation. Dangerous permissions (like `CAMERA`, `ACCESS_FINE_LOCATION`, or `RECORD_AUDIO`) give access to sensitive user data and require explicit runtime user consent dialogs.

Q3. Can two apps on the same phone share the same package name in their manifests?

No. The package name (Application ID) is the globally unique identifier for an application within the Android OS and on the Google Play Store. Installing an app with an identical package name will overwrite or conflict with the existing installation.

Explore Related Android Development Classes & Next Steps

Broaden your foundational and advanced Android application development skills across our curriculum:

Activity Lifecycle & States

Register Activity declarations, launch modes, and theme attributes.

Runtime Permissions & Scoped Storage

Declare normal and dangerous permissions and handle runtime requests.

Deep Linking & Verified App Links

Configure intent-filter tags with android:autoVerify for App Links.

Firebase Push Notifications

Register FirebaseMessagingService and notification channels in the manifest.

Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Reddit

You may also like this!