July 9, 2025
15 min read

Discovering Android’s Source: Traversing the AOSP’s File Structure

AOSP
Android
File Structure
Development
System Architecture
SSamir Dubey
Samir Dubey

AOSP Engineer

A comprehensive guide to navigating the AOSP codebase, exploring key directories like packages, frameworks, system, art, dalvik, hardware, external, and kernel, and their roles in Android’s architecture.

Here’s a more detailed breakdown of the Android architecture and where you can find the corresponding files and folders in the AOSP codebase:

Remember that the AOSP is a complex codebase with multiple layers. While this breakdown provides a general overview, many more subdirectories and components contribute to the Android operating system.

A precisely planned directory structure forms the basis of one of the most well-known operating systems in the complex environment of the Android Open Source Project (AOSP). As we progress through the levels, this article will examine the role of each directory, its contents, and the insights it offers into the intricate structure of Android’s operation and features.

“packages”

In the context of the Android architecture, the “packages” directory in the AOSP codebase is a crucial part of the Application layer. This directory contains the source code for various Android applications that are bundled with the Android operating system. These applications make up the core user-facing experiences and functionalities of an Android device. Let’s delve into the “packages” directory to understand its significance and components:

Location: The “packages” directory is typically located at the root of the AOSP source code repository.

Contents:

Within the “packages” directory, you’ll find subdirectories that house the source code for different Android applications and components. Some of these subdirectories include:

apps: This subdirectory contains the source code for various pre-installed Android apps that users interact with daily. Examples include:Phone app (Dialer): Allows users to make and receive phone calls.Contacts app (Contacts): Manages contacts and address book information.Messaging app (Messaging): Handles SMS and MMS messaging.Calculator app (Calculator): Provides basic calculator functionality.Input Methods: This subdirectory contains the source code for input methods, including the default keyboard app (LatinIME) that provides on-screen typing functionality.Live Wallpapers: This subdirectory holds the source code for live wallpapers, which are dynamic backgrounds that respond to user interaction and device sensors.Wallpapers: Here, you’ll find source code for static wallpapers that users can set as their device background.Backup Apps: This subdirectory contains the source code for apps and agents that are responsible for participating in the Android system’s backup and restore mechanism.Bluetooth Apps: This subdirectory includes source code related to Bluetooth functionality, such as the Bluetooth stack and settings.Captive Portal Login: This subdirectory contains the code for handling captive portal Wi-Fi networks, which require user interaction for network access.Carrier Apps: In the case of carrier-customized builds of Android, this subdirectory holds carrier-specific apps and configurations.NFC Apps: Source code related to Near Field Communication (NFC) technology is stored here.

Significance and Learning Opportunities:

Exploring the “packages” directory provides programmers with valuable insights into the following aspects of Android development:

App Architecture: Studying the code of these core Android applications gives you insights into how to structure different app components, such as Activities, Fragments, Services, Broadcast Receivers, and Content Providers. User Interface Design: Examining the XML layout files within these apps helps you understand how Android’s user interface elements are created and arranged. System Services Integration: Many of these apps interact with system services, such as accessing contacts, sending SMS, or managing Bluetooth connections. This demonstrates how to integrate your app with existing system functionalities. Best Practices: Analyzing the code of these well-maintained apps gives you a glimpse into Android best practices, coding standards, and design patterns. Debugging and Troubleshooting: By studying real-world code, you’ll learn how to diagnose and debug issues that can arise during Android app development. Custom Components: Some of these apps might contain custom components or features, allowing you to learn how to implement unique functionality in your apps.

Overall, the “packages” directory in AOSP is a goldmine for programmers aiming to learn Android development by dissecting and understanding the code that powers essential user experiences on Android devices.

“frameworks”

The “frameworks” directory in the Android Open Source Project (AOSP) codebase is a central and critical part of the Android architecture. It contains the source code for the Android framework, which provides a set of core libraries, APIs, and services that allow applications to run and interact with the underlying system. Let’s explore the “frameworks” directory and understand its significance:

