Android DEX basics and androiddex Basics

Source: Internet
Author: User

Android DEX basics and androiddex Basics
1. What is dex?

To put it simply, optimize android .exe. Each apk installation package is available.
Compared with the Java Virtual Machine on the PC, it can run. class; The Davlik Virtual Machine on android can run. dex.
Why study dex format? Because dex contains all the app code, you can use the decompilation tool to obtain the java source code. Understand and modify the dex file to better crack and prevent apk attacks.

 

2. dex benefits

Dex files have a huge advantage: they can be directly loaded using the DexClassLoader class, which is called dynamic loading. As a result, we only need to shell the dex and get off the shell when the program is running, so we can avoid the risk of static decompilation.

 

3. What is the general decompilation process.

1. Download the apk file and decompress it to obtain the class. dex file.

2. Use dex2jar to restore class. dex to a classes-dex2jar.jar file.

3, with jd-gui.exe to open the classes-dex2jar.jar file, you can see the source code.

 

4. Why is 65536 restriction on Android?

In the Android system, all the code of an App is in a Dex file. Dex is a Jar-like package that stores a lot of archive files for compiling bytecode in Java. Because the Android system uses the Dalvik virtual machine, you need to convert the class file compiled using Java Compiler into the class file that Dalvik can execute. It should be emphasized that Dex is an archive file like Jar, and it is still a bytecode file corresponding to Java code. When the Android system starts an application, one step is to optimize Dex. This process is handled by a dedicated tool called DexOpt. DexOpt is executed when Dex files are loaded for the first time. This process generates an ODEX file, Optimised Dex. Execution of ODex is much more efficient than direct execution of Dex files. However, in the early Android system, DexOpt had a problem, that is, the problem to be explained and solved in this article. DexOpt retrieves the method IDs of each class and stores them in a linked list structure. However, the length of the linked list is saved as a short type, so that the number of method IDs cannot exceed 65536. When a project is large enough, it is clear that the maximum number of methods is not enough. Although DexOpt fixes this issue in the new version of Android, we still need to be compatible with the old system.





Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.