Android Architecture
From Linux Kernel to your app — understand every layer of the Android software stack
Table of Contents
Architecture Overview
Android architecture is a layered software stack built on the Linux kernel. Each layer provides abstractions to the layer above it, so app developers work with high-level APIs while the system handles hardware, memory, and security underneath.
From bottom to top, the stack is: Linux Kernel → Hardware Abstraction Layer (HAL) → Native Libraries + Android Runtime (ART) → Application Framework → Applications.
1Linux Kernel
The Linux Kernel is the foundation of Android. It sits directly on top of the physical hardware and provides core OS services that all upper layers depend on.
Device Drivers
Display, camera, audio, Wi-Fi, Bluetooth, GPS, sensors — kernel drivers talk to hardware chips.
Memory Management
Allocates RAM to processes, handles paging, and prevents apps from accessing each other's memory.
Power Management
CPU sleep states, wake locks, and battery optimization at the system level.
Process Isolation
Each app runs in its own Linux process with a unique UID — sandboxing starts here.
| Kernel responsibility | Why it matters for developers |
|---|---|
| Process scheduling | Multitasking — many apps appear to run simultaneously |
| Network stack (TCP/IP) | All HTTP, WebSocket, and socket APIs ultimately use kernel networking |
| File system (ext4, F2FS) | App private storage, shared media, and cache directories |
| IPC (Binder driver) | Enables inter-process communication between app and system services |
Google chose Linux for its proven security model, mature driver ecosystem, and open-source license. Android adds custom kernel patches (Binder, Ashmem, wakelocks) on top of standard Linux.
2Android Runtime (ART)
The Android Runtime (ART) executes your app's bytecode. Since Android 5.0 (Lollipop), ART replaced the older Dalvik VM, delivering significantly better performance and battery efficiency.
How ART works
Your Kotlin/Java code is compiled to .class files, then converted to DEX (Dalvik Executable) bytecode.
At install time, ART performs AOT (Ahead-of-Time) compilation — DEX is compiled to native machine code on the device.
At runtime, ART also uses JIT (Just-in-Time) for hot code paths — frequently used methods get further optimized.
Garbage Collection (GC) reclaims unused memory automatically — ART's concurrent GC reduces UI jank.
| Feature | Dalvik (legacy) | ART (current) |
|---|---|---|
| Compilation | JIT only at runtime | AOT at install + JIT at runtime |
| App startup | Slower (interpret bytecode) | Faster (pre-compiled native code) |
| Battery | More CPU for interpretation | Less runtime overhead |
| File format | .dex | .dex (same), stored in APK/AAB |
3Application Framework
The Application Framework exposes high-level Java/Kotlin APIs that developers use daily. It manages app lifecycle, UI, data, and system services through a set of Manager classes and Content Providers.
| Manager / API | Responsibility |
|---|---|
| Activity Manager | Launches Activities, manages back stack, app lifecycle |
| Window Manager | Screen layout, dialogs, system UI overlays |
| Package Manager | Install/uninstall apps, resolve intents, permissions |
| Notification Manager | Post and manage status bar notifications |
| Location Manager | GPS and network-based location |
| Telephony Manager | Phone calls, SIM info, network type |
| Content Providers | Shared data access — Contacts, MediaStore, Settings |
| View System | Widgets, layouts, drawing, touch events |
4Libraries
Below the Application Framework sit Native Libraries (C/C++) and the Hardware Abstraction Layer (HAL). These provide performance-critical and hardware-specific functionality without exposing kernel details to upper layers.
Native Libraries (C/C++)
SQLite
Embedded database engine — used by Room and ContentProviders.
OpenGL ES / Vulkan
2D/3D graphics rendering for games and custom views.
MediaCodec
Hardware-accelerated audio/video encode and decode.
FreeType / Skia
Font rendering and 2D graphics drawing engine.
Hardware Abstraction Layer (HAL)
HAL defines standard interfaces for hardware vendors. OEMs implement HAL modules for their specific chips while Android's framework calls the same API regardless of device.
| HAL module | Hardware controlled |
|---|---|
| Camera HAL | Camera sensors, autofocus, flash |
| Audio HAL | Speakers, microphones, Bluetooth audio |
| Graphics HAL | GPU composition and display output |
| Sensors HAL | Accelerometer, gyroscope, fingerprint |
| Radio HAL | Cellular modem, Wi-Fi, NFC |
NDK — calling native code from your app
5App Layers
The top layer — Applications — is where your code lives. Android apps are built from four component types, all running inside isolated sandboxes (separate Linux processes).
System Apps
Pre-installed with the OS — Phone, Settings, Camera, Contacts. Run with elevated privileges.
User Apps
Downloaded from Play Store or sideloaded — Instagram, banking apps, games. Sandboxed by default.
Library Apps (AAR)
Reusable code packaged as Android Archive — Firebase SDK, Retrofit, Glide.
Process & sandbox model
Each app gets its own Linux process and unique UID (user ID).
Apps cannot read each other's private data unless permission is granted.
Components communicate via Intents and Binder IPC — never direct memory access.
When memory is low, Android kills background processes — apps must save state in onSaveInstanceState.
| Layer (top to bottom) | What you interact with |
|---|---|
| Your App (Kotlin/Java) | Activities, ViewModels, Compose UI, business logic |
| Jetpack / Support Libraries | Room, Navigation, LiveData, WorkManager |
| Android Framework APIs | Activity Manager, Package Manager, Notifications |
| ART + Native Libs | Bytecode execution, SQLite, OpenGL, MediaCodec |
| HAL + Kernel | Hardware drivers, memory, security (invisible to most devs) |
6Android Architecture Diagram
The complete Android software stack from hardware to applications. Data and API calls flow downward through layers; hardware events flow upward.
System Apps · User Apps · Play Store Apps
Activity Manager · Window Manager · Package Manager · View System · Content Providers
SQLite · OpenGL ES · MediaCodec · WebKit · libc · FreeType
DEX bytecode · AOT/JIT compilation · Garbage Collection
Camera HAL · Audio HAL · Graphics HAL · Sensors HAL
Drivers · Power Management · Memory · Process Isolation · Binder · Network Stack
Data flow example — tapping a button
Key takeaway: As an Android developer, you primarily work at the Application and Application Framework layers. Understanding the full stack helps you debug performance issues, write efficient native code (NDK), and answer architecture questions in interviews. Next: dive into Activities & Intents — the building blocks of every Android screen.
Android Architecture MCQ Practice
10 Basic MCQs 10 Advanced MCQs10 Basic Android Architecture MCQs
Bottom layer of Android stack?
ART replaced which runtime?
HAL stands for?
Application layer contains?
Native C/C++ libraries used for?
System Server runs in?
Binder IPC is used for?
Zygote process?
Framework APIs are written mainly in?
SurfaceFlinger relates to?
10 Advanced Android Architecture MCQs
AOT vs JIT in ART?
SELinux on Android provides?
System apps vs user apps?
Ashmem/ION relate to?
PackageManagerService role?
ActivityManagerService?
Treble project improved?
Main thread in app process also called?
Sandbox per app means?
HWComposer role?
Android Architecture Interview Q&A
15 topic-focused questions for interviews and revision.