The Structure of .APK Files


The Structure of .APK Files

 
 
 
 
An .apk file is actually a zip compression package, which can be easily decompressed with decompression tools. The following is what we can see after the helloworld.apk (Any APK) file is decompressed using any Zip utility. We can see that its structure is somewhat similar to that of the new project.
                                

                                  |-- AndroidManifest.xml
                                  |
                                  |-- META-INF
                                  |     |-- CERT.RSA
                                  |     |-- CERT.SF
                                  |     `-- MANIFEST.MF
                                  |
                                  |-- classes.dex
                                  |
                                  |-- res
                                  |     |-- drawable
                                  |     |     `-- icon.png
                                  |     `-- layout
                                  |          `-- main.xml
                                  |
                                  `-- resources.arsc


1. Manifest File

AndroidManifest.xml is a required file for any application. It describes the name, version, access rights, referenced library files, and other information of the application. If you intend to upload the .apk file to Google Market, you need to configure this .xml file.
The AndroidManifest.xml contained in the .apk file has been compressed. It can be decompressed by using Apktool.


2. META-INF Directory

META-INF Directory, where signature data is stored, is used to ensure the integrality of the .apk package and system security. When using eclipse to create an API package, a check calculation is performed against all files to be packed. The calculation results are stored in the META-INF directory. When installing an .apk package on OPhone, the application manager will implement the same procedure above. If the result is different from that under the META-INF directory, the system will not install the .apk file. This helps ensure that the files contained in the .apk package will not be replaced randomly. For example, it is basically impossible to replace any picture, code fragment, or copyright data in the .apk package by directly decompressing the file, replacing such content, and then repacking it. Therefore, this may protect the system from virus infection and malicious modification, increasing the system security.


3. Classes.dex File

Classes.dex is a java byte code file generated after the compilation using java source codes. The Dalvik virtual machine used by Android is not compatible with typical java virtual machine. Therefore, the structure and opcode of .dex files are different from .class files. All java decompilers available now can not process .dex files.
Android emulator provides a decompilation tool, dexdump, which can be used to decompile .dex files.


4. Res Directory

Res directory is used to store resource files. For details about resource manager in .apk files, please refer to related articles on the OPhone SDN website.


5. resources.arsc

It is a binary resource file after compilation.
SHARE

Shahbaz ali

Hi There!. I’m author of this blog. I am one who loves to ask a lot of questions and tries to find their answers, and shares to all what he gets.

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment