Android - Concepts

Last Updated: 2021-11-19

Android Runtime vs Dalvik VM

In Android 5.0, Android Runtime with ahead-of-time compilation replaces the Dalvik VM with just-in-time compilation introduced in Android 2.2.


NDK is for native code(C/C++), while SDK is for Java.

Bionic vs NDK

Platform code uses bionic, while third-party developers use NDK.

OpenGL ES vs Vulkan

Vulkan is the replacement of OpenGL. Android started to support Vulkan since Android N


  • AAR: a JAR + resources, also based on ZIP, for library modules
  • APK: packages, for app modules

Android App Bundle(.aab) vs Android PacKage(.apk)

  • App Bundle cannot be deployed to a device, it is an upload format(upload to play store); APK is the deploy/download format(download from play store to device).
  • Play store will auto-generate a basic APK, multiple configuration APKs and multiple dynamic feature APKs from an uploaded App Bundle
  • Android App Bundle frees the developers from building, signing, and managing multiple APKs to support different devices; users get smaller, more optimized downloads
  • Android App Bundles do not support APK expansion (*.obb) files

Google Mobile Services vs Google Play Services

Google Mobile Services refers to the pre-installed Google closed-source apps, like Google Search, Chrome, YouTube, Google Maps, etc.

Google Play Services refers to an app, which provides backend services and APIs, e.g. single sign-on, security, location services. It is confusingly under com.google.android.gms, since the internal name is gmscore.

GoogleApi vs GoogleApiClient

GoogleApi is the new interface, replacing GoogleApiClient.

However the naming is confusing, e.g. FusedLocationProviderApi is based on the old GoogleApiClient, while the new GoogleApi based interfaced is called FusedLocationProviderClient.


Android Expansion Files


  • Obfuscator and optimizer for Java bytecode
  • ProGuard is the free version, a default tool in Android SDK, later replaced by R8
  • DexGuard is the paid version, with extra security layers on top of ProGuard


  • SQLite
  • LevelDB


Looper/Handler/Message/MessageQueue: how Android solves the problem of async programming.

How it works:

  • a Thread gets a Looper and a MessageQueue by calling Looper.prepare()
  • A Handler gets implicitly associated with the thread that instantiates it via thread's Looper
  • Handler will enqueue the Message to the MessageQueue: handler.sendMessage(msg) or handler.post(runnable)
  • Looper.loop() will start an infinite loop for(;;) {}, must be called to start the associated looper.
  • Get next message from the MessageQueue: Message msg = queue.next();, this may block if the next Message is not ready to be processed.
  • pass the message to Handler to execute: msg.target.dispatchMessage(msg), where msg.target will get the Handler
  • looper must be terminated explicitly: looper.quit()

Other notes:

  • HandlerThread: just a Thread with a Looper. A Handler needs a Looper to work.
  • the main thread is built with a Looper and Handlers. Android prevents from updating UI components from most threads. A separate thread can update the UI by using Looper and Handler. No need to lock access to UI components.
  • get Looper in the main thread: Looper.getMainLooper()
  • post to the main thread MessageQueue and execute in the main thread: new Handler(Looper.getMainLooper()).post(new Runnable() {...})

Building Blocks

  • Intent can be used in
    • Activity: a subclass of Context; Activity#startActivity takes an Intent as input
    • Service: another subclass of Context; Services can be started with Context.startService() and Context.bindService(); A Service is NOT a separate process or a thread.
    • broadcast: Context#sendBroadcast(intent) to any BroadcastReceiver
  • Intent and ContentProvider are higher-level abstractions of Binder
  • ContentProvider is only required if you need to share data between multiple applications. If you don't need to share data amongst multiple applications you can use a database directly via SQLiteDatabase.
  • IBinder is the base interface for a remotable object, the core part of a lightweight RPC mechanism; Binder is a class implementing IBinder


  • Parcelable: Android's serializable
  • Parcel: a message container
  • Bundle: stores heterogeneous data(map from String to different types of Parcelable)

Android UI Toolkit

UI related packages:

  • android.widget
  • android.view


  • Main-thread, usually the UI thread
  • worker-threads: working on network access, database queries, respond to system callbacks(like button push onKeyDown()) etc.


  • AIDL is for IPC within Android Framework
  • HIDL is for IPC between HAL and Android Framework. Started from Android 8, so HAL no longer needs to recompile to adopt a new version of Android Framework. Android framework and HALs communicate with each other using Binder IPC calls.
  • Both related to Binder IPC

HIDL HALs guarantee the Android core system/platform(system.img) is backward compatible. Vendors build their images(vendor.img, boot.img) then update them independent of the platform. It is possible to have newer platform version running on the device, vendor images cannot have a newer version than the platform.


  • SDK: for developing Android apps
  • NDK: for using native code
  • PDK: (P=platform) a subset of the new Android release so SoC vendors and OEMs can start adoption and migration before it is released. Only the necessary components for developing HAL.

Platform vs Framework

Platform is the whole, while Framework refers to Java APIs.



  • OEM: Original equipment manufacturer, produces parts and equipment that may be marketed by another manufacturer, e.g. iPhone designed by Apple, manufactured by Foxconn(OEM).
  • ODM: Original design manufacturer, designs and manufactures a product, as specified, that is eventually rebranded by another firm for sale. e.g. phones designed and manufactured in China get rebranded and sold in India.
  • SoC: system-on-a-chip, e.g. Apple's A series chips found in iPhones, or Qualcomm's Snapdragon.

Android O splits the monolithic Android OS into generic (system.img) and hardware-specific (vendor.img and odm.img) partitions. Conditional compilation was removed from system partition.

Future Android: single SoC kernel; OEM/ODM may add additional modules or override configs for different devices.

App Folder

  • AndroidManifest.xml: metadata, e.g. required permissions, activities, etc.
  • res/layout/layout_file_name.xml: layout files, can be accessed by R.layout.layout_file_name within Java or Kotlin code
  • Java or Kotlin code: logic


Android 9 must use system-as-root.

A/B devices that re-purpose /boot as the recovery partition and removed cache partition. system.img is mounted as rootfs.

  • CTS: compatibility tests
  • GSI: Generic System Image, for testing(CTS and VTS). If your app works in GSI, it works for all compliant devices.