Android Reverse Base----APK file structure

Source: Internet
Author: User

Refer to this Blog

Http://www.cnblogs.com/wangtianxj/archive/2010/06/13/1757639.html

APK file Structure:

Androidmanifest.xml Configuration Checklist

Meta-inf Signature

Assets Resources

Classes.dex Java bytecode files generated after source compilation

RES Resource Library

LIB Native dynamic library so

Smali Classes.dex

RESOURCES.ARSC files that record the correspondence between these IDs and the resource file location

APKTOOL.YML re-packaging must file

Meta-inf Directory: The signature information is stored to ensure the integrity of the APK package and the security of the system.

When compiling an API package, a checksum calculation is done for all files to be packaged, and the results are placed in the Meta-inf directory. When installing, this apk will not be installed if the checksum results are inconsistent with the content under Meta-inf. Ensure that the files in the APK package cannot be replaced arbitrarily.

The files contained in the Meta-inf directory are cert.rsa,cert.dsa,cert.sf and MANIFEST.MF.

CERT. Rsa

Is the signature file that the developer signed the APK with the private key

CERT. Sf,manifest. Mf

SHA-1 hashes of files in files are logged

Assets directory: Used to store static files that need to be packaged into the APK

The assets directory supports subdirectories of any depth, and users can deploy the folder schema as they want.

and the files in the Res directory will be in the. The corresponding resource id,assets generated in the R file does not automatically generate the corresponding ID, and the Assetmanager class is required for access.

Lib directory: This is where the application relies on the native library file, usually written in C + +, here The Lib library may contain 4 different types, depending on the CPU model, can be divided into ARM architecture, ARM-V7A architecture, MIPS architecture and X86 architecture.

Different CPU architectures correspond to different directories, the current mobile terminal used in the market is based on arm or arm-v7a architecture, X86 and MIPS architecture of mobile intelligent terminal is relatively small, these four directories to choose according to the CPU architecture, and the market arm architecture of mobile phones accounted for the majority, So the general apk contains only arm and arm-v7a so.

Res directory: RES is an abbreviation for resource, which holds resource files, All files that exist in this folder will be mapped to the. r file of the Android project, generating the corresponding ID, which can contain multiple folders when accessed directly using the resource ID, which is the R.id.filename,res folder.

Filename

Store content

Anim

storing animated files;

Drawable

Directory to store image resources;

Layout

Directory to store layout files;

Values

The directory holds some eigenvalues;

Colors.xml

Store color value;

Dimens.xml

Define dimension values;

String.xml

Defines the value of the string;

Styles.xml

Defines the style object;

Xml

The folder holds arbitrary XML files, which can be read by Resources.getxml () at run time;

Raw

are arbitrary files that can be copied directly to the device without compiling them.

Androidmanifest.xml: Is the android application configuration file, is a profile to describe the Android app "overall information", the Android system can be based on this "self-introduction" to fully understand the APK app information, Each Android application must contain a androidmanifest.xml file, and its name is fixed and cannot be modified. When we develop Android applications, we generally put every single activity,service in the Code, Provider and receiver are registered in the Androidmanifest.xml, so that the system can start the corresponding component, and this file also contains some permission statements and the SDK version information used, and so on. When the program is packaged, Androidmanifest.xml is compiled in a simple, easy-to-Android system, and the compiled format is the axml format, as shown in 1:

Figure 1 Axml format

Axml Head

Where the Axml header is fixed to identify the Axml file, its value is fixed when 0x00080003.

Axml file length

Identifies the size of the Axml file.

Stringdatasegment

All string types in the XML file are saved here.

Resourceidsegment

The resource file ID declared in the XML file is saved here.

Xmlcontentsegment

is the content segment of XML, followed by the structure in the XML file, to save the XML data content.

Classes.dex:

In the traditional Java program, the Java file is first compiled into a class file, the bytecode is stored in the class file, and the Java virtual machine can execute these class files by explanation. While the Dalvik virtual machine is optimized in the Java Virtual machine, the execution is Dalvik bytecode, and these Dalvik bytecode is converted from Java bytecode, in general, Android apps use the DX tool in ANDROIDSDK to convert Java bytecode to Dalvik bytecode while packaging. The DX tool can merge, reorganize, and optimize multiple class files to reduce the volume and shorten the running time. The conversion process for the DX tool is shown in 2:

Figure 2 DX tool converts. class files to Dex files

The DX tool resets the contents of each area of each. class file, reorganizes, and optimizes the reflow to generate the Dex file, which can be executed at the Dalvik virtual machine and is faster.

RESOURCES.ARSC: Used to record the mapping between resource files and resource IDs to find resources based on resource IDs. Android Development is a sub-module, the Res directory is dedicated to storing resource files, when the code needs to call the resource file, only need to call Findviewbyid () to get the resource file, whenever a file in the Res folder, AAPT will automatically generate the corresponding ID saved in the. r file, we call this ID can be, but only this ID is not enough,. r file just to ensure that the compiler does not error, in fact, when the program is running, the system will be based on the ID to find the corresponding resource path, and the RESOURCES.ARSC file is used to record these IDs and resources File location corresponding to the relationship.

Android Reverse Base----APK file structure

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.