当前位置:网站首页>Apk packaging process
Apk packaging process
2022-07-25 02:11:00 【Orange 19911016】

Typical Android The construction process of application modules usually follows the following steps :
- Compiler converts source code into
.DEX(Dalvik Executable) file ( These includeAndroidBytecode running on the device ), Convert all other content into compiled resources ; APKThe packer will.DEXCombine files and compiled resources into a single fileAPK. however , You must signAPK, To install and deploy the application toAndroidOn the device ;APKPackers use debugging or publishing keystores to signAPK;- If you build a debug version of the application ( That is, applications designed for testing and Analysis ), The packer will use the debug keystore to sign the application .
Android StudioAutomatically configure new projects using the debug keystore ; - If you build a release version application that you plan to release , The packer will use the publishing keystore to sign the application ;
- If you build a debug version of the application ( That is, applications designed for testing and Analysis ), The packer will use the debug keystore to sign the application .
- At the end of the generation
APKBefore , The packer will usezipalignTools to optimize applications , Reduce the memory used when running on the device ;

1 Package resource files
stay Android During the compilation of the application ,AAPT(Android Assert Packaging Tool) The tool will be right res Compile the resource files under the directory , Generate a resource.arsc file ,resource.arsc A file is equivalent to a file index table , It records a lot of information related to resources . Each such file will be assigned a resource id, Access to such resources , The application layer code is through resource id visiting .
take .apk After decompressing (apk The essence is a .zip Compressed package ) You'll see it resources.arsc, It's actually APP Resource files for . Simply speaking , adopt resources.arsc You can locate the memory address of the resource .

2 Handle aidl files
If there is .aidl file , Will pass aidl Tools ( The source code is located in system/tools/aidl), Pack it up .java Interface class .aidl The tool parses the interface definition file and generates the corresponding Java Code interface for program call . If not used in the project aidl file , You can skip this step .
AIDL(Android Interface Definition Language), yes Android Interface definition language . The purpose is to facilitate inter process communication , Especially in the case of multi process concurrency . Its essence is to Binder Encapsulation of communication .
3 compile (Compilers)
Engineering source ( All of the Java Code )+ R.java + aidl.java adopt javac Generate .class file .
4 Generate .dex file
.class Documents and third parties jar perhaps library adopt dx The tools are packed into .dex file .
5 apkbuilder( Generate unsigned apk)
apkbuilder The tool will save all resources that have not been compiled 、.arsc resources 、.dex Package the files into a complete apk In file .
6 Jarsigner( Signature )
jarsigner The tool will respond to unsigned apk Verify the signature , After getting a signature apk——signed.apk. once APK File generation , It has to be signed to be installed on the device .
7 zipalign( alignment )
zipAlign Tool pair signed.apk Do alignment . If the APK If it's the official version , You have to be right APK Do alignment , The tools used are zipalign([ Catalog ]\Android\sdk\build-tools\[ Version number ]\zipalign.exe) . The so-called alignment , The main process is to APK All resource files in the package are offset from the beginning of the file by 4 Integer multiples of bytes , This is accessed through memory mapping apk Files will be faster .
Reference resources
边栏推荐
- [system design] distributed key value database
- 6-10 vulnerability exploitation SMTP experimental environment construction
- VRRP virtual redundancy protocol configuration
- Safety management and application of genomic scientific data
- Babbitt | metauniverse daily must read: Dubai launched the national metauniverse strategy, which plans to increase the number of related companies of metauniverse by five times in the next five years
- Jedispoolconfig parameter configuration from the perspective of source code
- Nacos service discovery data model
- CSRF attack principle scenario
- Thinkphp5.0.24 deserialization chain analysis
- Rightmost × Microframe, high quality heif image coding and compression technology
猜你喜欢

Cloud native platform, let edge applications play out!

Web Security Foundation - file upload

Fraud detection using CSP

What do growth enterprises need most to build a data-driven organization?

Using multithreaded execution method in Lua script based on nlua implementation

"I gave up programming and wrote a 1.3 million word hard science fiction."

6-11 vulnerability exploitation - use the built environment to send emails

Use SAP ui5 application to consume create and delete operations of OData in business application studio

Talk about what's going on with C # backstage GC?

Today in history: the kotlin language was published for the first time; The father of the IMAP agreement was born; CT imaging achieves a new breakthrough
随机推荐
G024-db-gs-ins-01 openeuler deployment opengauss (single instance)
Origin and development of philosophy Hegel external historical form
Ecosystem long-term observation data product system
Inventory of well-known source code mall systems at home and abroad
Nacos service discovery data model
[summer daily question] Luogu p1605 maze
Common functional interfaces_ Predicate interface_ Default method and and predicate interface exercise_ Set interface filtering
Cloud native platform, let edge applications play out!
Using multithreaded execution method in Lua script based on nlua implementation
JVM Foundation
6-10 vulnerability exploitation SMTP experimental environment construction
DNA helped solve the outstanding case 30 years ago. The suspect strangled his girlfriend because he fell in love with his roommate. He was already the CEO of the technology company when he was arreste
EasyX realizes button effect
Research 280+ documents! The team of Tsinghua Huang Gao, the winner of CVPR best paper, proposed the first dynamic network overview to comprehensively review the development of dynamic networks!
The solution of displaying garbled code in SecureCRT
An article explains unsupervised learning in images in detail
Genesis, the world's first "consumption investment" public chain, was invited to participate in consensus 2022
How can arm access the Internet through a laptop?
xts performance auto fix script
Digital power supply -- Chapter 1