Location: The “frameworks” directory is typically located at the root of the AOSP source code repository.

Contents:

The “frameworks” directory is subdivided into multiple subdirectories, each of which contains different aspects of the Android framework:

base: This subdirectory contains the core libraries and components that form the foundation of the Android framework. It includes fundamental classes and interfaces that are used across the entire system. native: In this subdirectory, you’ll find the native components of the Android framework, written in languages like C and C++. These components provide low-level functionality and bridge the gap between the Java-based framework and the underlying hardware. opt: The “opt” subdirectory holds optional framework modules. These modules provide additional features or enhancements that may not be included in all devices. This allows device manufacturers to choose which optional modules to include. policy: The “policy” subdirectory contains code related to policy enforcement and management. This includes security policies, permissions, and access controls that define how apps and components interact with each other and the system. services: Here, you’ll find the source code for various system-level services that are fundamental to Android’s operation. Examples include the Activity Manager, Package Manager, and Location Manager. test-runner: This subdirectory contains the code for the Android Test Runner, which is used to execute automated tests on Android devices. wifi: In the “wifi” subdirectory, you’ll find components related to Wi-Fi connectivity, including APIs for interacting with Wi-Fi networks and managing connections. graphics: The “graphics” subdirectory contains code related to graphics rendering and management, including interfaces to interact with the GPU and render graphics on the screen.

Significance and Learning Opportunities:

Core Framework Components: Exploring the “frameworks” directory gives programmers insight into the fundamental components of the Android framework, such as activities, services, content providers, and broadcast receivers. Application Lifecycle: By studying the code within the “services” subdirectory, you can understand how Android manages the lifecycle of applications and activities. Inter-Component Communication: You can learn about inter-component communication mechanisms, such as intents and intents resolution, which enable different parts of the Android system to communicate with each other. Security and Permissions: The “policy” subdirectory reveals how Android enforces security policies, manages app permissions, and ensures that apps run within a secure sandbox. Low-Level System Interaction: The “native” subdirectory allows you to explore how Android interacts with low-level hardware components through native code. Testing and Test Framework: The “test-runner” subdirectory provides insights into how Android handles testing, which is crucial for ensuring app quality and stability. Wi-Fi and Connectivity: By examining the “wifi” subdirectory, you can understand how Android handles Wi-Fi connectivity, scans, and network management.

Studying the “frameworks” directory is essential for programmers who want to deeply understand the inner workings of the Android system, develop custom framework components, or contribute to improving the core Android framework.

“system”

The “system” directory in the Android Open Source Project (AOSP) codebase is a vital component of the Android architecture. It contains core system-level components and services that are responsible for managing various aspects of the Android operating system. Let’s dive into the “system” directory and understand its significance:

Location: The “system” directory is usually located at the root of the AOSP source code repository.

Contents:

The “system” directory is organized into several subdirectories, each housing different system-level components:

core: This subdirectory contains essential system-level components and utilities that are fundamental to the Android operating system’s operation. It includes core system services and daemons, as well as system-level libraries. extras: In the “extras” subdirectory, you’ll find additional system components and utilities that are not part of the core Android framework but provide extended functionality. health: The “health” subdirectory includes components related to system health monitoring and management, such as battery and power management. io: Here, you’ll find components related to input and output operations, including system-level handling of input devices and storage. media: The “media” subdirectory contains components related to multimedia processing, such as audio, video, and graphics. netd: This subdirectory holds the code for the Network Daemon (netd), which is responsible for managing network-related tasks, including routing and firewall rules. time: The “time” subdirectory includes code for managing time and date-related functionalities, such as time synchronization. vold: In the “vold” subdirectory, you’ll find the Volume Daemon (vold), which manages storage volumes and provides access to external storage devices.

Significance and Learning Opportunities:

