Detailed description of the Andriod APK file structure, andriodapk

Source: Internet
Author: User

Detailed description of the Andriod APK file structure, andriodapk

APK file structure

The APK file is actually a zip package and can be unzipped.

The structure of the APK package is as follows:

| -- AndroidManifest. xml

| -- META-INF

| -- CERT. RSA

| -- CERT. SF

| '-- MANIFEST. MF

| -- Classes. dex

| -- Res

| -- Drawable

| '-- Icon.png

| '-- Layout

| '-- Main. xml

'-- Resources. arsc


Manifest File

AndroidManifest. xml must be defined and contained by each application. It describes the application name, version, permission, referenced library file, and other information. For example, to upload an apk to Google Market, configure the xml file. There is a lot of information on the Internet, so I will not introduce it more here.


AndroidManifest. xml in the apk is compressed and can be unzipped using the AXMLPrinter2 tool. The specific command is:

Java-jar AXMLPrinter2.jar AndroidManifest. xml


META-INF directory

The META-INF directory stores signature information to ensure the integrity of the apk package and system security.

When eclipse compiles an apk package, it will do a verification calculation for all the files to be packaged, and put the calculation result under the META-INF directory. When the apk package is installed on the Android phone, the application manager will verify the file in the package according to the same algorithm. If the verification result is inconsistent with the content in the META-INF, the system will not install this apk. This ensures that the files in the apk package cannot be replaced at will. For example, after obtaining an apk package, if you want to replace an image, a piece of code, or a piece of copyright information, it is basically impossible to directly decompress, replace, and re-package the package. This increases the difficulty of virus infection and malicious modification, and helps protect the security of the system.


Classes. dex File

Classes. dex is a java bytecode file generated after java source code compilation. However, because the dalvik Virtual Machine Used by Android is incompatible with the standard Java virtual machine, the dex file is different from the class file, regardless of the file structure or opcode.


Res directory

The res directory stores resource files.


Resources. arsc

The compiled binary resource file. Generally, localized and Chinese resources are stored in this file.




What are the file types in the Android APK package?

The structure of an APK file is: res/directory that stores resource files META-INF/Jar files can often see resources. arsc compiled binary resource files, mainly use strings in the program! AndroidManifest. the global configuration file classes for the xml program. dex Dalvik bytecode file. The JAVA file we wrote is compiled into the byte code in DEX format. In summary, we found that Android requires UnZip before running a program, and then directly like Symbian, it is different from the PE file in Windows Mobile. In this way, the confidentiality and reliability of the program are not very high. The dexdump command can be used to decompile the program, but this is in line with the development rules, microsoft's Windows Gadgets or WPF also adopts this architecture. 1. java file ----- application source file I think this is what you heard when you heard about android, A considerable part of android is written in java (the blue part in the basic shelving diagram is developed in Java), and android applications must be developed in java. 2. Class file ------ the target file after Java compilation is not as J2se as we usually use. java can be directly compiled into a class, and class files on android platforms cannot be directly run on android. Because Google uses its own Dalvik to run applications, the class here certainly cannot be run in sun's java environment, I personally feel that the android class file is actually only the intermediate target file during compilation. It must be linked to the dex file before it can run on dalvik. 3. dex file ----- the executable file supported by the Android Virtual Machine Dalvik on the Android platform. Google uses its own Dalvik Virtual Machine to define the file format on the newly released Android platform, this type of virtual machine does not execute Java bytecode, but another bytecode: dex format bytecode. After compiling Java code, you can use tools on the Android platform to convert Java bytecode into Dex bytecode. Although Google claims that Dalvik is customized for mobile devices, many people in the industry think it is to avoid applying for a Java license from sun. Since there are not many details available, we still cannot find the specific implementation of Dalvik. We can only do some simple analysis based on the SDK. This Dalvik VM is optimized for Mobile Phone programs/CPUs. It can execute many VMS at the same time without occupying too much Resource. The source of the Dalvik VM is not yet open for download (the entire system will be available in the future ), at present, Google hopes to allow everyone to use this SDK to start developing AP, and the underlying things will be released slowly. 4. Apk file ------- the Installation File Apk on Android is the extension of the Android installation package. An Android installation package contains all files related to an Android Application. In the apk file, compress the AndroidManifest. xml file, application code (. dex file), resource file, and other files into a compressed package.

What is an APK file? What is his relationship with android phones?

Source: Macheng Network

APK is the abbreviation of Android Package, that is, the Android installation Package. APK is a file format similar to Symbian Sis Or Sisx. Directly upload the APK file to the Android simulator or Android mobile phone for installation.

The APK file is actually in zip format, but its suffix is changed to apk. After UnZip is decompressed, you can see the Dex file. Dex is the full name of Dalvik VM executes, that is, the Android Dalvik execution program, it is not a Java ME bytecode, but a Dalvik bytecode.

The structure of an APK file is:
The mete-INF Jar file is often seen
Res directory for storing resource files
Global configuration file of AndroidManifest. xml Program
Classes. dex Dalvik bytecode
Resources. arsc compiled binary resource file

In summary, we found that Android requires UnZip before running a program, and then is as direct as Symbian. It is different from the PE file in Windows Mobile. In this way, the confidentiality and reliability of the program are not very high, the dexdump command can be used for decompilation, but this is in line with the development rules. Microsoft's Windows Gadgets or WPF also adopts this architecture.

In the Android platform, the dalvik vm execution file is packaged into the apk format. The loader decompress the package and then obtains the file in the compiled androidmanifest. xml file.

Security Access related to the permission branch, but there are still many security restrictions. If you upload the apk file to the/system/app folder, you will find that the execution is unrestricted. In the end, the files we usually install may not be in this folder, and the apk files in the android rom system will be placed in this folder by default. They have the root permission.

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.