
Lập trình Mobile - Android
Android has undergone several major runtime changes since its inception. The most significant shift occurred with the introduction of Android Runtime (ART) in Android 5.0 Lollipop . Unlike…

Trong kiến trúc Android, lớp nào chịu trách nhiệm cung cấp API cho giao diện người dùng và quản lý vòng đời ứng dụng?
Theo dữ liệu năm 2017, số lượng ứng dụng trên Android Market (Google Play) khoảng bao nhiêu?
Trong lớp Linux Kernel của Android, chức năng nào không thuộc trách nhiệm của nó?
Trong Android, file .apk tương tự nhất với định dạng nào của Java?
Trong bảng thống kê thị phần hệ điều hành di động năm 2016 Q4, hệ điều hành nào chiếm khoảng 18%?
Trong Android Development Environment, công cụ nào được dùng để tạo và chạy các ứng dụng trên máy ảo?
Trong mô hình 5 lớp của Android, lớp nào nằm ngay trên Linux Kernel?
Trong Android, Intent được dùng để:
Trong Android, lớp nào chịu trách nhiệm cho việc xử lý đa phương tiện như video và âm thanh?
Understanding Android Runtime (ART) and Its Evolution
Android has undergone several major runtime changes since its inception. The most significant shift occurred with the introduction of Android Runtime (ART) in Android 5.0 Lollipop. Unlike its predecessor Dalvik, ART uses ahead‑of‑time (AOT) compilation, which translates bytecode into native machine code during app installation. This results in faster execution, reduced battery consumption, and smoother user experiences.
- Key Benefits of ART:
- Improved app launch speed
- Lower CPU usage during runtime
- Enhanced garbage collection efficiency
- Transition Timeline:
- Android 4.4 (KitKat) – Dalvik remains default, ART optional for developers.
- Android 5.0 (Lollipop) – ART becomes the default runtime.
- Subsequent releases – Continuous optimizations such as profile‑guided compilation and JIT/AOT hybrid approaches.
Android Architecture: The Five‑Layer Model
Android’s architecture is organized into five logical layers, each providing specific services and abstractions. Understanding these layers is essential for any mobile developer.
1. Linux Kernel
The foundation of Android is the Linux Kernel. It handles low‑level hardware interactions, including:
- Process management
- Memory allocation
- Power management
- Network stack
Note: The kernel does not provide UI APIs – that responsibility belongs to higher layers.
2. Native Libraries
Directly above the kernel, Android includes a set of C/C++ libraries such as libc, OpenGL ES, and WebKit. These libraries enable high‑performance graphics, audio processing, and other native functionalities. Developers can access them via the Java Native Interface (JNI).
3. Android Runtime (ART)
ART sits on top of the native libraries and provides the execution environment for Java/Kotlin code. It includes core components like the core libraries, the dex optimizer, and the garbage collector. The shift from Dalvik to ART marked a major performance milestone for the platform.
4. Application Framework
The Application Framework layer offers high‑level APIs that developers use to build user interfaces, manage resources, and control the application lifecycle. Key services include:
- Window Manager
- View System
- Content Providers
- Activity Manager
- Resource Manager
This layer abstracts the complexities of the lower layers, allowing developers to focus on app logic rather than hardware details.
5. Applications
At the top of the stack are the end‑user applications—both system apps (e.g., Phone, Settings) and third‑party apps downloaded from Google Play. These apps are packaged as .apk files, which we’ll explore next.
APK Files: The Android Equivalent of Java JARs
An .apk (Android Package) is essentially a compressed archive that contains compiled bytecode, resources, assets, and a manifest file. Its structure mirrors the Java .jar format, which also bundles compiled .class files and libraries.
Why the comparison matters:
- Both formats are used for distribution and deployment of applications.
- They rely on the Java Virtual Machine (or ART) to execute the contained bytecode.
- Understanding the
.jarconcept helps developers grasp how Android packages are built and signed.
When you build an Android app, the Gradle build system compiles your Kotlin/Java source into .dex files, then packages them with resources into an .apk. This .apk can be installed on any compatible Android device, just as a .jar can be run on any Java‑enabled platform.
Market Landscape: Android Apps and OS Share
Knowing the scale of the Android ecosystem provides context for why developers invest time in mastering its architecture.
Number of Apps on Google Play (2017)
According to 2017 statistics, the Google Play Store hosted approximately 3.3 million applications. This massive catalog demonstrates the platform’s openness and the competitive environment developers face.
Mobile OS Market Share (Q4 2016)
In the fourth quarter of 2016, the mobile operating system market was dominated by Android, but iOS captured around 18% of global market share. This figure highlights the importance of cross‑platform considerations and the need for developers to understand both ecosystems.
Development Tools: Android Emulator
To develop and test Android applications efficiently, developers rely on the Android Emulator. Part of the Android SDK, the emulator provides a virtual device that mimics real hardware, allowing you to:
- Run apps without a physical device.
- Test different screen sizes, Android versions, and hardware configurations.
- Debug performance issues using built‑in profiling tools.
Other tools such as ADB (Android Debug Bridge) facilitate communication between your development machine and the emulator or a physical device, but the emulator itself is the primary environment for creating and launching apps during development.
Key Takeaways for Mobile Developers
- ART replaced Dalvik starting with Android 5.0 Lollipop, offering AOT compilation and better performance.
- The Application Framework layer supplies the UI API and lifecycle management that developers interact with daily.
- The Linux Kernel handles low‑level tasks like memory and power management, but does not provide UI services.
- An
.apkis the Android counterpart of a Java.jar, bundling compiled code and resources for distribution. - As of 2017, Google Play contained roughly 3.3 million apps, reflecting a vibrant developer community.
- In Q4 2016, iOS held about 18% market share, underscoring the relevance of multi‑platform strategies.
- The Android Emulator is the essential tool for testing apps across diverse device configurations.
Further Learning Resources
To deepen your understanding, explore the following official and community resources:
- Android Runtime (ART) Overview
- Application Fundamentals
- Android Open Source Project (AOSP) – Kernel Documentation
- Using the Android Emulator
- Google Play App Statistics (2024 update)