System Services: Exploring the “core” subdirectory gives you insights into the core system services and daemons that Android relies on for its operation. These services handle critical tasks such as package management, activity lifecycle, and more. System Health Management: The “health” subdirectory allows you to understand how Android manages battery life, monitors system health, and optimizes power consumption. Input and Output Handling: By examining the “io” subdirectory, you can learn about how Android interacts with input devices like touchscreens and keyboards, as well as how it manages storage operations. Media Processing: The “media” subdirectory provides insights into how Android processes audio, video, and graphics, including codecs, players, and multimedia frameworks. Network Management: Studying the “netd” subdirectory helps you understand how Android manages networking tasks, including routing and firewall configurations. Time and Date Management: The “time” subdirectory allows you to delve into how Android handles time synchronization and management. Storage Management: The “vold” subdirectory reveals how Android manages storage volumes, mounts external storage devices, and ensures data access.

Understanding the “system” directory is crucial for developers who want to work on low-level system components, optimize system performance, or troubleshoot issues related to system services and functionality. It provides insights into how Android’s core services collaborate to create a stable and functional operating system.

“art” and “dalvik”

The “art” and “dalvik” directories in the Android Open Source Project (AOSP) codebase are related to the Android Runtime, which is responsible for executing and managing Android applications’ code. Both “art” and “dalvik” represent different versions of the runtime environment used in various Android versions. Let’s explore these directories and understand their significance:

“art”:

Location: The “art” directory is usually located at the root of the AOSP source code repository. Purpose: “art” stands for Android Runtime. It’s the successor to the earlier Dalvik Virtual Machine (Dalvik) and is introduced to provide improved performance, memory efficiency, and developer tools.

Inside the “art” directory, you’ll find the source code for the Android Runtime environment, including:

art/runtime: This subdirectory contains the runtime libraries and components that manage the execution of compiled Java code. It includes components for JIT (Just-In-Time) compilation, garbage collection, memory management, and more. art/compiler: This subdirectory contains the source code for the ART compiler, responsible for compiling Java bytecode into native machine code. ART uses ahead-of-time (AOT) compilation to improve app startup and execution performance. art/libdex: The DEX (Dalvik Executable) file format is used to package and distribute Android app code. This subdirectory contains code related to working with DEX files.

“dalvik”

Location: The “dalvik” directory is usually located at the root of the AOSP source code repository. Purpose: Dalvik was the original runtime environment used in older versions of Android (before Android 5.0 Lollipop). It employed a Just-In-Time (JIT) compilation approach, converting bytecode to native machine code during app execution.

Inside the “dalvik” directory, you’ll find the source code for the Dalvik Virtual Machine: dalvik/libdex: Similar to the “art” directory, this subdirectory contains code related to working with DEX files in the context of the Dalvik runtime. dalvik/vm: This subdirectory holds the core components of the Dalvik Virtual Machine, including the interpreter, JIT compiler, garbage collector, and memory management.

Significance and Learning Opportunities:

Performance Optimization: Exploring the “art” directory allows developers to understand the improvements made in the ART runtime compared to Dalvik. This knowledge can help optimize app performance and memory usage. Compilation Techniques: Studying the “art/compiler” subdirectory gives insight into the AOT compilation process, which can help you write code that benefits from AOT compilation. Runtime Behavior: By examining the code in “art/runtime,” you can learn about how the Android Runtime manages memory, handles garbage collection, and optimizes code execution. Compatibility and Migration: Developers maintaining older Android apps might find the “dalvik” directory useful for understanding how apps were executed in previous Android versions and for ensuring compatibility. Low-Level System Interaction: Understanding the “art” and “dalvik” directories provides insight into the interaction between the runtime environment and the underlying system components, such as the kernel and hardware.

Overall, the “art” and “dalvik” directories are crucial for developers who want to optimize app performance, understand runtime behavior, and ensure compatibility with different Android versions. The transition from Dalvik to ART marked a significant improvement in Android’s runtime environment.

“hardware”

