APK application unpacking, modification, editing, localization, packaging and Application
The first two lectures mainly focus on the basic knowledge of playing a machine and focus on how to brush the machine. This lecture introduces the knowledge related to the APK application, including the unpackaging, packaging, anti-editing, parsing, localization, and modification of the AKP file, several common software are also introduced. Finally, we will introduce the applications for APK operations and learn what to do.
These contents actually constitute a big topic and cannot be clearly described in brief words. I am going to introduce the following content in three parts:
Part 1: APK application introduction, unpacking and packaging, common software tools
Part 2: processing, localization and signature of APK files in Samsung's closed-Source System
Part 3: introduce various APK file packaging and unpacking applications
The first part is the basic knowledge. The second part is the actual modification of the APK application. Finally, the third part introduces the various practical applications for modifying and editing the APK application.
----------------------------------------------------------------------------------
Part 1: APK application introduction, unpacking and packaging, common software
Http://blog.csdn.net/kuangren_01/article/details/9318977
Part 2: processing, localization and signature of APK files in Samsung's closed-Source System
Http://blog.csdn.net/kuangren_01/article/details/9319027
Part 3: introduce various APK file packaging and unpacking applications
Http://blog.csdn.net/kuangren_01/article/details/9319049
I believe that every fan is familiar with APK files. You may deal with APK files every day, whether to install and uninstall useful application tools, plug-ins, and fun games... In particular, the Chinese version of 2.3.4 xxjvp rom has become a hot topic in the Forum. Do you know how Rom is written in Chinese? It is easy to do. This involves a wide range of knowledge, techniques, and time.
1. APK file Introduction
APK is the abbreviation of Android package, that is, the android application package file or the android installation package. Every application to be installed on the Android platform must be compiled and packaged into a separate file with the extension. APK. The APK file is a file package compiled by professional software ECLIPSE, which contains the binary code, resources, and configuration files of the application. You can install the SDK by directly uploading the APK file to your Android phone. The APK file is actually in the ZIP format, but its extension is changed to APK. In Windows, you can use the decompress software WinRAR/WinZip/7-zip to open it directly. After decompression, you will see several files and folders. A typical APK file consists of the following content:
Global configuration file of androidmanifest. xml Program
Classes. Dex Dalvik bytecode
Resources. ARSC compiled binary resource file
META-INF \ This directory stores signature information
Res \ This directory stores resource files
Assets \ This directory can store some configuration files
Below are some basic comments and introductions to these files and directories:
• Androidmanifest. xml
This file is a file that every APK application must contain. It describes the application name, version, permission, referenced library file, and other information.
• Classes. Dex File
Classes. Dex is a Java bytecode file generated after Java source code compilation. Dex is the full name of Dalvik VM executes, that is, the android Dalvik execution program. The parsing tool can be used to convert it into Java for reading and understanding.
• Resources. ARSC
The compiled binary resource file. This file is often used for theme beautification.
• META-INF catalog
The META-INF directory stores the signature information, there are three signature files, 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. 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.
• Res directory
The res directory stores resource files. Including images and strings. Res contains several subdirectories, including drawable, layout, and XML.
After unpacking, almost all possible modifications and edits are here. The main work of the Chinese Rom is here. The Chinese Rom is actually a character file of all APK applications in Chinese.
• Assets Directory
The Assets Directory can store some configuration files. The content of these files can be obtained through related APIs during the program running.
The following uses settings.apk as an example. After opening the file with WinRAR, you can see the six items described above. Now, even if you have decompressed the file, you still cannot directly read the content of each file. To read the content of these files for further modification and editing, you must have the corresponding tool (please go to Section 2 ).
Upload
Download Attachment(59.35 KB)
2. APK app unpack and package tools
This section describes several commonly used tool kits in Windows to unpack, package, decompile, and parse APK applications. All APK sdks require the Java environment (I will not introduce it here, so I will learn it myself ). These tools can be obtained from various online forums. I have collected several frequently-used tool kits in the last month. I will package and upload them and share them with friends who are interested in APK operations. We recommend that you use three tool kits.
1) apktool
Apktool may be the most popular APK toolkit today, which consists of unpacking, packaging, and signature programs. It is called "APK decompilation tool ". Google apktool has a lot of resources, including software downloads and tutorials. It is easy to operate non-Samsung applications.
Open the apktool toolkit and see the following content:
Upload
Download Attachment(34.99 KB)
The Unpacking and packaging software of the AKP program are completed by two programs: apktool. jar and aapt.exe.
In addition, a batch file apktool. bat is provided with the following content:
Java-jar "% ~ Dp0 \ apktool. Jar "% 1% 2% 3% 4% 5% 6% 7% 8% 9
Running apktools. Jar requires a Java environment (version 1.6.0 or later ). Apktool.jaris used for unpackaging. apktool.jarand aapt.exe are combined for packaging. Testkey. pk8 and testkey. x509.pem are signature programs.
Command:
Apktool D xxxxxx.apk ABC
"D" indicates decoding. Xxxxx.apk is the APK file to be decompressed. ABC is the subdirectory name. Files to be decompressed are placed in this subdirectory.
Packaging command:
Apktool B ABC yyyyy.apk
Here, "B" indicates that the package is to be packaged. ABC indicates the subdirectory name, which is the subdirectory generated when the package is unwrapped. It is used to store all files after the package is unwrapped and modified. Yyyyy.apk is a new APK file generated after packaging.
In the uploaded APK toolkit, two additional batch files are added: Unpack-apk.bat and Repack-apt.bat. The former is used to unpack an APK, and the latter is used to package and sign the edited file. Put the APK file to be unwrapped into the same directory of the Unpack-apk.bat, double-click the Unpack-apk.bat, APK file unwrapped start, generate 3 subfolders, the files after unwrapped is placed in the working_apk folder. The details are described in the second part. In addition, batch files allow unpacking and packaging of multiple APK files at the same time.
Note: The file name cannot contain spaces or Chinese characters.
Install the framework file: apktool if framework-res.apk before use
For a Samsung system, you also need to install: apktool if twframework-res.apk
2) APK Manager
APK manager is another "APK decompilation tool ". It is more powerful than the apktool kit. Many of Samsung's APK system applications use Samsung's closed-source system and can be unwrapped using apktool, But the package fails. In this case, the APK manager is easy to use.
Open the APK Manager Toolkit and see the following content. The software is stored in the other subdirectory. Running APK Manager requires the ADB Toolkit (see the three ADB files in ). Place the APK file of the package to the place-APK-here-for-modding subdirectory, and double-click the script batch processing program script. bat, select option 9 to generate a sub-Folder projects. The files after unpacking are placed in this sub-folder. The details are described in the second part.
Upload
Download Attachment(37.64 KB)
In use, sometimes apktool and APK manager are used in turn. Therefore, you must master both of them when editing the APK application.
Note: The file name cannot contain spaces or Chinese characters.
Install the framework file: apktool if framework-res.apk before use
For a Samsung system, you also need to install: apktool if twframework-res.apk
3) dex2jar and xjad
This method does not directly unpack the APK file. It extracts the classes in the APK file first. dex file, and then use dex2jar. jar tool kit will classes. dex is decompiled into a jar file, and Java decompilation is performed using xjad or other class decompilation tools to generate the Java source file.
However, you cannot use this toolkit to restore classes. Dex (or package APK ). Even so, this Toolkit is still important because it converts the classes. Dex file into a Java source file that is easier to read. It is essential to modify the APK application and is a powerful auxiliary tool. In contrast, after decompiling apktool and APK manager, the Dalvik decompilation code (Dalvik Opcodes) is obtained, which requires professional knowledge to read and is not intuitive. If you have read the Java source file, isn't it much easier to modify the corresponding Dalvik code.
4) Other toolkit Introduction
In addition, many toolkit are available. These are also easy to find online.
A) doapk
Doapk is actually the apktool toolkit. Someone wrote apktool as an executable file with a window interface.
B) Google smali
There are two programs: baksmali. jar and smali. jar. Baksmali. jar is used to parse DEX and odex files and obtain the Dalvik code. Then use smali. jar to restore the file to the DEX file. For example, when you modify the display color of the status bar, you need to use these two resolution programs.
C) axmlprinter2.jar
Axmlprinter2.jar operates androidmanifest. xml and Main. XML in the APK file, and restores XML to a text file for ease of reading.
D) apkdb
Is a tool that integrates functions such as apktool, smali, dex2jar, and signature.
E) Other Tools
I will not introduce it any more. Search for it on the Internet.
I package and upload these collected APK sdks for your use, so that you may not find them.
Integrated APK Toolkit:
Http://download.csdn.net/detail/kuangren_01/5747419