An efficient batch packaging method for Android application customization packages

By managing resource replacement rules in the cloud and using a distributed packaging machine, the problem of time-consuming batch packaging of Android application custom packages with multiple flavors was solved. This enabled efficient batch packaging of custom packages for multiple platforms, reducing R&D costs and time consumption, and improving software release efficiency.

CN116827927BActive Publication Date: 2026-01-06YUKUAI CHUANGLING INTELLIGENT TECH (NANJING) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310933512.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-27
Publication Date
2026-01-06
Estimated Expiration
2043-07-27

AI Technical Summary

Technical Problem

In existing technologies, multi-flavor batch packaging solutions for Android application custom packages are time-consuming and labor-intensive, especially in hardening scenarios, where frequent full compilation and signing are required, resulting in high development costs and making them unsuitable for batch packaging of multi-platform custom packages.

Method used

By adopting server-side management of resource replacement rules, and through the CI continuous integration service module and distributed packaging machine, the resource preparation module and repackaging module are used to realize cloud storage and distributed packaging of resource files, reducing the involvement of R&D personnel. The method of full compilation followed by hardening is adopted, and incremental compilation and signing are only performed after resource replacement.

Benefits of technology

It reduces R&D costs, improves the efficiency of batch packaging of customized packages, is applicable to multiple platforms, reduces the time consumed for each packaging, improves software release efficiency, and reduces the risk of delays caused by urgent problem fixes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116827927B_ABST
    Figure CN116827927B_ABST
Patent Text Reader

Abstract

The application provides a kind of efficient Android application customization package batch packaging method, including server, front-end management platform, front-end packaging platform, CI continuous integration service module, packer, packaging tool, file server, including the following steps: resource management;Formulate resource replacement rule file and upload customization package resource to server;Operation personnel upload customization package resource through front-end management platform;Server according to the customization package resource uploaded by front-end management platform, query resource replacement rule file, store customization package resource according to rule;Customization package batch packaging;The application improves packaging efficiency, reduces the input cost of packer / packaging server, improves the release efficiency of Android application software, effectively avoids the release delay caused by urgent problem repair, saves the cost of research and development, and improves the efficiency of research and development.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of Android application software development technology, and in particular to an efficient method for batch packaging of customized Android application packages. Background Technology

[0002] In recent years, Android applications have become an integral part of our lives, running on many devices such as mobile phones, car infotainment systems, tablets, treadmills, watches, and POS machines. Often, Android application developers need to provide specific channel packages for various software distribution channels and customized service packages for different types of users and clients. Channel package packaging solutions are relatively mature. Channel package packaging is only related to the Android application software signing process and is unrelated to whether the Android application software has been hardened or obfuscated. Channel package packaging tools can modify channel information without requiring re-signing or hardening, resulting in high packaging efficiency. There are also open-source, high-efficiency channel package packaging tools available in the Android application software development industry. Custom package packaging, especially in the B2B field, often involves personalized needs and enterprise-specific customization. Custom package packaging solutions have evolved from the initial Ant scripts + multi-directory resource differentiation, to the later Gradle scripts + multi-directory resource differentiation, and then to the Gradle multi-flavor approach. Many companies also develop their own high-efficiency custom package packaging tools. Currently, the most widely used solution is the multi-flavor packaging solution provided by Google. There are currently no open-source, high-efficiency custom package packaging tools in the industry.

[0003] Regarding multi-flavor packaging solutions, custom packaging involves modifying text, images, and even functions. Since custom packages must be signed, they often require hardening. If each custom package needs to be hardened and signed, batch packaging will consume a lot of time, which will be a huge time cost in the development process. Especially during the software release process, if an urgent bug is encountered and fixed, even if only one line of code is changed, it will require a lot of time to repackage. In addition, the maintenance of multi-flavor requires the participation of development personnel and requires continuous investment in development costs.

[0004] The time consumption for a single-packer, multi-flavor batch packaging solution is calculated as follows: Full compilation time + (Differentiated compilation time + Hardening time + Signing time) * Number of packages / Number of threads * Actual CPU utilization. The time consumption of the multi-flavor batch packaging solution is mainly in scenarios requiring hardening. If the Android application does not require hardening, the multi-flavor batch packaging solution is a good option, but it is not a general-purpose, efficient solution for batch packaging custom Android applications.