The “hardware” directory in the Android Open Source Project (AOSP) codebase is a crucial part of the Android architecture that handles the Hardware Abstraction Layer (HAL). The HAL provides a standardized interface between the Android framework and the underlying hardware components of an Android device. Let’s explore the “hardware” directory and understand its significance:

Location: The “hardware” directory is typically located at the root of the AOSP source code repository.

Contents:

The “hardware” directory is organized into different subdirectories, each representing a category of hardware components or features:

audio: This subdirectory contains the HAL implementations related to audio hardware components, such as sound cards, audio codecs, and audio input/output. camera: The “camera” subdirectory holds HAL implementations for camera hardware. It provides an interface for the Android framework to interact with device cameras. libhardware: This subdirectory contains the core HAL interface definition and common code shared across different hardware components. It’s a crucial part of the Hardware Abstraction Layer. lights: In the “lights” subdirectory, you’ll find HAL implementations for device LEDs and other light-related hardware components. power: The “power” subdirectory includes HAL implementations for managing power-related features, such as CPU frequency scaling and battery management. sensors: This subdirectory contains HAL implementations for various sensors on the device, including accelerometers, gyroscopes, and ambient light sensors. tv: If the device supports TV functionality, the “tv” subdirectory holds HAL implementations related to TV tuner hardware. thermal: The “thermal” subdirectory contains HAL implementations for thermal management, ensuring that the device temperature is within safe limits.

Significance and Learning Opportunities:

Standardized Hardware Interface: The “hardware” directory and its subdirectories provide standardized interfaces that allow the Android framework to communicate with diverse hardware components across different devices. Abstraction from Hardware Differences: The HAL abstracts the hardware differences between various devices. This enables app developers to write code that works across a wide range of devices without needing to know the specific details of each device’s hardware. Modularity and Portability: Understanding the HAL architecture helps developers build custom ROMs or device adaptations, as it allows them to replace or modify hardware-specific implementations without altering the rest of the system. Device Customization: Device manufacturers can create custom implementations for specific hardware components while adhering to the HAL interface. This ensures that their custom hardware can seamlessly integrate with the Android framework. System Stability and Compatibility: Properly functioning HAL implementations are crucial for maintaining system stability, as they bridge the gap between the Android framework and hardware, ensuring smooth communication. Low-Level System Interaction: Exploring the HAL provides insight into the low-level interaction between the Android operating system and device hardware, giving developers a deeper understanding of the system’s behavior.

Overall, the “hardware” directory is essential for both Android app developers and system integrators who want to ensure that their apps and customizations work seamlessly across various devices while efficiently interacting with underlying hardware components.

“external”

The “external” directory in the Android Open Source Project (AOSP) codebase is a significant component that houses a wide range of external libraries, tools, and utilities that Android relies on. These external resources are used to build the Android operating system and provide various functionalities. Let’s delve into the “external” directory and understand its significance: Location: The “external” directory is typically located at the root of the AOSP source code repository.

Contents:

The “external” directory contains a diverse set of subdirectories, each containing external libraries, tools, and utilities:

bzip2: This subdirectory includes the source code for the Bzip2 compression utility. Bzip2 is used in the Android build process for compressing and decompressing files. chromium-webview: The “chromium-webview” subdirectory contains the source code for the WebView component, which allows apps to display web content within the app. clang: This subdirectory holds the source code for the Clang compiler, which is used as part of the Android build process for compiling C and C++ code. e2fsprogs: Here, you’ll find the source code for the e2fsprogs package, which provides utilities for working with the ext2, ext3, and ext4 filesystems. icu: The “icu” subdirectory includes the International Components for Unicode (ICU) library, which provides Unicode and globalization support. libpng: This subdirectory contains the source code for the libpng library, used for handling PNG image files. openssl: The “openssl” subdirectory holds the source code for the OpenSSL library, which provides cryptography and secure communication functionality. sqlite: Here, you’ll find the source code for the SQLite database engine, which is used extensively in Android for data storage. valgrind: The “valgrind” subdirectory includes the source code for the Valgrind memory analysis tool, used for debugging and profiling. zlib: This subdirectory contains the source code for the zlib library, used for compression and decompression.

