Saturday, 27 January 2018

What is Android Architecture? Discuss Android Architecture in detail.

Android Architecture In Detail:

Android Architecture in details

Android Architecture:

  • Android SDK Compiles our code, data & resources into Android Package file; an APK file
  • APK file contains all the contents of an Android app and is the file that Android-powered devices use to install the app
  • A “SandBox” environment; OS is a multi-user Linux system in which each app is a different user.
  • Every app runs in its own Linux process. 
  • Each process has its own virtual machine (VM), so an app's code runs in isolation from other apps. 
  • Android system implements the principle of least privilege 
  • This creates a very secure environment in which an app cannot access parts of the system for which it is not given permission.
  • An app can request permission to access device data such as the user's contacts, SMS messages and more. All app permissions must be granted by the user at install time. 
  • A unique aspect of the Android system design is that any app can start another app’s component.

Architecture:

Android Architecture by selectiveTopics

  1. Linux Kernel:
  • Works as a Hardware Abstraction Layer (HAL) 
  • Basic system functionality like process management, memory management, device management ,networking ,device drivers Low level Hardware control & interfaces
2. Libraries

  • C/C++ libraries ; Interface through Java 
  • Surface manager – Handling UI Windows 
  • 2D and 3D Graphics 
  • Media codecs, SQLite, Browser engine 
  • libraries to play and record audio & video 
  • SSL libraries for Internet security

3. Android Runtime

  • Dalvik Virtual Machine which is a kind of Java Virtual Machine specially designed and optimized for Android 
  1. –Dex files 
  2. –Compact and efficient than class files 
  3. –Limited memory and battery power 
  • Core Libraries 
  1. –Java libs 
  2. –Collections, I/O etc…

4. Application Framework:

  • API interface 
  • Activity manager – manages application life cycle. 
  • The Application Framework layer provides many higher-level services to applications in the form of Java classes. Application developers are allowed to make use of these services in their applications.

5. Build System:

  • Customize, configure, and extend the build process. 
  • Create multiple APKs for your app with different features using the same project and modules. Reuse code and resources across source sets. 
  • The apk file for each app contains all of the information necessary to run your application on a device or emulator, such as compiled .dex files (.class files converted to Dalvik byte code), a binary version of the AndroidManifest.xml file, compiled resources (resources.arsc) and uncompiled resource files for your application.
build System in Android by selectivetopics.blogspot.com




  • The build system merges all the resources from the configured product flavors, build types, and dependencies. 
  • The Android Asset Packaging Tool (aapt) takes your application resource files, such as the AndroidManifest.xml file and the XML files for your Activities, and compiles them. An R.java is also produced so you can reference your resources from your Java code. 
  • The aidl tool converts any .aidl interfaces that you have into Java interfaces.
  • All of your Java code, including R.java and .aidl files, are compiled by the Java compiler and .class files are output. 
  • The dex tool converts the .class files to Dalvik byte code. Any 3rd party libraries and .class files that you have included in your module build are also converted into .dex files so that they can be packaged into the final .apk file.
  • All non-compiled resources (such as images), compiled resources, and the .dex files are sent to the apkbuilder tool to be packaged into an .apk file. 
  • Once the .apk is built, it must be signed with either a debug or release key before it can be installed to a device. 
  • Finally, if the application is being signed in release mode, you must align the .apk with the zipalign tool. Aligning the final .apk decreases memory usage when the application is -running on a device.
  • Apps are packaged in .apk format, variant of .jar, then downloaded to device and installed 
  • .apks contain .dex files (bytecode), manifest and various other files 
    1. Manifest contains security and link info, hardware access info, minimum OS release info, etc. 
  • Apps run on the Dalvik Virtual Machine 
    1. Not a JVM, but works similarly from developer’s point of view 
    2. Usually one app per DVM 
    3. Each DVM runs under Linux as a separate user 
    4. App permissions set at install time

1 comment: