Run the Application

1. App launch request

Zygote process is the parent to all Android apps and it launches an application when a user makes the request to do so. The zygote is a special kind of Android OS process which enables code sharing between different instances that run across Android virtual devices(Dalvik/Android Runtime). Those resources, classes, and code libraries which possibly required by any application at runtime are preloaded in the memory space of the zygote process. Whenever the process gets a request to launch a new application, it forks itself(creates a copy) using the fork system call(android is a Linux system) and starts the new app. The preloaded libraries and resources are the reason for efficient and fast app launch in android.   

2. Conversion of the .dex code to native OAT format

When a new application is installed, the Android optimize the app data and generates a corresponding OAT file. This file is created by the Android OS to accelerate the application loading time. The process to generate the OAT file starts with the extraction of classes.dex file present inside the .apk file of the application. The classes.dex file is placed in a separate directory and Android compiles the Dalvik byte-code with ahead-of-time(AOT, also abbreviated as OAT) compilation into native machine code. Android system uses this native OAT file to enhance the user experience by loading the application quickly and smoothly. 

Before AOT came into the picture, dexopt tool is used to convert the .dex files into .odex file(optimized DEX) that holds the optimized byte-code. With the introduction of AOT in Android, dex2oat tool converts and optimize the .dex file into an OAT file format that holds machine code written in ELF format(Executable and Linkable Format). This native library is then mapped into the memory of the application process. OAT files are generally saved in the Android device in the directory: /data/dalvik-cache/

After following all these steps and procedures, the application will finally start and the initial activity of the app will appear on the device screen.



How Does Android App Work?

Developing an android application involves several processes that happen in a sequential manner. After writing the source code files, when developers click the Run button on the Android studio, plenty of operations and process starts at the backend. Every operation happening in the background is a crucial step and are interdependent. The IDE builds all the application files, make them device compatible in order to deploy, and assure that the application runs successfully on the device. This article broadly explains each and every critical step involved in the journey of an android app, from the IDE files to a working device application.   

Similar Reads

Step 1: Building the APK File

1. Code Compilation...

Step 2: Deploy the Application

1. Establish the ADB Server...

Step 3: Run the Application

1. App launch request...

Contact Us