当前位置:网站首页>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
边栏推荐
- Deamnet|filenotfounderror: [winerror 3] the system cannot find the specified path.: '/ Datasettest\\Set12‘
- Opengauss kernel analysis: query rewriting
- In the post deep learning era, where is the recommendation system going?
- VRRP virtual redundancy protocol configuration
- Easy to master SSO single sign on, see this article
- Safety management and application of genomic scientific data
- CSRF attack principle scenario
- Example demonstration of "uncover the secrets of asp.net core 6 framework" [02]: application development based on routing, MVC and grpc
- What do growth enterprises need most to build a data-driven organization?
- Completefuture parallel asynchronous return processing
猜你喜欢
![[linear DP] Digital triangle](/img/8c/f7392733ef8e13b20c394da8b4c403.png)
[linear DP] Digital triangle

Win10 configuring CUDA and cudnn

Interpretation of video generation paper of fed shot video to video (neurips 2019)

Peripherals: timer, watchdog and RTC

Mobile Robotics (3) Kalman filter
![[hero planet July training leetcode problem solving daily] 20th BST](/img/25/2d2a05374b0cf85cf123f408c48fe2.png)
[hero planet July training leetcode problem solving daily] 20th BST

In the post deep learning era, where is the recommendation system going?

Consul cluster deployment

Server performance monitoring

Nacos service discovery data model
随机推荐
Example demonstration of "uncover the secrets of asp.net core 6 framework" [02]: application development based on routing, MVC and grpc
Industrial control safety PLC firmware reverse II
These 11 chrome artifacts are extremely cool to use
Data management process model of science and technology planning project
EasyX realizes button effect
Consul cluster deployment
Focus on improving women's and children's sense of gain, happiness and security! In the next ten years, Guangzhou Women's and children's undertakings will make such efforts
Thinkphp5.0.24 deserialization chain analysis
Gerrit statistics script
In the post deep learning era, where is the recommendation system going?
Use SAP ui5 application to consume create and delete operations of OData in business application studio
Web vulnerability
Grpc sets connection lifetime and server health check
Promise basic use
An article explains unsupervised learning in images in detail
Inventory of well-known source code mall systems at home and abroad
2022/7/18-7/19
Agreement on sharing agricultural scientific data in China
6-11 vulnerability exploitation - use the built environment to send emails
Gbase 8s how to query relational databases in sentences to select sample syntax and results of data from complex types