Android Architecture

Before diving into serious development, it’s a nice idea to know what’s under the hood of the platform we’re developing apps for. As an android user, you know how to do all kinds of things on an Android device. It’s not enough for a developer. We should know all the key concepts of Android OS.  Here we will explore the Android architecture in detail. By the term Android architecture, I mean the building blocks of the Android OS.

Android Architecture Diagram:

Before you start looking at the diagram, keep these points in your mind.

  1. Android OS is made of different layers of software. All operating systems are like that.
  2. Each layer provides various services to the layer just above it.
  3. Together it will make the OS, middleware, and applications.
  4. The lower-most layer interacts with the hardware.
  5. The upper-most layer interacts with the user.
  6. Each layer abstracts the complex implementation details to the layers above it.

The concept of abstraction may be a bit hard to understand at first. But once you get a grip on it, it’s really simple. Consider the case of Bluetooth file transfer. It is the layer that interacts with the Bluetooth hardware that ultimately sends or receives a file. The upper layer just tells the lower layer that it wants to send these bits to another device. It doesn’t have to know, how it is done. Each layer abstracts implementation details like this. Ultimately, the user doesn’t have to know any of these implementation details.

Now take a look at the diagram:

android architecture

So, the layers we said above are:

  • Linux Kernel
  • Hardware Abstraction Layer
  • Android Runtime
  • Native C/C++ Libraries
  • Java API framework
  • System Apps

The apps that we develop will go to the System Apps layer.

Now we will look at each of these layers in detail:

1. Linux Kernel

The basic layer is the Linux Kernel. The whole Android OS is built on top of the Linux Kernel with some further architectural changes. Please don’t get confused by the terms Linux OS and Linux Kernel.  The term Kernel means the core of any Operating System. By saying Android is based upon Linux Kernel, it doesn’t mean that it is another Linux distribution. It is not like that. It simply means Android at its core is Linux. But you can’t run any Linux packages on Android. It is a totally different OS.

It is this Linux kernel that interacts with the hardware and it contains all the essential hardware drivers. Drivers are programs that control and communicate with the hardware. For example, consider the WiFi feature. All devices have a WiFi hardware in it. Therefore the kernel must include a WiFi driver to communicate with the WiFi hardware.   As the Android is built on a most popular and proven foundation, the porting of Android to a variety of hardware became a relatively painless task.

2. Hardware Abstraction Layer (HAL)

It is the Hardware Abstraction Layer that provides an abstraction between device’s hardware and higher level layers. It acts as an interface between the device’s hardware and the software APIs. Consider this case. You’re developing an app which uses the camera. Your app calls the camera API in the Android system. It is the camera module in the HAL, that calls the device’s camera hardware on behalf of the API.

(API stands for Application Programming Interface. It is a software interface between two software components. APIs are provided by the developer of a software component to let others use that software feature in the software applications they build. For example, consider Google maps. The google maps provide several APIs so that we can integrate Google maps to the application we build).

3. Android Runtime (ART)

Android uses a type of Java Virtual Machine (JVM) called ART (Android Run Time). Earlier, the VM was known as Dalvik Virtual Machine. In devices running Android 5.0(Lollipop) or higher, the Dalvik Virtual Machine is completely replaced by ART. ART has many advantages over Dalvik VM such as AOT (Ahead Of Time) compilation and improved garbage collection which boosts the performance of apps significantly.

If you don’t know what is a Virtual Machine, then don’t worry. It’s not that complicated as it sounds. Think of virtual machine as a birds cage. The bird is free to move wherever inside the cage, but not outside. The bird is the app that we write and the cage is the virtual machine. The cage has some openings through which the bird receives food and water. Like that, the virtual machine gives permission to the apps to do certain things. The app can’t go beyond the virtual machine. Java uses a virtual machine for the execution called Java Virtual Machine (JVM). When we’re installing Java Runtime Environment (JRE) in our system, we’re actually setting up a JVM.

4. Native C/C++  Libraries

Many core system components in Android are developed using components that are written in C/C++. These are libraries written in C/ C++. One advantage of using C/C++ over the use of Java is the performance. When executing CPU intensive tasks, native code written in C/C++ always fare better. The Java API libraries use these native libraries for various functions.

Some of the important native libraries include the following:

Media framework: Media framework provides different media codecs allowing the recording and playback of different media formats

SQLite: SQLite is the database engine used in Android for data storage purposes

WebKit: It is the browser engine used to display HTML content

OpenGL: Used to render 2D or 3D graphics content to the screen

5. Java API Framework

These are the blocks that our applications directly interacts with. These programs manage the basic functions of the phone like resource management, voice call management etc. As a developer, you just consider these are some basic tools with which we are building our applications.

Important blocks of Application framework are:

Activity Manager: Manages the activity lifecycle of activities

Content Providers: Manage the data sharing between applications

Telephony Manager: Manages all voice calls. We use the telephony manager if we want to access voice calls in our application.

Location Manager: Location management, using GPS or cell tower

Resource Manager: Manage the various types of resources we use in our Application

6. System Apps

Applications are the top layer in the Android architecture and this is where our applications are gonna fit in. Several standard applications come pre-installed with every device, such as:

  • SMS client app
  • Dialer
  • Web browser
  • Contact manager

As a developer we are able to write an app which replaces any existing system app. That is, we’re not limited in accessing any particular feature. You’re practically limitless and can do whatever you want to with the Android (as long as the users of your app permit it). Thus Android is opening endless opportunities to the developer.

Hi, I’m Shiju P John. A Computer Science Engineering student. I run this site as my hobby and passion.

Leave a Reply