Method for generating APK file, related device and computer program product
By using the compatible interface to obtain image data and convert it to Webp format during the APK file generation process, the problem of large size of APK files is solved, compatibility with different Gradle plug-in versions is achieved, and data acquisition and storage efficiency is improved.
Patent Information
- Application Number
- CN202311716447.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-13
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2043-12-13
AI Technical Summary
The size of APK files is large, which affects application performance and user experience. The existing technology is difficult to compatible with different Gradle plug-in versions, improving data acquisition capabilities.
The first image data used to generate the APK file is obtained through the compatible interface, converted to Webp format, and then generated the APK file after compression. This method uses virtual interfaces to be compatible with different Gradle plug-in versions to improve data acquisition capabilities.
It reduces the size of the generated APK file, saves storage space, is compatible with different Gradle plug-in versions, and improves data acquisition capabilities.
Smart Images

Figure CN117708067B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data processing technology, specifically data storage, data compression, cloud storage and cloud services, and in particular to methods, devices, electronic devices, computer-readable storage media and computer program products for generating APK files. Background Art
[0002] Electronic device applications mainly refer to software installed on electronic devices, which can improve the deficiencies of the original system and provide users with personalized extended services. Therefore, applications can not only improve the use functions of electronic devices, but also provide users with a richer use experience.
[0003] At present, with the continuous development of mobile applications, in the Android operating system and environment, the Android application package (APK) format is chosen to build storage content. Therefore, the size of the APK file has become a key factor affecting application performance and user experience. Summary of the invention
[0004] The embodiments of the present disclosure provide a method, an apparatus, an electronic device, a computer-readable storage medium, and a computer program product for generating an APK file.
[0005] In a first aspect, an embodiment of the present disclosure proposes a method for generating an APK file, comprising: using a compatible interface to obtain first image data for generating an APK file, wherein the compatible interface is used to provide virtual interfaces of different versions of a native Gradle plug-in; in response to the first image data being in a first format, converting the first format into a Webp format to generate second image data, wherein the first format includes: PNG format and / or JPG format; compressing the second image data, and generating an APK file using the compilation result of the compressed second image data.
[0006] In the second aspect, an embodiment of the present disclosure proposes a device for generating an APK file, including: an image data acquisition unit, configured to use a compatible interface to acquire first image data for generating an APK file, wherein the compatible interface is used to provide virtual interfaces of different versions of a native Gradle plug-in; a first format conversion unit, configured to convert the first format into a Webp format in response to the first image data being in a first format, to generate second image data, wherein the first format includes: PNG format and / or JPG format; a first file generation unit, configured to compress the second image data, and generate an APK file using the compilation result of the compressed second image data.
[0007] In a third aspect, an embodiment of the present disclosure provides an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that when the at least one processor executes, it is possible to implement the method for generating an APK file as described in any implementation method in the first aspect.
[0008] In a fourth aspect, an embodiment of the present disclosure provides a non-transitory computer-readable storage medium storing computer instructions, which are used to enable a computer to implement the method of generating an APK file as described in any implementation method in the first aspect when executed.
[0009] In a fifth aspect, an embodiment of the present disclosure provides a computer program product comprising a computer program, which, when executed by a processor, can implement the method for generating an APK file as described in any implementation manner in the first aspect.
[0010] The method, device, electronic device, computer-readable storage medium and computer program product for generating an APK file provided by the embodiments of the present disclosure use a compatible interface for providing different versions of virtual interfaces of a native Gradle plug-in to obtain first image data for generating an APK file, and respond when the first image data is in a first format to convert the first format into a Webp format to generate second image data, wherein the first format includes: PNG format and / or JPG format. Then, the second image data obtained after the format conversion is compressed, and the APK file is generated using the compilation result of the compressed second image data.
[0011] The present disclosure can reduce the size of the generated APK file and save storage space by converting the format of images of specific data types while being compatible with the usage requirements of different Gradle plug-in versions and improving data acquisition capabilities.
[0012] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] Other features, objects and advantages of the present disclosure will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:
[0014] Figure 1 is an exemplary system architecture in which the present disclosure may be applied;
[0015] Figure 2A flowchart of a method for generating an APK file provided in an embodiment of the present disclosure;
[0016] Figure 3 A flowchart of a process for generating an APK file based on first image data in a first format provided by an embodiment of the present disclosure;
[0017] Figure 4 A flowchart of a process for generating an APK file based on first image data in a second format provided by an embodiment of the present disclosure;
[0018] Figure 5 A schematic diagram of the architecture of a method for generating an APK file in an application scenario provided by an embodiment of the present disclosure;
[0019] Figure 6 A structural block diagram of a device for generating an APK file provided in an embodiment of the present disclosure;
[0020] Figure 7 A schematic diagram of the structure of an electronic device suitable for executing a method for generating an APK file provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0021] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description. It should be noted that the embodiments in the present disclosure and the features in the embodiments may be combined with each other without conflict.
[0022] In addition, in the technical solutions involved in the present disclosure, the acquisition (for example, the image data used to generate APK files involved in the present disclosure may be facial image data uploaded by the user), storage, use, processing, transportation, provision and disclosure of user personal information are in compliance with relevant laws and regulations and do not violate public order and good morals.
[0023] Figure 1 An exemplary system architecture 100 is shown to which embodiments of the method, apparatus, electronic device, and computer-readable storage medium for generating an APK file disclosed herein can be applied.
[0024] like Figure 1As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0025] The user can use the terminal devices 101, 102, 103 to interact with the server 105 through the network 104 to receive or send messages, etc. The terminal devices 101, 102, 103 and the server 105 can be installed with various applications for realizing information communication between the two, such as APK file generation applications, cloud storage applications, instant messaging applications, etc.
[0026] Terminal devices 101, 102, 103 and server 105 can be hardware or software. When terminal devices 101, 102, 103 are hardware, they can be various electronic devices with display screens, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, etc.; when terminal devices 101, 102, 103 are software, they can be installed in the electronic devices listed above, which can be implemented as multiple software or software modules, or as a single software or software module, and no specific limitation is made here. When server 105 is hardware, it can be implemented as a distributed server cluster composed of multiple servers, or as a single server; when the server is software, it can be implemented as multiple software or software modules, or as a single software or software module, and no specific limitation is made here.
[0027] The server 105 can provide various services through various built-in applications. Taking an APK file generation application that can provide APK file generation service as an example, the server 105 can achieve the following effects when running the APK file generation application: first, obtain the first image data for generating an APK file from the terminal devices 101, 102, and 103 through the network 104 using a compatible interface, wherein the compatible interface is used to provide virtual interfaces of different versions of the native Gradle plug-in; then, in response to the first image data being in a first format, the server 105 converts the first format into a Webp format to generate second image data, wherein the first format includes: PNG format and / or JPG format; finally, the server 105 compresses the second image data, and generates an APK file using the compilation result of the compressed second image data.
[0028] It should be noted that, in addition to being obtained from the terminal devices 101, 102, and 103 through the network 104, the first image data can also be pre-stored locally in the server 105 in various ways. Therefore, when the server 105 detects that the data has been stored locally (for example, when starting to process the previously retained APK file generation and storage tasks), it can choose to directly obtain the data locally. In this case, the exemplary system architecture 100 may also not include the terminal devices 101, 102, 103 and the network 104.
[0029] Since generating an APK file requires more computing resources and stronger computing power, the methods for generating an APK file provided in the subsequent embodiments of the present disclosure are generally performed by a server 105 having stronger computing power and more computing resources, and accordingly, the device for generating an APK file is generally also set in the server 105. However, it should also be pointed out that when the terminal devices 101, 102, and 103 also have computing power and computing resources that meet the requirements, the terminal devices 101, 102, and 103 can also use the APK file generation class application installed thereon as an example to complete the above-mentioned various operations that are handed over to the server 105, and then output the same result as the server 105. Especially in the case where there are multiple terminal devices with different computing powers at the same time, but when the APK file generation class application is used as an example to determine that the terminal device where it is located has stronger computing power and more remaining computing resources, the terminal device can be allowed to perform the above-mentioned operations, thereby appropriately reducing the computing pressure of the server 105, and accordingly, the device for generating an APK file can also be set in the terminal devices 101, 102, and 103. In this case, the exemplary system architecture 100 may also not include the server 105 and the network 104 .
[0030] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.
[0031] Please refer to Figure 2 , Figure 2 A flowchart of a method for generating an APK file provided in an embodiment of the present disclosure, wherein process 200 includes the following steps:
[0032] Step 201: Acquire first image data for generating an APK file using a compatible interface;
[0033] This step is intended to be performed by the execution subject of the method for generating an APK file (for example Figure 1The server 105 shown in the figure) obtains the first image data for generating the APK file. In the embodiment of the present disclosure, the execution subject can actually build and execute the APK generation task based on the Gradle plug-in (abbreviated as Gradle). Gradle is a project automation tool based on the concepts of Apache Ant and Apache Maven. The execution subject can communicate with other modules configured in the machine (for example, a storage module for image data) or other electronic devices through the Gradle interface (i.e., Android GradlePlugin) to obtain the first image data for generating the APK file.
[0034] In other words, the first image data may be directly obtained by the execution subject from a local storage device, or from a non-local storage device (eg Figure 1 The local storage device may be a data storage module provided in the above-mentioned execution subject, such as a server hard disk, in which case the first image data can be quickly read locally; the non-local storage device may also be any other electronic device provided for storing data, such as some user terminals, in which case the above-mentioned execution subject may obtain the required first image data by sending an acquisition command to the electronic device.
[0035] In the embodiments of the present disclosure, the execution subject can use the compatible interface to ensure that the communication is smoothly implemented. The compatible interface is used to provide virtual interfaces of different versions of the native Gradle plug-in. The compatible interface can provide a unified interface to the outside by abstracting different Android Gradle Plugin version interfaces, so that the execution subject can communicate with related modules and external devices in a compatible manner based on the abstract results of the compatible interface. For example, the compatible interface can abstract the virtual interfaces corresponding to each version based on different versions of the native Gradle plug-in.
[0036] In some optional implementations of this embodiment, first image data for generating an APK file is obtained using a compatible interface, including: in response to receiving a data input request for the first image data from a target device, parsing a target version of the Gradle plug-in requested to be used in the data input request; configuring a virtual interface corresponding to the target version for the target device to communicate with the target device using the virtual interface to obtain the first image data.
[0037] Specifically, when the execution subject receives a data incoming request for the first image data from the target device (for example, the terminal device used by the user, such as terminal devices 101, 102, 103) (or, the user sends an incoming request to the execution subject through the target device in the hope of transmitting the first image data), the execution subject can understand the version of the Gradle plug-in used by the user by parsing the target version of the Gradle plug-in requested in the data incoming request. Accordingly, the execution subject can abstract and configure the corresponding virtual interface based on the target version, so that the target device can communicate with the execution subject based on the configured virtual interface, and communicate with the target device using the virtual interface to obtain the first image data. As a result, the user can communicate with the execution subject based on access requests for different versions of the Gradle plug-in, which can improve the feasibility and practicality of the method for generating APK files.
[0038] In practice, the data provided by the user to the execution entity for generating the APK file may not be limited to image data (for the convenience of description, it can be described as the first image data). For example, the user may provide a set of data including text data, SDK, etc. to the user. In this case, the execution entity can determine the first image data included therein based on the data analysis and data type identification results of the set of data. As a result, the user can arbitrarily provide and upload data according to the needs without the user side "separately parsing and uploading image data", which can reduce the data provision requirements for the user.
[0039] Step 202: Detect the format of the first image data;
[0040] Based on the above step 201, this step is intended to detect the format of the acquired first image data by the execution subject. Generally, the format of the first image data can be, for example, PNG format, JPG format, GIF format, etc.
[0041] Further, if the execution entity detects that the format of the first image data is a first format, for example, the first format includes: PNG format and / or JPG format, the execution entity may further execute step 203 .
[0042] Step 203: In response to the first image data being in the first format, converting the first format into the Webp format to generate second image data;
[0043] This step is intended to convert the first image data into the Webp format (abbreviated as Webp) if the execution subject determines that the first image data is in the first format. For ease of understanding, the image data obtained after the format conversion can be described as "second image data". Thus, the "file size" is reduced by converting the format.
[0044] WebP is an image file format that provides both lossy compression and lossless compression (reversible compression), and the maximum number of pixels it supports is 16383x16383. Furthermore, for lossy compressed WebP, it can support 8-bit YUV4:2:0 format. And lossless compressed (reversible compression) WebP, it can support VP8L encoding and 8-bit ARGB color space. In addition, whether it is lossy or lossless compressed WebP, it can support Alpha transparent channel, ICC color configuration, XMP interpretation data, etc. Moreover, WebP also has the distinction between static and dynamic modes. Taking dynamic WebP (Animated WebP) as an example, it can support lossy and lossless compression, ICC color configuration, XMP interpretation data, and Alpha transparent channel.
[0045] Accordingly, in an embodiment of the present disclosure, selection of the first format may be determined based on a comparison of the volume of the document in the original format and in the Webp format. For example, for image data A, when the file volume thereof in a certain format (for example, PNG format) is larger than the volume thereof in the Webp format, the PNG format may be determined as the first format.
[0046] In some embodiments, the volume change threshold may be determined based on the conversion relationship between the cost of computing resources required for format conversion and the storage resources, occupied space, etc. that can be saved by format conversion, so that the corresponding source format is determined as the first format only when the volume change caused by format conversion exceeds the volume threshold requirement. In this way, the purpose of saving computing and storage resources can be substantially achieved.
[0047] Step 204: compress the second image data, and generate an APK file using the compilation result of the compressed second image data.
[0048] On the basis of the above step 203, this step aims to obtain the second image data in Webp format and then compress (or compile) it to generate an APK file (or at least part of the APK file). For example, the execution subject can create an Android project after compressing the second image data (for example, compressing it into a ZIP compressed file), and put the compressed second image data in the assets directory of the project. Furthermore, the execution subject can choose to create a WebView component in the Android project, and load the main entry file of the WebApp by calling loadUrl() to provide a way to compile and package the Android project to generate an APK file. Subsequently, the execution subject can actually run and store the APK file according to the user's instructions to meet the user's different usage requirements. For example, when providing cloud storage services to users, the execution subject can place the APK file in the corresponding access path or folder according to the user's instructions to achieve purposes such as cloud storage.
[0049] The method for generating an APK file provided by the embodiment of the present disclosure can reduce the size of the generated APK file and save storage space by converting the format of images of specific data types while being compatible with the usage requirements of different Gradle plug-in versions and improving data acquisition capabilities.
[0050] In some optional implementations of the present embodiment, in response to the first image data being in the first format, the execution subject converts the first format into the Webp format to generate second image data, including: in response to the first image data being in the first format, detecting whether the data size of the first image data exceeds a preset data volume threshold; in response to the data size of the first image data exceeding the preset data volume threshold, converting the first format into the Webp format to generate second image data.
[0051] Specifically, when the execution subject determines that the first image data is in the first format, it can also detect whether the data size of the first image data exceeds a preset data volume threshold to determine whether the first format of the first image data is actually converted to the Webp format. In this way, it is avoided to convert the first image data that is too small and does not actually occupy much space, thereby avoiding wasting computing resources. For example, the execution subject can respond when it is determined that the data size of the first image data exceeds a preset data volume threshold (the data volume threshold can be determined based on the user or the operation and maintenance party's "large data volume file" that is "worth" being converted, or in other words, when the data volume of the first image data is greater than the "data volume threshold", the execution subject can determine that the first image data is a "large data volume file" that can be converted to a format), so as to convert the first format into the Webp format and generate the second image data.
[0052] In some optional implementations of this embodiment, when converting the first format into the Webp format to generate the second image data, the execution subject may convert the first format into the Webp format by using the cwebp tool to generate the second image data. Specifically, the execution subject may implement the format conversion based on the cwebp tool (e.g., the cwebp instruction). For example, based on the cwebp [input_image] -o [output_image.webp] instruction, where [input_image] is the path and file name of the input image file you want to convert, and [output_image.webp] is the path and file name of the output WebP file. Thus, the format conversion can be performed accurately and without error based on the native cwebp tool to ensure the quality of the conversion.
[0053] In some optional implementations of this embodiment, if the first format is PNG format, the process of converting the first format to Webp format using the cwebp tool may result in an increase in the file size by obtaining image data in Webp format. In this case, if this is contrary to the intended purpose of "reducing the file size", constraints may be set for this, so that when the execution entity detects that converting the image data to Webp format causes the file size to increase, it is considered that no conversion is required, or in other words, the situation is determined as "the cwebp tool failed to successfully convert the first format to Webp format". In this case, the execution entity can directly generate an APK file based on the compressed PNG format image data without converting it to Webp format.
[0054] For easier understanding, you can also refer to Figure 3 . Figure 3 A flowchart of a process 300 for generating an APK file based on first image data in a first format provided by an embodiment of the present disclosure. For example, process 300 can be used as a substitute for steps 203 to 204 in the above process 200 to achieve the purpose of converting the first format into the Webp format and generating second image data. Process 300 includes the following steps:
[0055] Step 301, using the cwebp tool to convert the first format into the Webp format;
[0056] Specifically, the execution subject may use the cwebp tool, for example, as described above, to perform an operation of converting the format of the first image data from the first format to the Webp format.
[0057] Step 302, in response to the cwebp tool failing to successfully convert the first format into the Webp format, compressing the first image data using the Pngquant tool, and generating an APK file using the compilation result of the compressed first image data.
[0058] Specifically, if the execution entity determines that the cwebp tool has not successfully converted the first format into the Webp format, it can respond to this by using Pngquant to compress the first image data in PNG format, and generate an APK file using the compiled result of the compressed first image data. The Pngquant tool is a cross-platform command-line lossy PNG compression tool. It is based on the portable libimagequant library, written in C99, and can significantly reduce the file size by converting PNG images into a more efficient multi-(e.g., 8)-bit PNG format, while retaining full Alpha transparency.
[0059] In some embodiments, if the format of the acquired first image data is not the first format (for the convenience of description, for example, the format of the first image data is a second format different from the first format), the execution subject may process it based on a processing strategy different from that for the first format, so as to achieve the purpose of being able to perform processing and generate APK files for each format file type. For example, the first image data in the second format may not cause its file size (or storage volume) to be "reduced" due to the execution of Webp conversion. For example, the second format may be GIF format.
[0060] For easier understanding, please refer to Figure 4 . Figure 4 A flowchart of a process 400 for generating an APK file based on first image data in a second format provided in an embodiment of the present disclosure. For example, process 400 may be executed when step 202 in the above process 200 determines that the first image data is in the second format, and process 400 specifically includes the following steps:
[0061] Step 401, in response to the format of the first image data being in GIF format, detecting whether a Webp format conversion request for the first image data in GIF format is received within a preset time period;
[0062] Specifically, for image data in GIF format, converting it to Webp format may not reduce its storage volume, or, compared with the reduced storage volume, it loses too many computing resources. In this case, the execution subject can choose to directly use the compression result of the first image data in GIF format to generate an APK file. However, as described above, the execution subject can adjust the conversion strategy according to the actual configuration needs of the user. For example, although converting the GIF format to the Webp format may not reduce the "storage volume", considering that the Webp format may have better transmission performance than the GIF (for example, for the same content, its Webp format can be transmitted faster than the GIF format), in this case, the user can instruct the execution subject to "also convert the second format to the Webp format" to enhance the transmission performance. In short, based on the classification rules of the first format and the second format determined by the execution subject in advance, the user can still instruct the execution subject to convert the second format to the Webp format to meet the different needs of the user.
[0063] Therefore, certain detection conditions, such as time conditions, can be configured so that the execution subject can determine whether the user has "special needs". For example, when the execution subject determines that the format of the first image data is the second format, it can detect whether a Webp format conversion request is issued for the first image data in the second format within a preset time period. If the Webp format conversion request is not received within the preset time period, the execution subject can determine that the user does not have a "special need to convert the second format to the Webp format", and the execution subject can further perform step 402.
[0064] Step 402, compressing the first image data using the Gifsicle tool, and generating an APK file using the compilation result of the compressed first image data;
[0065] Specifically, the execution subject can directly use the Gifsicle tool to compress the first image data in GIF format, so as to directly use the compression result of the first image data in GIF format to generate an APK file. Gifsicle is a command line tool specifically used to process GIF animations. It has a powerful compression function, which can reduce the file size of the animation by optimizing the color palette, reducing the number of colors, and deleting unnecessary data. Gifsicle not only provides a simple and easy-to-use command line interface, but also supports batch processing, which can quickly compress multiple GIF animations.
[0066] In some optional implementations of this embodiment, the execution entity may also convert the second format into the Webp format in response to receiving a Webp format conversion request within a preset time period, generate third image data; compress the third image data, and generate an APK file using the compilation result of the compressed third image data.
[0067] Specifically, please refer to Figure 4 .exist Figure 4 The illustrated process 400 may further include step 403 and step 404. Step 403 and step 404 may be executed when a Webp format conversion request is received within a preset time period based on step 401.
[0068] Step 403: Convert the second format into Webp format to generate third image data.
[0069] Specifically, as described above, if the execution entity receives a Webp format conversion request within a preset time period, it can choose to convert the second format into the Webp format. For the convenience of description, the image data in the Webp format obtained based on the conversion of the second format can be described as third image data.
[0070] Step 404: compress the third image data, and generate an APK file using the compilation result of the compressed third image data.
[0071] Specifically, the execution subject can execute convenience and generate an APK file based on the compression result of the third image data. Thus, the Webp format can be used to meet the special needs of users, such as preference for transmission speed.
[0072] In some embodiments, the execution entity can also adjust the usage parameters of the native Gradle plug-in using the configuration file in response to receiving a configuration file for the native Gradle plug-in, wherein the configuration file indicates at least one of the following: a first format, an enabling condition for converting the first format into a Webp format, and an image data compression parameter.
[0073] Specifically, in order to meet different configuration requirements of users, users can also specify the usage parameters of the Gradle plug-in through a configuration file. Accordingly, after receiving the configuration file for the native Gradle plug-in, the execution subject can use the configuration file to adjust the usage parameters of the native Gradle plug-in to meet the personalized needs of the user. In some optional implementations of this embodiment, the configuration file indicates at least one of the following: a first format, an enabling condition for converting the first format to a Webp format, and an image data compression parameter. For example, a user can use a configuration file to indicate the "first format" that needs to be converted, whether to perform a Webp format operation on the first format (or, the enabling condition for converting the first format to a Webp format, when to convert the first format to a Webp format, etc.), and image data compression parameters (for example, compressed file size, dimensions, etc.). Thus, it is convenient for users to customize the usage parameters of the Gradle plug-in according to their own needs and improve the user experience.
[0074] In addition, in some embodiments, it is also possible to choose to perform encapsulation operations correspondingly based on the implemented functions to obtain various modules that implement the corresponding functions. As a result, the execution subject can conveniently implement the functions of each part by calling the module. For example, for the above-mentioned function of receiving a configuration file for the native Gradle plug-in to adjust the usage parameters of the native Gradle plug-in, a "reading module" can be configured, so that the execution subject can call the corresponding function by calling and configuring the "reading module". Similarly, the "compatible interface" can be encapsulated as an "interface adaptation module" to achieve the purpose of "obtaining the first image data for generating an APK file using a compatible interface". Similarly, a "Webp conversion and compression module" for achieving the purpose of "converting the first format to the Webp format" and compressing the second image data in the Webp format can be obtained based on the cwebp tool encapsulation. Similarly, a "PNG image compression module" for achieving the purpose of compressing the first image data in the PNG format, for example, can be obtained based on the Pngquant tool encapsulation. Similarly, a "GIF compression module" for achieving the purpose of compressing the first image data in the GIF format, for example, can be obtained based on the Gifsicle tool encapsulation.
[0075] To deepen understanding, the present disclosure also provides a specific example architecture for implementing the above method in combination with a specific application scenario. Figure 5 Architecture 500 is shown.
[0076] In the architecture 500 , the execution body (eg, the server 105 ) may utilize the reading module 510 to communicate with the user to receive the configuration file for the native Gradle plugin.
[0077] After the adjustment is completed, the execution subject can use the interface adaptation module 520 to communicate with the user using a compatible interface to obtain the first image data.
[0078] Furthermore, the execution subject may utilize the Webp conversion and compression module 530 to process the first image data in the first format to convert it into second image data in the Webp format, and then compress it to obtain at least part of the compression result 560 .
[0079] In this case, if the Webp conversion and compression module 530 fails to successfully convert the first image data into the Webp format, as described above, for the first image data in the PNG format, the execution body can further call the PNG compression module 550 to process it to obtain at least part of the compression result 560.
[0080] In addition, for the first image data in the second format, the execution entity may call the GIF compression module 540 to compress it to obtain at least part of the compression result 560 .
[0081] Furthermore, the execution entity may package and generate an APK file 580 based on the compilation result 570 of the obtained compression result 560 (as exemplified above, the compression result 560 may at least be obtained by compressing a plurality of first image data and second image data).
[0082] Further references Figure 6 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a device for generating an APK file. Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0083] like Figure 6 As shown, the apparatus 600 for generating an APK file in this embodiment may include: an image data acquisition unit 601, a first format conversion unit 602, and a first file generation unit 603. The image data acquisition unit 601 is configured to acquire first image data for generating an APK file using a compatible interface, wherein the compatible interface is used to provide virtual interfaces of different versions of the native Gradle plug-in; the first format conversion unit 602 is configured to convert the first format into a Webp format in response to the first image data being in a first format, and generate second image data, wherein the first format includes: a PNG format and / or a JPG format; the first file generation unit 603 is configured to compress the second image data, and generate an APK file using the compilation result of the compressed second image data.
[0084] In the apparatus 600 for generating an APK file in this embodiment, the specific processing of the image data acquisition unit 601, the first format conversion unit 602, and the first file generation unit 603 and the technical effects thereof can be referred to in Figure 2 The relevant descriptions of steps 201 - 203 in the corresponding embodiment are not repeated here.
[0085] In some optional implementations of this embodiment, the first format conversion unit 602 is further configured to, in response to the first image data being in the first format, convert the first format into the Webp format using a cwebp tool to generate the second image data.
[0086] In some optional implementations of this embodiment, in response to the first format being a PNG format, the device 600 also includes: a second file generation unit, configured to compress the first image data using a Pngquant tool in response to the cwebp tool failing to successfully convert the first format into the Webp format, and generate an APK file using the compilation result of the compressed first image data.
[0087] In some optional implementations of this embodiment, the device 600 also includes: a conversion request detection unit, configured to detect whether a Webp format conversion request for the first image data in the second format is received within a preset time length in response to the format of the first image data being a second format different from the first format, wherein the second format includes a GIF format; a third file generation unit, configured to compress the first image data using a Gifsicle tool in response to not receiving a Webp format conversion request within the preset time length, and generate an APK file using the compilation result of the compressed first image data.
[0088] In some optional implementations of this embodiment, the device 600 also includes: a second format conversion unit, configured to convert the second format into the Webp format in response to receiving a Webp format conversion request within a preset time length, and generate third image data; a fourth file generation unit, configured to compress the third image data and generate an APK file using the compilation result of the compressed third image data.
[0089] In some optional implementations of this embodiment, the device 600 also includes: a parameter configuration unit, configured to adjust the usage parameters of the native Gradle plug-in using the configuration file in response to receiving a configuration file for the native Gradle plug-in, wherein the configuration file indicates at least one of the following: a first format, an enabling condition for converting the first format into a Webp format, and an image data compression parameter.
[0090] In some optional implementations of the present embodiment, the image data acquisition unit 601 includes: an interface version parsing subunit, configured to, in response to receiving a data incoming request for the first image data from the target device, parse the target version of the Gradle plug-in requested to be used in the data incoming request; a data communication subunit, configured to configure a virtual interface corresponding to the target version for the target device, so as to communicate with the target device using the virtual interface to acquire the first image data.
[0091] In some optional implementations of the present embodiment, the first format conversion unit 602 includes: a data size comparison subunit, configured to detect whether the data size of the first image data exceeds a preset data volume threshold in response to the first image data being in the first format; a format conversion subunit, configured to convert the first format into the Webp format to generate second image data in response to the data size of the first image data exceeding the preset data volume threshold.
[0092] This embodiment exists as an apparatus embodiment corresponding to the above-mentioned method embodiment. The apparatus for generating an APK file provided by this embodiment can reduce the size of the generated APK file and save storage space by formatting images of specific data types while being compatible with the usage requirements of different Gradle plug-in versions and improving data acquisition capabilities.
[0093] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0094] Figure 7 A schematic block diagram of an example electronic device 700 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0095] like Figure 7As shown, the device 700 includes a computing unit 701, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 702 or a computer program loaded from a storage unit 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the device 700 can also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0096] A number of components in the device 700 are connected to the I / O interface 705, including: an input unit 706, such as a keyboard, a mouse, etc.; an output unit 707, such as various types of displays, speakers, etc.; a storage unit 708, such as a disk, an optical disk, etc.; and a communication unit 709, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 709 allows the device 700 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0097] The computing unit 701 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 701 performs the various methods and processes described above, such as a method for generating an APK file. For example, in some embodiments, the method for generating an APK file may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 708. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 700 via the ROM 702 and / or the communication unit 709. When the computer program is loaded into the RAM 703 and executed by the computing unit 701, one or more steps of the method for generating an APK file described above may be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to execute the method for generating an APK file in any other appropriate manner (e.g., by means of firmware).
[0098] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0099] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0100] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0101] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0102] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0103] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and virtual private servers (VPS) services. The server can also be divided into a server of a distributed system, or a server combined with a blockchain.
[0104] According to the technical solution of the embodiment of the present disclosure, it is possible to reduce the size of the generated APK file and save storage space by converting the format of images of specific data types while being compatible with the usage requirements of different Gradle plug-in versions and improving data acquisition capabilities.
[0105] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions provided by this disclosure can be achieved, and this document does not limit this.
[0106] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A method for generating an APK file, comprising: Acquiring first image data for generating an APK file by using a compatible interface, comprising: in response to receiving a data incoming request for the first image data from a target device, parsing a target version of a Gradle plug-in requested to be used in the data incoming request; configuring a virtual interface corresponding to the target version for the target device, so as to communicate with the target device by using the virtual interface to acquire the first image data, wherein the compatible interface is used to provide virtual interfaces of different versions of a native Gradle plug-in; In response to the first image data being in a first format, converting the first format into a Webp format to generate second image data, wherein the first format includes: a PNG format and / or a JPG format; The second image data is compressed, and the APK file is generated using a compilation result of the compressed second image data.
2. The method according to claim 1, wherein: The converting the first format into the Webp format to generate the second image data includes: The first format is converted into Webp format using a cwebp tool to generate second image data.
3. The method according to claim 2, in response to the first format being a PNG format, further comprising: In response to the cwebp tool failing to successfully convert the first format into the Webp format, the first image data is compressed using a Pngquant tool, and the APK file is generated using a compilation result of the compressed first image data.
4. The method according to any one of claims 1 to 3, further comprising: In response to the format of the first image data being a second format different from the first format, detecting whether a Webp format conversion request for the first image data in the second format is received within a preset time period, wherein the second format includes a GIF format; In response to not receiving the Webp format conversion request within the preset time period, compressing the first image data using a Gifsicle tool, and generating the APK file using a compilation result of the compressed first image data.
5. The method according to claim 4, further comprising: In response to receiving the Webp format conversion request within the preset time period, converting the second format into the Webp format to generate third image data; The third image data is compressed, and the APK file is generated using a compilation result of the compressed third image data.
6. The method according to claim 1, further comprising: In response to receiving a configuration file for the native Gradle plug-in, the usage parameters of the native Gradle plug-in are adjusted using the configuration file, wherein the configuration file indicates at least one of the following: the first format, the enabling conditions for converting the first format into the Webp format, and the image data compression parameters.
7. The method according to claim 1, wherein: In response to the first image data being in a first format, converting the first format into a Webp format to generate second image data includes: In response to the first image data being in a first format, detecting whether a data size of the first image data exceeds a preset data amount threshold; In response to the data size of the first image data exceeding the preset data amount threshold, the first format is converted into a Webp format to generate second image data.
8. A device for generating an APK file, comprising: The image data acquisition unit is configured to acquire first image data for generating an APK file by using a compatible interface, and includes: an interface version parsing subunit, configured to, in response to receiving a data incoming request for the first image data from a target device, parse the target version of the Gradle plug-in requested to be used in the data incoming request; a data communication subunit, configured to configure a virtual interface corresponding to the target version for the target device, so as to communicate with the target device by using the virtual interface to acquire the first image data, wherein the compatible interface is used to provide virtual interfaces of different versions of the native Gradle plug-in; A first format conversion unit is configured to, in response to the first image data being in a first format, convert the first format into a Webp format to generate second image data, wherein the first format includes: a PNG format and / or a JPG format; The first file generating unit is configured to compress the second image data and generate the APK file using the compilation result of the compressed second image data.
9. The device according to claim 8, wherein: The first format conversion unit is further configured to, in response to the first image data being in the first format, convert the first format into the Webp format using a cwebp tool to generate second image data.
10. The apparatus according to claim 9, in response to the first format being a PNG format, further comprising: The second file generating unit is configured to compress the first image data using the Pngquant tool in response to the cwebp tool failing to successfully convert the first format into the Webp format, and generate the APK file using the compilation result of the compressed first image data.
11. The device according to any one of claims 8 to 10, further comprising: a conversion request detection unit, configured to detect whether a Webp format conversion request for the first image data in a second format different from the first format is received within a preset time period in response to the format of the first image data being a second format different from the first format, wherein the second format includes a GIF format; The third file generation unit is configured to compress the first image data using a Gifsicle tool in response to not receiving the Webp format conversion request within the preset time period, and generate the APK file using the compilation result of the compressed first image data.
12. The apparatus according to claim 11, further comprising: A second format conversion unit is configured to, in response to receiving the Webp format conversion request within the preset time period, convert the second format into the Webp format to generate third image data; The fourth file generating unit is configured to compress the third image data and generate the APK file using the compilation result of the compressed third image data.
13. The apparatus according to claim 8, further comprising: A parameter configuration unit is configured to adjust the usage parameters of the native Gradle plug-in using a configuration file for the native Gradle plug-in in response to receiving the configuration file, wherein the configuration file indicates at least one of the following: the first format, the enabling conditions for converting the first format into the Webp format, and the image data compression parameters.
14. The device according to claim 8, wherein: The first format conversion unit includes: a data size comparison subunit, configured to detect whether the data size of the first image data exceeds a preset data amount threshold in response to the first image data being in a first format; The format conversion subunit is configured to convert the first format into a Webp format to generate second image data in response to the data size of the first image data exceeding the preset data amount threshold.
15. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method for generating an APK file according to any one of claims 1 to 7.
16. A non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause the computer to execute the method for generating an APK file according to any one of claims 1 to 7.
17. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements the method for generating an APK file according to any one of claims 1 to 7.
Citation Information
Patent Citations
Method and system for automatically packaging APK (Android Package) installation package on server
CN107301074A
Software installation package obtaining method and device and electronic equipment
CN109710265A