Android Fundamentals
Android
● OS
– Linux Kernel
● Original version: 2.6
● Current versions: 4.14, 4.19, 5.4
– Customized device drivers
– Bionic libc
– Other libraries (e.g. SqlLite, Webkit, OpenGL, SSL, etc)
● Development Environment
– Dalvik VM / ART
– Core libraries
– Application framework
Architecture diagram
Differences with Linux and Java
● Linux
– Kernel
● Power management
● Memory management
● IPC
● Other device drivers
– Libc
● Bionic
● Java
– Execution Environment
● Standard JVM vs Dalvik VM
– Libraries
● Android libraries added
● Some standard Java libraries not supported (Swing, AWT, etc.)
Bionic
● Standard C library for Android
– Partly based upon BSD libc
● Primary features
– License
– Size
– Speed
● Other aspects
– Not fully POSIX compliant
– Compatible toolchain required to develop programs
Dalvik VM
● Introduction
– JVM optimized for low-powered, low-memory devices
– created by Dan Bornstein at Google / Android
– named Dalvik after a village in Iceland
● Technical Architecture
– Register-based (in contrast to stack-based)
● Fewer instructions, fewer dispatches
● Make use of optimizations and exploit RISC hardware (where possible)
● Average instruction size is larger
● Overall program size is marginally larger
– DEX bytecode format (vs Java bytecode format)
● Optimized for minimal memory footprint
Compilation and Execution
ART (Android Runtime)
● Replaces Dalvik VM, starting from Android 5.0
● Uses an idea of Ahead Of Time (AOT) compilation
– compile bytecode into native code at the time of installation
– Optimizations according to underlying hardware platform (e.g.
ARM, x86, etc)
– Interpretation is not required
● Uses same DEX format for compatibility
– Input DEX bytecode
– Output Linux ELF
● Implications
– App installation takes more time
– Slightly more storage space required
APK
● Packaging format for Android
– Archive file
– Combines executables and other resources
Android SDK
● Build tools
– dx : Java to DEX bytecode compiler
– aapt : Archives files in APK format
– …
● Platform and other tools
– adb : Android debug bridge for communicating with emulator
or other connected android devices
– emulator : emulate android devices on your machine
– …
● IDE and Build Management
– Gradle: manage build workflows
– Android Studio: integrates all SDK components and Gradle to
provide an easy to use development environment