Significance and Learning Opportunities:

Build Process Dependencies: The “external” directory provides the external dependencies required for building the Android operating system. These libraries and tools are integrated into the build process to ensure that the system is built with the necessary functionality. Code Reusability: By utilizing established external libraries, Android can leverage well-tested and widely-used code, saving development effort and ensuring the quality of the resulting system. Security and Stability: External libraries like OpenSSL provide essential security features, ensuring that Android can handle secure communication and cryptography. Interoperability: Libraries like ICU and SQLite enable Android to support various internationalization and database-related features efficiently. Development Tools: Tools like Clang and Valgrind facilitate the development process by providing powerful compilation and debugging capabilities. Maintainability: Utilizing external libraries allows Android to keep its codebase manageable and maintainable by focusing on system-specific code rather than reinventing the wheel for common functionality. Open Source Ecosystem: The inclusion of external libraries showcases Android’s commitment to the open-source philosophy by utilizing and contributing to well-established open-source projects.

Overall, the “external” directory is essential for developers who want to understand how Android integrates external libraries and tools into the build process, ensuring that the resulting operating system is robust, feature-rich, and capable of interacting with a wide range of hardware and software components.

“kernel”

The “kernel” directory in the Android Open Source Project (AOSP) codebase contains the source code for the Linux kernel used in the Android operating system. The Linux kernel is the core component of the operating system that interacts directly with hardware and provides essential services and abstractions to higher-level software layers. Let’s explore the “kernel” directory and understand its significance:

Location: The “kernel” directory is usually located at the root of the AOSP source code repository.

Contents:

The “kernel” directory houses the source code for the Linux kernel, along with various subdirectories and files related to kernel configuration and device-specific adaptations:

arch: This subdirectory contains architecture-specific code for various processor architectures supported by Android devices. For example, ARM, ARM64, x86, and more. block: In the “block” subdirectory, you’ll find code related to block device drivers and I/O subsystems. crypto: This subdirectory contains code related to cryptography and cryptographic algorithms implemented in the kernel. drivers: The “drivers” subdirectory includes device drivers for different hardware components, such as input devices, network interfaces, storage devices, and more. fs: Here, you’ll find code related to filesystems supported by the kernel, such as ext4, FAT, and others. include: The “include” subdirectory holds various kernel header files used by different parts of the kernel and user-space applications. ipc: In the “ipc” subdirectory, you’ll find code related to inter-process communication mechanisms used within the kernel and between user-space and the kernel. kernel: This subdirectory contains core kernel code, including process management, memory management, and kernel initialization. mm: The “mm” (memory management) subdirectory holds code related to memory management, including virtual memory systems and memory allocation. net: Here, you’ll find code related to networking, including network protocols, socket handling, and network device drivers. security: The “security” subdirectory contains code related to security modules and policies implemented in the kernel.

Significance and Learning Opportunities:

Hardware Abstraction: The Linux kernel provides a standardized interface for interacting with hardware components, abstracting away the underlying hardware details. This allows Android to work on various devices with different hardware configurations. Kernel Space vs. User Space: Understanding the kernel directory helps developers distinguish between the kernel space (where the kernel code runs) and the user space (where applications and user-level code run). Device Drivers: The “drivers” subdirectory demonstrates how the kernel communicates with different hardware components through device drivers, enabling access to various hardware features. Process and Memory Management: Exploring the “kernel” and “mm” subdirectories provides insights into how the kernel manages processes, memory, and multitasking. Networking: The “net” subdirectory offers an understanding of networking protocols and how the kernel handles network communication. Filesystems: By examining the “fs” subdirectory, you can learn about the different filesystems supported by the kernel and how the kernel interacts with them. Security: The “security” subdirectory showcases how the kernel enforces security policies and implements security modules.