[0005] Because multi-flavor packaging schemes rely on intermediate products during compilation, if distributed packaging is to be performed across multiple packaging machines, each packaging machine needs to perform a full compilation. Summary of the Invention

[0006] The purpose of this invention is to address the shortcomings of existing technologies by proposing an efficient method for batch packaging of customized Android application packages.

[0007] To achieve the above objectives, the present invention adopts the following technical solution: an efficient method for batch packaging of customized Android application packages, comprising a server, a front-end management platform, a front-end packaging platform, a CI continuous integration service module, a packaging machine, a packaging tool, and a file server, wherein the packaging tool includes a resource preparation module, a resource replacement module, and a repackaging module;

[0008] Includes the following steps:

[0009] S100: Resource Management;

[0010] S101: Develop resource replacement rule files and upload customized package resources to the server;

[0011] S102: Operations personnel upload customized package resources through the front-end management platform;

[0012] S103: The server queries the resource replacement rule file based on the customized package resources uploaded by the front-end management platform, and stores the customized package resources according to the rules;

[0013] S200: Customized package bulk packaging;

[0014] S211: Front-end packaging platform triggers packaging;

[0015] S212: The server prepares packaging information based on the packaging parameters;

[0016] S213: The CI continuous integration service module schedules the packaging machine and transmits packaging information to the packaging machine.

[0017] S214: The packing machine starts the packing tool;

[0018] S215: The packaging tool retrieves code and customized package resources based on the packaging information;

[0019] S221: The packaging tool triggers a full compilation of the code, outputting the Android application.

[0020] S222: The resource preparation module of the packaging tool uses the open-source apktool tool to decompile Android applications;

[0021] S223: The resource preparation module prepares the basic temporary package temp.apk;

[0022] S224: The resource preparation module prepares the decompiled resource package folder temp_res to be replaced;

[0023] S225: The packaging tool starts multiple threads, with each thread responsible for packaging one item. Each thread is a packaging task and distributes packaging tasks.

[0024] S231: In each packaging task, the resource preparation module copies a basic temporary package temp.apk and a resource package folder temp_res;

[0025] S232: Each packaging task executes the resource replacement module based on the packaging information to replace the customized package resources;

[0026] S233: In each task, the repackaging module incrementally compresses the replaced resource package folder temp_res into the base temporary package temp.apk;

[0027] S234: In each task, the repackaging module performs byte alignment on the compressed Android application package apk using the zipalign tool;

[0028] S235: In each task, the repackaging module signs the final generated Android application package (apk).

[0029] S236: Each task uploads the final signed Android application package (apk) to the file server;

[0030] S241: Notify the CI continuous integration service module after all packaging tasks are completed;

[0031] S242: The CI continuous integration service module waits for all packaging machines to finish packaging before sending a packaging completion message to the server.

[0032] Furthermore, the resource replacement rules include resource type, resource name, and resource path;

[0033] Resource types include files, folders, and text. If the resource type to be replaced is a file or folder, the resource replacement rule must include the path of the resource to be replaced. If the resource type to be replaced is text, the resource replacement rule must include the editable file type and the text location.

[0034] Furthermore, the file types include JSON, XML, and PList formats. Text files are composed of nodes, and the text position is described by abstract rules that define the relative position of text data within the file. The text position is described by nodes, node depth, node attributes, and content.

[0035] Furthermore, the customized package resources include images, files, and text content.

[0036] Furthermore, for Android applications in scenarios requiring hardening, after hardening the fully compiled Android application using hardening tools, S222-S242 can be executed.

[0037] Compared with the prior art, the beneficial effects of the present invention are as follows: First, the resource files required for the customized package are stored in the cloud. The resource files can be uploaded by the operations personnel / customers, and are no longer all put in the source code, which reduces the involvement of R&D personnel, reduces development and maintenance costs, and decouples the code and customized resources, making the method applicable to batch packaging of customized packages for multiple platforms (such as iOS).

[0038] Second: The method provided by this invention establishes resource file rules, rather than targeting fixed resources. If the resource files change, only the Android code and resource replacement rule declaration need to be modified, without requiring changes to all aspects.

