When optimizing the Android DEX file, you must note that the DEX file structure is compact, but we still need to find ways to improve the running speed of the program, we still need to further optimize the DEX file.
Adjust the byte order of all fields LITTLE_ENDIAN) and none of the fields in the alignment structure verify that all classes in the DEX file optimize some specific classes and optimize the operation codes in the methods. The optimized file size will increase, which should be 1-4 times that of the original Android DEX file. There are two optimization scenarios: For a preset application, you can generate an optimization file after the system compilation, ending with ODEX.
In this way, in addition to the APK file does not include DEX), there is a corresponding Android DEX file. For non-preset applications, the DEX file contained in the APK file will be optimized at runtime, and the optimized file will be saved in the cache.
Each Android Application runs in a Dalvik Virtual Machine instance, and each virtual machine instance is an independent process space. The thread mechanism, memory allocation and management, and Mutex of virtual machines depend on the underlying operating system.
All Android Application threads correspond to a Linux thread. Therefore, virtual machines can rely more on the thread scheduling and management mechanisms of the operating system.
Different applications run in different process spaces. In addition, different Linux users are used for applications from different sources to maximize the Security and independent operation of applications.
Zygote is a virtual machine process and also an incubator for Virtual Machine instances. Whenever the system requires an Android Application to be executed, Zygote will generate a sub-process to execute the application. The advantages of doing so are obvious: the Zygote process is generated when the system starts. It completes VM initialization, Library Loading, loading and initialization of Preset class libraries, and so on, when the system needs a new Virtual Machine instance.
Zygote provides the fastest system by replicating itself. In addition, for some read-only system libraries, All VM instances share a memory area with Zygote, greatly saving the memory overhead. Android Application Development and Dalvik Virtual Machine Android applications use the Java programming language. Like Java SE, Sun JDK is used to program Java source programs into standard Java bytecode files during compilation. class file ).
Then, convert all bytecode files to Android DEX file classes. dex through the tool software DX ). Finally, use the Android packaging tool aapt) to combine DEX files, resource files, and binary formats of AndroidManifest. xml files into an application package APK ). Application packages can be published to mobile phones for running.