Overall, the “kernel” directory is essential for developers who want to work on low-level system components, customize the kernel for specific devices, optimize system performance, or understand the interactions between hardware and software in the Android operating system.

Now let’s explore some more important directories in the AOSP source code

1. Device The “device” directory contains device-specific configurations, drivers, and adaptations that tailor the Android system to a particular hardware device. It includes components like kernel configurations, device-specific drivers, and configuration files, allowing manufacturers to customize Android for their devices.

2. Vendor The “vendor” directory holds proprietary files, drivers, and customizations provided by device manufacturers. These components are specific to a particular device vendor and include things like proprietary drivers, vendor-specific system apps, and hardware-related configurations.

3. Bionic The “bionic” directory houses the Bionic C library, which is Android’s standard C library implementation. It provides the fundamental runtime environment for C and C++ code in Android apps and the system, offering features like memory management, threading, and standard C library functions.

4. Frameworks/Base The “frameworks/base” directory is a crucial part of the Android framework, containing core components for the Android system UI and app interactions. It includes system services, UI components, app frameworks, and resources. This directory is vital for app developers to understand how Android’s user interface, system services, and app interaction are structured and implemented.

5. Libcore The “libcore” directory houses the core libraries and classes of the Java programming language that are used within the Android platform. It provides essential Java functionality for Android apps and system components, such as data structures, utilities, and APIs for I/O, networking, and more.

6. System/etc The “system/etc” directory contains system-level configurations and settings that are used during the Android device’s startup and operation. This includes startup scripts, configuration files, and system-wide settings that influence various aspects of the system behavior, like network configurations and system-wide policies.

7. Bootable The “bootable” directory holds components related to the Android system’s boot process. It includes bootloaders, recovery mode components, and the bootloader’s interface to the system. This directory is essential for understanding how the Android device boots up, handles recovery, and manages the initial stages of the operating system’s execution.

8. Bootable/Recovery The “bootable/recovery” directory contains the source code for Android’s recovery mode, which is a separate bootable environment used for system recovery, updates, and maintenance. It includes the recovery user interface, tools for flashing updates, and backup and restore functionalities. This directory is crucial for developers and users to understand how to perform system recovery, install updates, and manage the device’s software.

9. System/SEPolicy The “system/sepolicy” directory holds the SELinux policy configurations for the Android system. SELinux (Security-Enhanced Linux) enforces access controls and security policies at the kernel level. This directory contains the policy rules that define which processes can access specific resources, enhancing the security and isolation of the Android system. Understanding this directory is essential for managing Android’s security model and enforcing access controls.

10. CTS (Compatibility Test Suite) The “cts” directory contains the source code and resources for the Compatibility Test Suite, which is used to ensure that Android devices and software implementations adhere to the compatibility standards set by Google. It includes test cases that cover various aspects of the Android platform, helping manufacturers and developers ensure that their devices and software are compatible with the Android ecosystem.

11. Build The “build” directory holds scripts, configurations, and tools that are essential for building the Android operating system. It includes build configurations, makefiles, and scripts for compiling the source code into executable binaries and system images.

12. Out The “out” directory is the default output directory where the build process generates compiled binaries, libraries, and system images. It contains the results of the build process, including intermediate and final output files, which are crucial for creating Android system images that can be flashed onto devices.

It’s important to note that the directory structure within the Android Open Source Project (AOSP) can vary between different versions of Android and even across different AOSP source codes. As Android evolves and new versions are released, the organization of directories and subdirectories might change to accommodate new features, optimizations, or restructurings. Additionally, device manufacturers and vendors may introduce customizations and modifications that result in differences in the directory hierarchy. Therefore, while the fundamental architecture remains consistent, it’s essential to be mindful that the specific directories and subdirectories discussed here can differ based on the version of Android or the specific AOSP source code being examined. This flexibility ensures that Android remains adaptable to the ever-evolving landscape of hardware, software, and user needs.bin