[0039] Third: This invention defines a set of rules for text replacement expressions. These rules can describe the specific text location to be replaced. The expressions are universal and applicable to file types, not limited to the file types required by the Android platform.

[0040] Fourth: The method of first compiling the master package in full, then hardening it, and then decompiling it preserves the hardened product. Subsequent batch packaging of customized packages only requires replacing the resources and recompiling, avoiding the packaging time consumption caused by hardening every time.

[0041] Fifth: Split the files in the decompiled folder, keep the unchanging files and folders, move the volatile files to a folder outside the decompiled folder, keep only the unchanging folders and files in the decompiled folder, package it into a temporary package, and after the volatile folders are replaced by the replacer, the files are incrementally compressed into the temporary package, saving a lot of compression time for unchanging files.

[0042] Sixth: The method provided by this invention does not rely on compiler intermediate products and can be easily used for distributed packaging across multiple packaging machines. Only CI distributed scheduling needs to be added. Attached Figure Description

[0043] Figure 1 This is a resource management flowchart for the customized package batch packaging method of the present invention;

[0044] Figure 2 This is a flowchart of the customized package batch packaging method of the present invention;

[0045] Figure 3 This is a schematic diagram of the structure of the customized package batch packaging method of the present invention. Implementation

[0046] To provide a further understanding of the purpose, structure, features, and functions of the present invention, detailed descriptions are provided below with reference to specific embodiments.

[0047] An efficient method for batch packaging customized Android applications includes a server M103, a front-end management platform, a front-end packaging platform M101, a CI continuous integration service module M102, a packaging machine M104, a packaging tool M105, a file server, etc. The packaging tool includes a resource preparation module M251, a resource replacement module M252, and a repackaging module M253.

[0048] Includes the following steps:

[0049] S100: Resource Management;

[0050] S101: Develop a resource replacement rule file and upload the customized package resources to the server.

[0051] Resource rules are used to abstractly describe resources. They must include the resource type, resource name, and resource path. Resource types include files, folders, and text. If the resource being replaced is a file or folder, the resource rule must include the path of the resource being replaced. If the resource being replaced is text, the resource rule must include the editable file type and the text location. The text location is related to the file type, and different file types have different methods for describing the text location. Text file types include formats such as JSON, XML, and plist.

[0052] Text position describes the relative position of text data in a text file using abstract rules; the text data includes fields or field values, etc.; for example, a text file has 1000 lines of text, and there is text data in the 400th line that needs to be replaced. The position of this text data may not be fixed in different text file formats or files developed by different people. We need to use a computer-recognizable language to describe the position of this text data relative to the entire text.

[0053] JSON is a lightweight data exchange format based on a subset of ECMAScript (the JavaScript specification developed by the European Computer Manufacturers Association). It uses a text format that is completely independent of programming languages ​​to store and represent data.

[0054] XML stands for Extensible Markup Language. It is a subset of SGML (Standard Generalized Markup Language). Unlike HTML files, XML is only used for data storage and exchange.

[0055] plist format is a special text file that contains data in the format of a list of attributes.

[0056] JSON, XML, and plist formats do not have the concept of lines; the position of text is described by computer-readable language such as nodes, node depth, node attributes, and content.

[0057] Nodes are identified by their names. In computer languages, text files are composed of nodes, and the first node in a text file is the "root node". A text file must have one and only one root node, and all other nodes must be its child nodes. The node depth refers to the number of nodes traced from the current node to the root node, and the root node has a node depth of 1.

[0058] Node attributes also include key, value, and other attribute values; content refers to the text value (Text).

[0059] The rules for defining text replacement expressions are as follows:

[0060] Operators:

[0061] # indicates the node depth; each additional node in depth requires a # connection.

[0062] * indicates that all child nodes under this node need to be traversed;

[0063] ^ indicates the next node;

[0064] ~ indicates the previous node;

[0065] @ indicates that a node is searched by index;

[0066] The question mark (?) indicates fuzzy matching of attributes.

[0067] The exclamation mark (!) indicates strict attribute matching.

[0068] = Used to separate the key and value of an attribute;

[0069] : Indicates content;

[0070] An empty character represents the bit to be replaced, which can be an attribute, node name, or the text value.

