Android runs on the android runtime called DVM(Dalvik Virtual Machine), which is built on top of the Linux kernel. Android running on DVM has major components that are divided into separate areas.
The application area contains applications developed in Java. It includes applications such as email clients, SMS programs, calendars, maps, browsers, address books, and other custom applications developed in Java.
The application framework provides the various APIs needed to develop applications. You can use the various APIs in this area to represent buttons, text, and so on, or to use data from other applications such as address books. It also manages the lifecycle of an application by accessing multiple data, such as images or strings, or through the API.
The library provides a variety of C/C++ libraries available on Android. All of the libraries in this area are available to developers through the application framework.
The library has a standard C system library based on BSD, modified for embedded Linux based devices. It also includes Media Library based on PacketVideo’s OpenCore, which can support files such as MPEG4, H.264, MP3, AAC, AMR, JPG and PNG.
The Surface Manager library supports 2D and 3D graphics, and the WebKit library supports browser functionality. In the library area also provides SQLite, a database engine developed for embedded use.
The Android runtime runs on Java but uses the Dalvik Virtual Machine(DVM) instead of the Java Virtual Machine(JVM).
DVM converts the source code(.java) written in Java into a class file(.class) through the Java compiler. And the class file is converted to Dakvik byte code by the DX compiler.
In other words, the Java source code is stored as an executable(.dex, Dalvik Executable) and an optimized executable(.odex, Optimized Dalvik Executable), which runs on your Android device.
Android 4.4(KitKat) Previously it was based on Dalvik, but ART(Android Run Time) was introduced from 4.4 version. Since Android 5.0(Lollipop) has been changed to work based on ART.
ART(Android Run Time) has the following advantages and uses the same bytecode as Dalvik for backward compatibility.
- AOT(Ahead-of-time) Compile
- Improved garbage collection
- Improved debugging support
Dalvik uses a just-in-time(JIT) compilation method that changes the bytecode to machine code each time the app is run. The JIT compilation method requires additional memory to convert the bytecode to machine code.
The Ahead-of-time(AOT) method converts DEX bytecode to machine code when the app is installed, without converting the code when the app is run. This method has the disadvantage of lengthening the installation time but it has the advantage of shortening the execution time.
Android is based on Linux kernel 3.0.1(Android 4.0) and provides various drivers such as security, memory management, process management, and network stack.