APK package volume optimization method and device, storage medium and electronic equipment
By unpacking and analyzing different versions of APK packages and their detection rules, an optimization priority ranking model is constructed to automatically optimize the APK package size. This solves the problems of inaccurate optimization and lack of real-time monitoring in existing technologies, thereby improving development efficiency.
Patent Information
- Application Number
- CN202510834325.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-20
- Publication Date
- 2025-11-18
AI Technical Summary
Existing APK package size optimization methods lack in-depth analysis of the differences between different versions, resulting in inaccurate optimization. Furthermore, they lack real-time monitoring and early warning mechanisms in continuous integration and continuous deployment processes, making it difficult to detect abnormal increases in package size in a timely manner.
By unpacking different versions of the target application's APK package to obtain package size parameters, and using detection metrics and rules for detection, an optimization priority ranking model is constructed to optimize the package size parameters one by one, thereby achieving automated optimization.
It automates APK package size optimization, accurately identifies key factors, reduces manual operations by developers, and improves development efficiency and optimization accuracy.
Smart Images

Figure CN120973405A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application relates to the technical field of Android application development, and in particular to an APK package volume optimization method and device, a storage medium and electronic equipment. BACKGROUND
[0002] In the Android application development process, the APK package volume size is a key indicator. An excessively large APK package volume not only increases the time cost of user downloading and installation, but also occupies more device storage space, thereby affecting user experience and even causing users to give up using the application. At present, the existing APK package volume optimization method usually uses a tool such as Matrix-ApkChecker to analyze the changes in the APK package volume and give certain optimization suggestions, but these suggestions are often based on fixed rules and general experience, lack deep analysis of the differences between different versions of APK, and are difficult to accurately locate the key factors leading to the package volume changes. Meanwhile, for complex code structures and resource usage, the existing tools cannot provide personalized and intelligent optimization schemes. In addition, in the continuous integration and continuous deployment (CI / CD) process of the application, there is a lack of effective package volume real-time monitoring and early warning mechanism, and developers are difficult to discover the abnormal growth of the package volume in a timely manner. SUMMARY
[0003] Therefore, the application provides an APK package volume optimization method, device, storage medium and electronic equipment, and mainly aims to solve the problem that the existing APK package volume optimization method lacks deep analysis of the differences between different versions of APK, thereby leading to inaccurate APK package volume optimization.
[0004] To solve the above problems, the application provides an APK package volume optimization method, which comprises the following steps:
[0005] Unpacking the different version APK packages of a target application to obtain package volume parameters corresponding to the different version APK packages;
[0006] Detecting the package volume parameters between the different version APK packages by using detection rules corresponding to different detection indexes to obtain to-be-optimized package volume parameters corresponding to the different detection indexes;
[0007] Optimizing priority of each to-be-optimized package volume parameter to obtain a to-be-optimized package volume parameter queue;
[0008] Optimizing each to-be-optimized package volume parameter by using a parameter optimization mode corresponding to each to-be-optimized package volume parameter in the to-be-optimized package volume parameter queue to obtain an APK package volume optimization result.
[0009] Optionally, the different versions of APK packages are unpacked to obtain package volume parameters corresponding to the different versions of APK packages, specifically including:
[0010] The same version of APK package is parsed to obtain an HTML report and a JSON data file;
[0011] The HTML report and the JSON data file are respectively subjected to package volume data extraction to obtain package volume parameters corresponding to the same version of APK package;
[0012] The package volume parameters include: file quantity, method number, and resource usage analysis parameters.
[0013] Optionally, before the package volume parameters between different versions of APK packages are detected by using detection rules corresponding to different detection indexes, the method further includes: constructing detection rules corresponding to different detection indexes;
[0014] The construction of detection rules corresponding to different detection indexes specifically includes:
[0015] Based on the parameter type of the package volume parameter, each detection index corresponding to the parameter type is determined;
[0016] A query path and a trigger condition corresponding to each detection index are constructed;
[0017] Based on the query path and the trigger condition corresponding to the same detection index, a detection rule corresponding to the same detection index is constructed.
[0018] Optionally, the package volume parameters between different versions of APK packages are detected by using detection rules corresponding to different detection indexes to obtain to-be-optimized package volume parameters corresponding to different detection indexes, specifically including:
[0019] The trigger conditions of different detection indexes are listened to;
[0020] When the value of a target detection index meets the trigger condition, a to-be-optimized parameter query rule corresponding to the target detection index is used to query the package volume parameters to obtain to-be-optimized package volume parameters corresponding to the target detection index.
[0021] Optionally, the method further includes:
[0022] Obtaining a version feature of the APK file;
[0023] Based on the version feature, a target detection index to be dynamically adjusted is determined;
[0024] The threshold of the trigger condition of the target detection index is dynamically adjusted.
[0025] Optionally, the optimization priority of each of the to-be-optimized package volume parameters is sorted to obtain a to-be-optimized package volume parameter queue, specifically including:
[0026] Each of the to-be-optimized package volume parameters is subjected to feature extraction to obtain a feature parameter corresponding to each of the to-be-optimized package volume parameters;
[0027] Each of the feature parameters is identified by using a pre-trained optimization priority sorting model to obtain an optimization priority score corresponding to each of the feature parameters;
[0028] Each of the to-be-optimized package volume parameters is sorted in descending order of the optimization priority score to obtain the to-be-optimized package volume parameter queue.
[0029] Optionally, each of the to-be-optimized package volume parameters is optimized by using a parameter optimization mode corresponding to each of the to-be-optimized package volume parameters in the to-be-optimized package volume parameter queue to obtain an APK package volume optimization result, specifically including:
[0030] Each optimization rule in a pre-set optimization rule database is queried based on the to-be-optimized package volume parameter to obtain an optimization method and a parameter transfer mode corresponding to the to-be-optimized package volume parameter;
[0031] The to-be-optimized package volume parameter is optimized by using the optimization method based on the parameter transfer mode to obtain the APK package volume optimization result.
[0032] To solve the above problems, the application provides an APK package volume optimization device, which includes:
[0033] An unpacking module is configured to perform unpacking processing on different version APK packages of a target application to obtain package volume parameters corresponding to the different version APK packages;
[0034] A detection module is configured to detect the package volume parameters between the different version APK packages by using detection rules corresponding to different detection indexes to obtain to-be-optimized package volume parameters corresponding to the different detection indexes;
[0035] A sorting module is configured to sort the optimization priority of each of the to-be-optimized package volume parameters to obtain a to-be-optimized package volume parameter queue;
[0036] An optimization module is configured to optimize each of the to-be-optimized package volume parameters by using a parameter optimization mode corresponding to each of the to-be-optimized package volume parameters in the to-be-optimized package volume parameter queue to obtain an APK package volume optimization result.
[0037] To solve the above problems, the application provides a storage medium, which stores a computer program, and the computer program realizes the steps of the APK package volume optimization method when executed by a processor.
[0038] To solve the above problems, the application provides an electronic device, which at least comprises a memory and a processor, the memory stores a computer program, and the processor realizes the steps of the APK package volume optimization method when executing the computer program on the memory.
[0039] The application has the following beneficial effects: the application unpacks different versions of APK packages of a target application to obtain package volume parameters corresponding to the different versions of APK packages; different detection rules corresponding to different detection indexes of the package volume parameters are used to detect the package volume parameters between different versions of APK packages to obtain to-be-optimized package volume parameters corresponding to the different detection indexes; key factors causing changes in APK package volume can be accurately identified to obtain the to-be-optimized package volume parameters; the to-be-optimized package volume parameters are prioritized to obtain a to-be-optimized package volume parameter queue; and each to-be-optimized package volume parameter is optimized one by one by using a parameter optimization mode corresponding to each to-be-optimized package volume parameter in the to-be-optimized package volume parameter queue to obtain an APK package volume optimization result. The application realizes the automation of APK package volume optimization, reduces manual operations of developers, and improves development efficiency.
[0040] The above description is only a summary of the technical scheme of the application, in order to more clearly understand the technical means of the application, the application can be implemented according to the content of the specification, and in order to make the above and other purposes, characteristics and advantages of the application more obvious and easy to understand, the following specific embodiments of the application are described. BRIEF DESCRIPTION OF DRAWINGS
[0041] Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The accompanying drawings are included to provide a description of the preferred embodiments and are not meant to limit the present application. Moreover, the same reference numerals in the attached drawings refer to the same or similar components. In the drawings:
[0042] Figure 1 A flowchart of an APK package volume optimization method provided by an embodiment of the application is shown;
[0043] Figure 2 A flowchart of an APK package volume optimization method provided by another embodiment of the application is shown;
[0044] Figure 3 A structural block diagram of an APK package volume optimization device provided by another embodiment of the application is shown. DETAILED DESCRIPTION
[0045] Various aspects and features of the present application are described herein with reference to the accompanying drawings.
[0046] It is to be understood that various modifications can be made to the embodiments described herein. Thus, the description is not to be considered as limiting, but merely as a description of exemplary embodiments. Other modifications of the application will occur to those skilled in the art upon reading the present application.
[0047] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments of the application and, together with the general description of the application given above, and the detailed description of the embodiments given below, serve to explain the principles of the present application.
[0048] These and other characteristics of the present application will become apparent upon consideration of the following detailed description taken in conjunction with the accompanying drawings.
[0049] It should also be understood that, although the present application has been described above in terms of certain embodiments, many other embodiments of the present application will be apparent to those skilled in the art from this disclosure.
[0050] The above and other aspects, features, and advantages of the present application will become apparent upon consideration of the following detailed description taken in conjunction with the accompanying drawings, in which:
[0051] Specific embodiments of the present application are described hereinbelow with reference to the accompanying drawings; however, it is to be understood that the claimed embodiments are merely examples of the present application, which can be implemented in numerous ways. Well-known and / or redundant functions and structures have not been described in detail to avoid obscuring the present application unnecessarily. Therefore, specific structural and functional details disclosed herein are not intended to limit the present application, but merely as a representative basis for teaching one skilled in the art to use the present application in virtually any appropriate detailed structure.
[0052] The present specification can use the phrases "in one embodiment," "in another embodiment," "in yet another embodiment," or "in at least one embodiment," which can refer to one or more of the same or different embodiments of the application.
[0053] An APK package volume optimization method is provided in the embodiments of the present application, as shown in the accompanying drawings, comprising: Figure 1
[0054] Step S101: unpacking different versions of APK packages of a target application to obtain package volume parameters corresponding to the different versions of APK packages;
[0055] In the specific implementation process, the same version APK package is parsed to obtain an HTML report and a JSON data file; the package volume data of the HTML report and the JSON data file are extracted respectively to obtain package volume parameters corresponding to the same version APK package; the package volume parameters include file quantity, method number, and resource usage analysis parameters.
[0056] In step S102, the package volume parameters of different versions of APK packages are detected by using detection rules corresponding to different detection indexes to obtain to-be-optimized package volume parameters corresponding to different detection indexes.
[0057] In the specific implementation process, the trigger conditions of different detection indexes are monitored; when the value of a target detection index meets the trigger condition, the to-be-optimized package volume parameter corresponding to the target detection index is obtained by using a to-be-optimized parameter query rule corresponding to the target detection index.
[0058] In step S103, the to-be-optimized package volume parameters are prioritized to obtain a to-be-optimized package volume parameter queue.
[0059] In the specific implementation process, the features of the to-be-optimized package volume parameters are extracted to obtain feature parameters corresponding to the to-be-optimized package volume parameters; the optimization priority sorting model is trained in advance to identify the feature parameters to obtain optimization priority scores corresponding to the feature parameters; the to-be-optimized package volume parameters are sorted in descending order of the optimization priority scores to obtain the to-be-optimized package volume parameter queue.
[0060] In step S104, the to-be-optimized package volume parameters are optimized one by one by using parameter optimization methods corresponding to the to-be-optimized package volume parameters in the to-be-optimized package volume parameter queue to obtain an APK package volume optimization result.
[0061] In the specific implementation process, each optimization rule in the preset optimization rule database is queried based on the to-be-optimized package volume parameter to obtain an optimization method corresponding to the to-be-optimized package volume parameter and a parameter transfer method; the to-be-optimized package volume parameter is optimized by using the optimization method based on the parameter transfer method to obtain an APK package volume optimization result.
[0062] The application can accurately identify the key factors causing the APK package volume change to obtain each to-be-optimized package volume parameter. The to-be-optimized package volume parameters are prioritized for optimization to obtain a to-be-optimized package volume parameter queue. Each to-be-optimized package volume parameter is optimized by using a parameter optimization mode corresponding to each to-be-optimized package volume parameter in the to-be-optimized package volume parameter queue, and an APK package volume optimization result is obtained. The application realizes the automation of APK package volume optimization, reduces the manual operation of the developer, and improves the development efficiency.
[0063] Another embodiment of the application provides another APK package volume optimization method, as shown in Figure 2
[0064] Step S201: unpacking different versions of APK packages of a target application to obtain package volume parameters corresponding to the different versions of APK packages.
[0065] In the specific implementation process, the same version of APK package is parsed to obtain an HTML report and a JSON data file; the package volume data of the HTML report and the JSON data file is extracted to obtain the package volume parameters corresponding to the same version of APK package; the package volume parameters include file quantity, method number, and resource usage analysis parameters. The file quantity parameters include APK file overall data quantity, classification file quantity corresponding to the APK file, code file quantity, resource file quantity, dynamic library file quantity, and the like; the method number parameters include total method number and third-party library method number; the resource usage analysis parameters include redundant resource parameters, repeated resource parameters, and resource type distribution parameters; wherein the APK file overall data quantity can be directly obtained from the first page of the HTML report or the apkSize field of the JSON data file (unit: byte); the classification file quantity corresponding to the APK file includes code classification file quantity, resource classification file quantity, and library file classification quantity; the code file quantity includes classes.dex code file quantity, resources.arsc code file quantity, and the like, corresponding to the dex type file under fileList in JSON. The resource file quantity includes picture (drawable, mipmap) file quantity, layout (layout) file quantity, string (values / strings.xml), and the like, corresponding to the total file size under the res directory. The dynamic library file quantity includes the.so file size under the lib / directory (such as the library of armeabi-v7a, arm64-v8a, and the like).
[0066] Step S202: Constructing detection rules corresponding to different detection indexes;
[0067] In the implementation process of the present step, based on the parameter type of the package volume parameter, each detection index corresponding to the parameter type is determined. The parameter type includes a resource parameter type and a code parameter type. When the parameter type of the package volume is the resource parameter type, each detection index includes: unused resource quantity, picture resource compression rate, repeated resource quantity, dynamic library volume proportion, and text file size, etc. When the parameter type is the code parameter type, each detection index determined includes: method number growth rate, unused code proportion, and third-party library method number proportion, etc. Query paths and trigger conditions corresponding to each detection index are constructed respectively. For example: for the detection index of unused resource quantity, the trigger condition is unusedResourcesCount>0, and the query path is: resource file path (such as drawable, xml). For the detection index of method number growth rate, the trigger condition is “methodCountDiff>100 and methodPctChange>5%”, and the query path is the newly added class path (such as com / thirdparty), etc. Based on the query path and the trigger condition corresponding to the same detection index, the detection rule corresponding to the same detection index is constructed.
[0068] Step S203: Using the detection rules corresponding to different detection indexes to detect the package volume parameters between different versions of APK packages, to obtain the to-be-optimized package volume parameters corresponding to different detection indexes;
[0069] In the implementation process of the present step, the triggering conditions of different detection indexes are monitored; when the value of the target detection index meets the triggering condition, the package volume parameter is queried using the to-be-optimized parameter query rule corresponding to the target detection index, and the to-be-optimized package volume parameter corresponding to the target detection index is obtained. For example, when the detection index is the number of unused resources, the triggering condition is unusedResourcesCount>0, and the query path is: resource file path (such as drawable, xml); when the number of unused resources is greater than the preset threshold 0, the package volume parameter is queried based on the resource file paths drawable and xml, and the to-be-optimized package volume parameter corresponding to the target detection index is obtained. The version feature of the APK file is obtained; the target detection index to be dynamically adjusted is determined based on the version feature; and the threshold value of the triggering condition of the target detection index is dynamically adjusted. For example, when the version feature is a functional iteration version, the method number growth threshold is relaxed (allowing methodPctChange<8%), the functional integrity is preferentially ensured, and the method number growth threshold is dynamically adjusted. When the version feature is a maintenance version, the resource growth (resourcePctChange<3%) is strictly controlled, and the redundancy is forcibly cleaned up, so as to dynamically adjust the resource growth threshold.
[0070] Step S204: feature extraction is performed on each to-be-optimized package volume parameter to obtain a feature parameter corresponding to each to-be-optimized package volume parameter.
[0071] In the implementation process of the present step, feature extraction is performed on each to-be-optimized package volume parameter to obtain a feature parameter corresponding to each to-be-optimized package volume parameter; the feature parameter includes a parameter type, a parameter change amplitude, and historical optimization effect data. For example, the parameter type includes unusedResources, soSize, etc.; the parameter change amplitude is pctChange, etc.; and the historical optimization effect data includes a volume reduction rate brought by past optimization of a certain type of parameter, etc.
[0072] Step S205: each feature parameter is identified using a pre-trained optimization priority score model to obtain an optimization priority score corresponding to each feature parameter.
[0073] In the specific implementation process of this step, the feature parameters corresponding to each of the to-be-optimized package volume parameters are input into the pre-trained optimization priority scoring model to obtain optimization priority scores corresponding to each of the feature parameters. The scores can be set to 0-10, and the to-be-optimized package volume parameter with a higher score needs to be prioritized for optimization processing. The optimization priority scoring model can use GPT or other natural language processing models to take the feature parameters as inputs of the model and take the optimization priority scores as outputs of the model for model training.
[0074] Step S206: The to-be-optimized package volume parameters are sorted in descending order of the optimization priority scores to obtain a to-be-optimized package volume parameter queue.
[0075] In the specific implementation process of this step, the to-be-optimized package volume parameters are sorted in descending order of the optimization priority scores to obtain a to-be-optimized package volume parameter queue.
[0076] Step S207: Each optimization rule in a pre-set optimization rule database is queried based on the to-be-optimized package volume parameters to obtain an optimization method and a parameter transfer mode corresponding to the to-be-optimized package volume parameters in the to-be-optimized package volume parameter queue.
[0077] In the implementation process, the optimization method includes calling a tool for optimization operation or using a code for optimization operation; specifically, a query path of the to-be-optimized package volume parameter is determined; each optimization rule in a preset optimization rule database is queried based on the query path to obtain an optimization method corresponding to the to-be-optimized package volume parameter in the to-be-optimized package volume parameter queue and a parameter passing mode. For example, when the query path corresponding to the to-be-optimized package volume parameter is an unused resource path list, each optimization rule in the preset optimization rule database is queried, and the obtained optimization method is to call the AndResGuard tool, and the parameter passing mode is to pass in through the unusedRes field of the configuration file AndResGuard-configuration.xml; when the query path corresponding to the to-be-optimized package volume parameter is an uncompressed image path, each optimization rule in the preset optimization rule database is queried, and the obtained optimization method is to call the TinyPNG API, and the parameter passing mode is to upload a batch of file path lists to the TinyPNG server; when the query path corresponding to the to-be-optimized package volume parameter is a redundant dynamic library architecture, each optimization rule in the preset optimization rule database is queried, and the obtained optimization method is to call the APK Splits (Gradle), and the parameter passing mode is to exclude the redundant architecture in the abiFilters in build.gradle; when the query path corresponding to the to-be-optimized package volume parameter is an unused code class name, each optimization rule in the preset optimization rule database is queried, and the obtained optimization method is to call the ProGuard / R8 rule file, and the parameter passing mode is to add the -keep or-removeunused rule in proguard-rules.pro.
[0078] Step S208: An optimization method is used to perform optimization processing on the to-be-optimized package volume parameter based on the parameter passing mode, and an APK package volume optimization result is obtained.
[0079] In the implementation process, the to-be-optimized package volume parameter is subjected to package volume optimization by calling a corresponding optimization method according to a parameter passing mode corresponding to the to-be-optimized package volume parameter, and an APK package volume optimization result is obtained.
[0080] Step S209: The APK package volume optimization result is saved in a preset database.
[0081] In the implementation process, the optimization result (such as a parameter, a tool, and an effect) is stored in a historical database for iterative updating of an optimization rule and an optimization priority scoring model.
[0082] This application unpacks different versions of APK packages of the target application to obtain package volume parameters corresponding to different versions of APK packages; constructs detection rules corresponding to different detection indicators; uses the detection rules corresponding to the different detection indicators of the package volume parameters to detect the package volume parameters between different versions of APK packages, and obtains the package volume parameters to be optimized corresponding to different detection indicators; by defining a quantifiable optimization rule engine, the package volume parameters to be optimized can be quickly located; obvious problems can be quickly filtered out through simple rules. Feature extraction is performed on each of the package volume parameters to be optimized to obtain feature parameters corresponding to each of the package volume parameters to be optimized; the package volume parameters to be optimized are sorted in descending order of optimization priority score to obtain the queue of package volume parameters to be optimized; using a trained optimization priority sorting model to sort the package volume parameters to be optimized can improve the ability to handle complex correlations and significantly improve the efficiency and accuracy of APK package volume optimization. Based on the APK size parameter to be optimized, the system queries the preset optimization rule database to obtain the optimization method and parameter passing method corresponding to the APK size parameter in the queue. Based on the parameter passing method, the system uses the optimization method to optimize the APK size parameter, resulting in an APK size optimization result. This achieves fully automated APK size optimization and improves optimization efficiency. The APK size optimization result is stored in the preset database. The source of each optimizable parameter is recorded to ensure traceability.
[0083] Another embodiment of this application provides an APK package size optimization device, such as... Figure 3 As shown, it includes:
[0084] Unpacking module 1 is used to unpack different versions of the target application's APK package to obtain the package size parameters corresponding to different versions of the APK package;
[0085] Detection module 2 is used to detect the package volume parameters between different versions of APK packages using detection rules corresponding to different detection indicators, and to obtain the package volume parameters to be optimized corresponding to different detection indicators.
[0086] Sorting module 3 is used to sort the optimization priority of each of the packet volume parameters to be optimized, and obtain a queue of packet volume parameters to be optimized.
[0087] Optimization module 4 is used to optimize each of the package volume parameters one by one using the parameter optimization method corresponding to each of the package volume parameters in the package volume parameter queue, so as to obtain the APK package volume optimization result.
[0088] In the specific implementation process, the unpacking module 1 is specifically configured to: parse the same version APK package to obtain an HTML report and a JSON data file; perform package volume data extraction on the HTML report and the JSON data file respectively to obtain a package volume parameter corresponding to the same version APK package; and the package volume parameter includes a file quantity, a method number, and a resource usage analysis parameter.
[0089] In the specific implementation process, the device further includes a detection rule construction module, which is specifically configured to: construct a detection rule corresponding to each detection index, specifically including: determining each detection index corresponding to a parameter type based on a parameter type of a package volume parameter; constructing a query path and a trigger condition corresponding to each detection index; and constructing a detection rule corresponding to the same detection index based on the query path and the trigger condition corresponding to the same detection index.
[0090] In the specific implementation process, the detection module 2 is specifically configured to: listen to a trigger condition of each detection index; and when a value of a target detection index meets the trigger condition, query the package volume parameter by using a to-be-optimized parameter query rule corresponding to the target detection index to obtain a to-be-optimized package volume parameter corresponding to the target detection index.
[0091] In the specific implementation process, the device further includes a threshold updating module, which is specifically configured to: obtain a version feature of the APK file; determine a target detection index to be dynamically adjusted based on the version feature; and dynamically adjust a threshold of a trigger condition of the target detection index.
[0092] In the specific implementation process, the sorting module 3 is specifically configured to: perform feature extraction on each to-be-optimized package volume parameter to obtain a feature parameter corresponding to each to-be-optimized package volume parameter; identify each feature parameter by using a pre-trained optimization priority sorting model to obtain an optimization priority score corresponding to each feature parameter; and sort each to-be-optimized package volume parameter in a descending order of optimization priority score to obtain a to-be-optimized package volume parameter queue.
[0093] In the specific implementation process, the optimization module 4 is specifically configured to: query each optimization rule in a preset optimization rule database based on the to-be-optimized package volume parameter to obtain an optimization method and a parameter transmission mode corresponding to the to-be-optimized package volume parameter; and perform optimization processing on the to-be-optimized package volume parameter by using the optimization method based on the parameter transmission mode to obtain an APK package volume optimization result.
[0094] The application can accurately identify the key factors causing the APK package volume change to obtain each to-be-optimized package volume parameter. The to-be-optimized package volume parameters are prioritized for optimization to obtain a to-be-optimized package volume parameter queue. Each to-be-optimized package volume parameter is optimized one by one by using a parameter optimization mode corresponding to each to-be-optimized package volume parameter in the to-be-optimized package volume parameter queue to obtain an APK package volume optimization result. The application realizes the automation of APK package volume optimization, reduces the manual operation of the developer, and improves the development efficiency.
[0095] Another embodiment of the application provides a storage medium storing a computer program, which, when executed by a processor, implements the following method steps:
[0096] Step one, unpacking different versions of APK packages of a target application to obtain package volume parameters corresponding to the different versions of APK packages;
[0097] Step two, detecting the package volume parameters between different versions of APK packages by using detection rules corresponding to different detection indexes to obtain to-be-optimized package volume parameters corresponding to the different detection indexes;
[0098] Step three, prioritizing each to-be-optimized package volume parameter for optimization to obtain a to-be-optimized package volume parameter queue;
[0099] Step four, optimizing each to-be-optimized package volume parameter one by one by using a parameter optimization mode corresponding to each to-be-optimized package volume parameter in the to-be-optimized package volume parameter queue to obtain an APK package volume optimization result.
[0100] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when executed, can include the processes of the above-mentioned embodiment methods. Any reference to memory, storage, database or other medium used in the embodiments provided in the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0101] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above-mentioned division of functional units and modules is exemplified, and in actual application, the above-mentioned functions can be completed by different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the above-mentioned functions.
[0102] The specific implementation process of the above method steps can refer to the embodiments of any APK package volume optimization method described above, which will not be repeated here.
[0103] The application can accurately identify the key factors causing the APK package volume change to obtain each to-be-optimized package volume parameter. Each to-be-optimized package volume parameter is prioritized for optimization to obtain a to-be-optimized package volume parameter queue; each to-be-optimized package volume parameter is optimized one by one by using a parameter optimization mode corresponding to each to-be-optimized package volume parameter in the to-be-optimized package volume parameter queue, and an APK package volume optimization result is obtained. The application realizes the automation of APK package volume optimization, reduces the manual operation of the developer, and improves the development efficiency.
[0104] Another embodiment of the application provides an electronic device, which can be a server. The electronic device includes a processor, a memory, a network interface and a database connected by a system bus. The processor of the electronic device is configured to provide computing and control capabilities. The memory of the electronic device includes a non-volatile and / or volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for running the operating system and the computer program in the non-volatile storage medium. The network interface of the electronic device is configured to communicate with an external client through a network connection. The electronic device program is executed by the processor to implement the functions or steps of the APK package volume optimization method on the server side.
[0105] In one embodiment, an electronic device is provided, which can be a client. The electronic device includes a processor, a memory, a network interface, a display screen and an input device connected by a system bus. The processor of the electronic device is configured to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for running the operating system and the computer program in the non-volatile storage medium. The network interface of the electronic device is configured to communicate with an external server through a network connection. The electronic device program is executed by the processor to implement the functions or steps of the APK package volume optimization method on the client side.
[0106] Another embodiment of the application provides an electronic device, which includes at least a memory and a processor. The memory stores a computer program. The processor implements the following method steps when executing the computer program on the memory.
[0107] Step one, unpacking different versions of APK packages of a target application to obtain package volume parameters corresponding to different versions of APK packages;
[0108] Step two, detecting the package volume parameters between different versions of APK packages by using detection rules corresponding to different detection indexes, to obtain to-be-optimized package volume parameters corresponding to different detection indexes;
[0109] Step three, performing optimization priority sorting on each of the to-be-optimized package volume parameters, to obtain a to-be-optimized package volume parameter queue;
[0110] Step four, performing optimization on each of the to-be-optimized package volume parameters by using a parameter optimization mode corresponding to each of the to-be-optimized package volume parameters in the to-be-optimized package volume parameter queue, to obtain an APK package volume optimization result.
[0111] The specific implementation process of the above method steps can be referred to the embodiments of any of the APK package volume optimization methods described above, which will not be repeated here.
[0112] The application can obtain package volume parameters corresponding to different versions of APK packages by unpacking the different versions of APK packages of a target application, detect the package volume parameters between different versions of APK packages by using detection rules corresponding to different detection indexes of the package volume parameters, to obtain to-be-optimized package volume parameters corresponding to different detection indexes, accurately identify key factors causing APK package volume changes, and obtain each to-be-optimized package volume parameter. The to-be-optimized package volume parameters are sorted in optimization priority, to obtain a to-be-optimized package volume parameter queue, and each of the to-be-optimized package volume parameters is optimized by using a parameter optimization mode corresponding to each of the to-be-optimized package volume parameters in the to-be-optimized package volume parameter queue, to obtain an APK package volume optimization result. The application realizes the automation of APK package volume optimization, reduces the manual operation of developers, and improves the development efficiency.
[0113] The above embodiments are only exemplary embodiments of the application and are not used to limit the application, and the protection scope of the application is defined by the claims. Those skilled in the art can make various modifications or equivalent replacements to the application within the spirit and protection scope of the application, and such modifications or equivalent replacements should also be considered to fall within the protection scope of the application.
Claims
1. A method for optimizing APK package size, characterized in that, include: Unpack the APK packages of different versions of the target application to obtain the package size parameters corresponding to the different versions of the APK packages; The package volume parameters of different versions of APK packages are detected by using detection rules corresponding to different detection indicators, and the package volume parameters to be optimized corresponding to different detection indicators are obtained. The optimization priority of each packet volume parameter to be optimized is sorted to obtain a queue of packet volume parameters to be optimized. Each of the APK package volume parameters is optimized one by one using the parameter optimization method corresponding to each of the APK package volume parameters in the queue of APK package volume parameters, so as to obtain the APK package volume optimization result.
2. The method as described in claim 1, characterized in that, The unpacking process of different versions of the target application's APK packages to obtain the package size parameters corresponding to different versions of the APK packages specifically includes: Parse APK packages of the same version to obtain HTML reports and JSON data files; The package volume data of the HTML report and the JSON data file are extracted respectively to obtain the package volume parameters corresponding to the APK package of the same version; The package size parameters include: number of files, number of methods, and resource usage analysis parameters.
3. The method as described in claim 1, characterized in that, Before using detection rules corresponding to different detection indicators to detect the package volume parameters between different versions of APK packages, the method further includes: constructing detection rules corresponding to different detection indicators; The construction of detection rules corresponding to different detection indicators specifically includes: The parameter type is determined based on the package volume parameter, and each detection index is corresponding to the parameter type. Construct query paths and triggering conditions corresponding to each of the aforementioned detection indicators; Based on the query path and triggering conditions corresponding to the same detection indicator, a detection rule corresponding to the same detection indicator is constructed.
4. The method as described in claim 1, characterized in that, The method involves using detection rules corresponding to different detection indicators to detect the package volume parameters between different versions of APK packages, thereby obtaining the package volume parameters to be optimized corresponding to different detection indicators. Specifically, this includes: The triggering conditions for different detection indicators are monitored; When the value of the target detection index meets the triggering condition, the packet volume parameter is queried using the query rule for the parameter to be optimized corresponding to the target detection index, and the packet volume parameter to be optimized corresponding to the target detection index is obtained.
5. The method as described in claim 3, characterized in that, The method further includes: Obtain the version characteristics of the APK file; Based on the aforementioned version characteristics, determine the target detection index to be dynamically adjusted in terms of threshold. The threshold for triggering the target detection index is dynamically adjusted.
6. The method as described in claim 1, characterized in that, The optimization priority of each of the packet volume parameters to be optimized is sorted to obtain a queue of packet volume parameters to be optimized, specifically including: Feature extraction is performed on each of the packet volume parameters to be optimized to obtain feature parameters corresponding to each of the packet volume parameters to be optimized. A pre-trained optimization priority ranking model is used to identify each of the aforementioned feature parameters to obtain an optimization priority score corresponding to each of the aforementioned feature parameters; The packet volume parameters to be optimized are sorted in descending order of optimization priority score to obtain the packet volume parameter queue.
7. The method as described in claim 1, characterized in that, The step of optimizing each of the APK package volume parameters one by one using the parameter optimization method corresponding to each of the APK package volume parameters in the queue of APK package volume parameters to obtain the APK package volume optimization result specifically includes: Based on the packet volume parameter to be optimized, query the optimization rules in the preset optimization rule database to obtain the optimization method and parameter passing method corresponding to the packet volume parameter to be optimized. Based on the parameter passing method, the optimization method is used to optimize the size parameters of the package to be optimized, and the APK package size optimization result is obtained.
8. An APK package size optimization device, characterized in that, include: The unpacking module is used to unpack different versions of the target application's APK package to obtain the package size parameters corresponding to different versions of the APK package; The detection module is used to detect the package volume parameters between different versions of APK packages using detection rules corresponding to different detection indicators, and to obtain the package volume parameters to be optimized corresponding to different detection indicators. The sorting module is used to sort the optimization priority of each of the packet volume parameters to be optimized, and obtain a queue of packet volume parameters to be optimized. The optimization module is used to optimize each of the package volume parameters one by one using the parameter optimization method corresponding to each of the package volume parameters in the package volume parameter queue, so as to obtain the APK package volume optimization result.
9. A storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the steps of the APK package size optimization method according to any one of claims 1-7.
10. An electronic device, characterized in that, It includes at least a memory and a processor, wherein the memory stores a computer program, and the processor, when executing the computer program in the memory, implements the steps of the APK package size optimization method according to any one of claims 1-7.