Android apps are built using a layered system, where each layer has a specific job. These layers are stacked on top of each other, and they work together to help developers build apps more easily.
The top layers help you design the app's look and behaviour — like buttons, screens, and how users interact with it.
The middle layers help your app work with data, run business logic, and access features like internet or databases.
The bottom layers handle the technical parts — like talking to the phone’s hardware, managing memory, battery, or connecting to the camera and sensors.
This setup keeps everything organised and allows developers to focus on building features without needing to worry about how everything works behind the scenes.
Key Layers in Android Architecture
1.Application Framework Layer
Purpose: This layer provides the essential building blocks that developers use to create Android apps. It gives access to core app features and handles interactions between the system and your app.
Key Components:
Activity Manager: Controls the lifecycle of each screen (activity) in your app—e.g., when it starts, stops, or resumes.
Window Manager: Manages how windows and dialogs are displayed on the screen.
Content Providers: Helps apps share data securely (like contact info, media files) with other apps.
View System: Contains all the UI elements like buttons, text boxes, and sliders that users interact with.
Notification Manager: Lets apps send notifications to the user.
Package Manager: Manages installed applications and permissions.
This layer allows you to focus on what the app should do without worrying about how lower layers handle the details.
2. Android Runtime (ART) & Core Libraries
Purpose: Execution environment for Android apps.
Key Components:
ART (Android Runtime) – Replaces Dalvik, uses AOT and JIT compilation
Core Libraries – Provides Java APIs (Collections, IO, Threads, etc.)
3. Native Libraries (C/C++)
Purpose: Provides core capabilities through optimised native code.
Key Libraries:
OpenGL ES – Graphics rendering
WebKit – Web browser engine
SQLite – Lightweight relational database
SSL, libc, media codecs
4. Hardware Abstraction Layer (HAL)
Purpose: Acts as a bridge between the Android system and the hardware.
Example: Audio HAL, Camera HAL, Sensors HAL
5. Linux Kernel
Purpose: Core of the Android OS, managing hardware and system resources.
Responsibilities:
Memory and process management
Networking
Device drivers (camera, audio, sensors)
Power management
Security (SELinux)
Data Flow – Button Tap Example
Step-by-step Data Flow:
1.User Tap on UI Button
The user taps a button.
Depending on the app implementation, the tap could be on:
XML Button — traditional Android UI.
Compose Button — declarative UI with Compose.
2.UI Detects Tap Event
XML Button:
Tap is detected by the View system.
The event is dispatched to the View’s onClickListener registered in code or XML.
The listener calls the associated method (e.g., onButtonClicked()).
Compose Button:
Tap event is handled by Compose’s modifier and callback lambda, e.g., onClick = {}.
Compose calls the corresponding event handler function.
3.Call ViewModel / Event Handler
Both UI methods forward the event to the ViewModel.
The ViewModel contains the app’s business logic.
It processes the event, for example:
Update a UI state.
Fetch or update data.
Trigger navigation or other actions.
4.ViewModel interacts with Repository
The ViewModel calls the Repository layer.
The Repository handles data operations:
Queries the local database (e.g., Room).
Makes network requests.
Updates cached data.
5. Repository returns data
Repository responds with requested data or operation result.
ViewModel updates the app state accordingly.
6. UI Reacts to State Change
XML UI:
ViewModel updates LiveData or Observable data.
UI components observe changes and update the screen.
Compose UI:
ViewModel updates State or MutableStateFlow.
Compose automatically recomposes UI based on updated state.
7. System handles any low-level operations
Data persistence, network, or other OS-level tasks are handled by the Android system.
This includes managing threads, security, and device hardware if needed.
How XML and Compose differ in this flow
Conclusion
The Android SDK architecture provides everything needed to build high-quality apps, from managing memory and hardware to building modern user interfaces.
The lower layers (Kernel, HAL) deal with system-level tasks.
The middle layers (Native Libraries, Runtime) power your app's logic.
The top layer (Application Framework) is where developers build screens, logic, and interactions.
With Jetpack Compose, Android now supports a fully declarative way to build UI, making development faster and more maintainable compared to traditional XML.
Top comments (0)