[0071] The above expressions support json, xml, and plist.

[0072] Based on business requirements, identify the resources in the source code that need to be replaced, describe these customized package resources according to the above rules, and upload them to the server.

[0073] S102: Operations personnel upload customized package resources through the front-end management platform;

[0074] Custom package resources include images, files, text content, etc.

[0075] S103: The server queries the resource replacement rule file based on the customized package resources uploaded by the front-end management platform, and stores the customized package resources according to the rules.

[0076] S200: Customized package bulk packaging;

[0077] S211: Front-end packaging platform M101 triggers packaging.

[0078] Users generate packaging parameters by operating the front-end packaging platform. These parameters are selected and generated by the user. The packaging parameters contain index information of the code to be packaged, and the number and type of code to be packaged can be determined from the parameters.

[0079] S212: Server M102 prepares the packaging information based on the packaging parameters. The packaging information is generated based on the packaging parameters and server configuration.

[0080] S213: CI continuous integration service module M103 schedules packaging machine M104 and transmits packaging information to the packaging machine.

[0081] A packaging machine is a computer device specifically used to pull code, compile and package it, and upload it to a test package download server.

[0082] Pass-through is a technique that uses specific network technologies and protocols to send data directly from the server to the user.

[0083] S214: Packaging machine M104 starts packaging tool M105.

[0084] S215: The packaging tool M105 pulls code and customized package resources based on the packaging information.

[0085] S221: The packaging tool triggers a full compilation of the code, outputting the Android application.

[0086] Full compilation is the recompilation of a user's source program after partial modifications. It involves all source code and is not limited to partial modifications and related parts. That is, regardless of whether there are modifications, full compilation will be a completely new compilation, not based on the previous compilation.

[0087] S222: The resource preparation module M251 of the packaging tool uses the open-source apktool to decompile Android applications. Decompilation is the process of converting a compiled program back into source code. Decompilation involves using a compilation tool to decompile the source files and resources in the application files. The resulting source files and resource files can then be processed before recompiling.

[0088] S223: Resource preparation module M251 prepares the basic temporary package temp.apk.

[0089] S224: Resource preparation module M251 prepares the decompiled resource package folder temp_res to be replaced.

[0090] S225: The packaging tool starts multiple threads, each thread is responsible for packaging one package, and each thread is a packaging task, which is then distributed.

[0091] S231: In each packaging task, the resource preparation module M251 will copy a basic temporary package temp.apk and a resource package folder temp_res.

[0092] S232: Each packaging task executes the resource replacement module M252 based on the packaging information to replace customized package resources, including files, folders, and text.

[0093] S233: In each task, the repackaging module M253 incrementally compresses the replaced resource package folder temp_res into the base temporary package temp.apk.

[0094] S234: In each task, the repackaging module M253 performs byte alignment on the compressed Android application package apk using the zipalign tool.

[0095] S235: In each task, the repackaging module M253 signs the final generated Android application package (apk).

[0096] S236: Each task uploads the final signed Android application package (apk) to the specified file server.

[0097] S241: Notify CI continuous integration service module M103 after all packaging tasks are completed.

[0098] S242: CI continuous integration service module M103 waits for all packaging machines M104 to finish packaging before sending a packaging completion message to server M102.

[0099] Furthermore, for Android applications requiring hardening, after hardening the fully compiled Android application using hardening tools, steps S222-S242 are executed. These hardening tools include 360, Baidu, or App Store. This method of first fully compiling the parent package, hardening it, and then decompiling preserves the hardened output. Subsequent batch packaging of customized packages only requires replacing resources and recompiling, avoiding the time consumption associated with hardening each time.

[0100] With a single packaging machine and eight threads, the time consumption of the method provided by this invention is: full compilation time + decompilation time + temporary package and temporary resource preparation time + (temporary file copying time + resource replacement time + incremental compression time + byte alignment time + signing time) * number of packages / number of threads * actual CPU utilization.

[0101] For example:

