
Every Android app begins with a humble file:Â AndroidManifest.xml. You add permissions, declare activities, and move on.
But behind this file lies one of Android’s most critical subsystems — the Package Manager.
It’s how Android knows what your app is, what it can do, and what it’s allowed to touch.
Let’s uncover what really happens from build time to runtime.
⚙️ 1. The Manifest You Write Isn’t What Android Reads
When you build your app, your human-readable manifest is compiled into binary XML by AAPT2. This makes it smaller and faster to parse.
aapt dump xmltree app.apk AndroidManifest.xml
During packaging, AAPT2 merges manifests from libraries and modules — the final version inside the APK is often much bigger than you expect.
Manifest.xml (text) ↓ AAPT2 → Binary XML ↓ Packaged into APK
🏗️ 2. Installation — Where the Real Magic Happens
When you install an app (via Play Store or adb install), the Package Manager Service (PMS) inside Android’s system_server process steps in.
It uses a class called PackageParser to read the binary manifest and extract everything about your app:
- Components (
Activity,ÂService,ÂReceiver,ÂProvider) - Permissions and SDK info
- Intent filters and meta-data
PMS then:
- Stores this info inÂ
/data/system/packages.xml - Updates internal databases
- Notifies services likeÂ
ActivityManagerService andÂPermissionManagerService
That’s how Android “registers” your app before you ever run it.
đź§© 3. Who Parses the Manifest?
PackageParser (part of AOSP) literally walks through your manifest node by node:
if ("uses-permission".equals(tag)) {
parseUsesPermission(parser);
}
Each tag becomes part of a PackageParser.Package object — the in-memory definition of your app.
Once parsed, Android doesn’t re-read the manifest again.
Everything is cached in the Package Manager for fast lookups.
🚀 4. Launching the App
When you tap your app icon:
- Android checks the cached manifest data to find yourÂ
MAIN +ÂLAUNCHER activity. Zygote forks your app process.ActivityThread receives anÂApplicationInfo object — pre-filled from manifest data.
No parsing happens at launch — everything is already known.
🛡️ 5. Permissions — The Two-Stage Process
Install Time
PMS checks <uses-permission> tags:
- Normal permissions (likeÂ
INTERNET) → auto-granted - Dangerous permissions (likeÂ
READ_CONTACTS) → user approval needed later
Runtime
When your app requests something protected:
- The system checks if you declared it in your manifest.
- Then it checks if the user granted it.
PermissionManagerService andÂAppOpsManager handle these checks.
If you missed declaring it, Android throws a SecurityException — even if the user approved it earlier.
đź§ 6. The Key Players

đź’ˇ 7. Why It Matters
Knowing how this works helps you:
- Debug tricky permission or manifest merge issues
- Understand how the system enforces app boundaries
- Inspect third-party APKs confidently (
adb shell dumpsys package your.package.name)
The manifest isn’t just metadata — it’s your app’s contract with Android.
Job Offers
đź§ Final Thoughts
AndroidManifest.xml defines everything about your app — before it ever runs.
From permissions to launchers to content providers, Android relies entirely on what’s inside it.
Next time you add a permission or intent filter, remember:
- It’s not just XML.
- It’s how your app talks to the Android system itself.
Â
This article was previously published on proandroiddev.com