[0102] If there is a packaging machine, packaging an Android application takes 5 minutes, the Android application package size is 100 MB, decompiling takes 20 seconds, recompiling takes 8 seconds, hardening takes 2 minutes, signing takes 10 seconds, and it requires replacing 5 20 KB images, a folder containing 10 files, a 100 KB configuration file, 10 text display contents, and 200 custom packages. The time consumption of the multi-flavor batch packaging scheme and the method provided in this invention on a single packaging machine with eight threads (based on four threads running at full capacity) is compared as follows:

[0103] Multi-flavor batch packaging solution: approximately 7300 seconds;

[0104] The solution provided by this invention: approximately 1630 seconds.

[0105] Improving packaging efficiency can reduce the investment cost of packaging machines / packaging servers, improve the release efficiency of Android application software, effectively avoid release delays caused by urgent problem fixing, save R&D costs, and improve R&D efficiency.

[0106] The present invention has been described in the above-described embodiments; however, these embodiments are merely examples for implementing the present invention. It must be noted that the disclosed embodiments do not limit the scope of the present invention. Conversely, any modifications and refinements made without departing from the spirit and scope of the present invention are within the scope of patent protection of the present invention.

Claims

1. A highly efficient method for batch packaging custom Android application packages, characterized by: The application comprises a server, a front-end management platform, a front-end packaging platform, a CI continuous integration service module, a packager, a packaging tool, a file server, and the packaging tool comprises a resource preparation module, a resource replacement module and a repackaging module. The application comprises the following steps: S100: resource management; S101: formulating a resource replacement rule file and uploading custom package resources to the server; S102: an operator uploads custom package resources through the front-end management platform; S103: the server queries the resource replacement rule file according to the custom package resources uploaded by the front-end management platform, and stores the custom package resources according to the rule; S200: custom package batch packaging; S211: the front-end packaging platform triggers packaging; S212: the server prepares packaging information according to the packaging parameters; S213: the CI continuous integration service module dispatches the packager and transmits the packaging information to the packager; S214: the packager starts the packaging tool; S215: the packaging tool pulls the code and custom package resources according to the packaging information; S221: the packaging tool triggers full-code compilation and outputs an Android application; S222: the resource preparation module of the packaging tool uses an open-source apktool tool to decompile the Android application; S223: the resource preparation module prepares a basic temporary package temp.apk; S224: the resource preparation module prepares a resource package folder temp_res to be replaced; S225: the packaging tool starts multi-threading, each thread is responsible for packaging, each thread is a packaging task, and the packaging task is distributed; S231: in each packaging task, the resource preparation module copies a copy of the basic temporary package temp.apk and the resource package folder temp_res; S232: each packaging task executes the resource replacement module according to the packaging information to replace the custom package resources; S233: in each task, the repackaging module incrementally compresses the resource package folder temp_res that has been replaced into the basic temporary package temp.apk; S234: in each task, the repackaging module executes the zipalign tool on the compressed Android application package apk for byte alignment; S235: in each task, the repackaging module signs the finally generated Android application package apk; S236: each task uploads the finally signed Android application package apk to the file server; S241: after all the packaging tasks are completed, the CI continuous integration service module is notified; S242: after all the packagers complete the packaging, the CI continuous integration service module sends a packaging completion message to the server.

2. The efficient Android application customization package batch packaging method of claim 1, wherein: The resource replacement rule comprises a resource type, a resource name and a resource path; The resource type comprises a file, a folder and a text; if the replaced resource type is a file or a folder, the resource replacement rule needs to comprise a replaced resource path, and if the replaced resource type is a text, the resource replacement rule needs to comprise an editable file type and a text position.

3. The efficient Android application customization package batch packaging method of claim 2, wherein: The file type includes a json format, an xml format and a plist format; the text file is composed of nodes; the text position is a relative position of text data in a file of the text, and is described by abstract rules; and the text position is described by nodes, node depth, node attributes and content.

4. The efficient Android application customization package batch packaging method of claim 1, wherein: The customization package resource includes pictures, files and text content.

5. The efficient Android application customization package batch packaging method of claim 1, wherein: For an Android application of a scene with reinforcement requirements, the full-amount compiled output of the Android application is reinforced by using a reinforcement tool, and then S222-S242 are executed.

Citation Information

Patent Citations

  • An Android automatic packaging method and system

    CN109766101A

  • App automatic customization packaging method and device based on Android end

    CN113741960A