CN106775916B - Method and device for reducing application installation packages and electronic equipment - Google Patents

Method and device for reducing application installation packages and electronic equipment Download PDF

Info

Publication number
CN106775916B
CN106775916B CN201710087209.XA CN201710087209A CN106775916B CN 106775916 B CN106775916 B CN 106775916B CN 201710087209 A CN201710087209 A CN 201710087209A CN 106775916 B CN106775916 B CN 106775916B
Authority
CN
China
Prior art keywords
file
binary code
application
compiled
layout
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710087209.XA
Other languages
Chinese (zh)
Other versions
CN106775916A (en
Inventor
田昊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kingsoft Internet Security Software Co Ltd
Original Assignee
Beijing Kingsoft Internet Security Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kingsoft Internet Security Software Co Ltd filed Critical Beijing Kingsoft Internet Security Software Co Ltd
Priority to CN201710087209.XA priority Critical patent/CN106775916B/en
Publication of CN106775916A publication Critical patent/CN106775916A/en
Application granted granted Critical
Publication of CN106775916B publication Critical patent/CN106775916B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/443Optimisation
    • G06F8/4434Reducing the memory space required by the program code
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/52Binary to binary

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention provides a method and a device for reducing an application installation package and electronic equipment, wherein the method comprises the following steps: packaging and compiling the project files corresponding to the application to generate compiled files corresponding to the application; storing a first binary code corresponding to a layout file in the compiled file according to a preset storage path; replacing a first binary code corresponding to the layout file by using a binary code of the storage path in the compiled file; acquiring a first R file included in a compiled file; and creating a second R file in the compiled file according to the first R file so as to generate an installation package file corresponding to the application. The layout files in the installation package are taken out of the installation package and are stored independently, the R files automatically generated by the system are replaced by the newly created R files, the size of the application installation package is reduced, the space occupied by the application installation package and the flow consumed in the downloading process are saved, the downloading speed and the application utilization rate of the application installation package are improved, and the user experience is improved.

Description

Method and device for reducing application installation packages and electronic equipment
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for reducing an application installation package and electronic equipment.
Background
With the development of network and computer technologies, a wide variety of applications are widely used in various mobile terminals, and gradually become an indispensable part of people's daily life.
The application installation package is used as an application carrier, wherein all files of the application are installed, and the operation of the installation package can release all files of the application to a hard disk to complete the work of modifying a registry, modifying system settings, creating shortcuts and the like. If the application installation package is too large, the flow consumed in the downloading process is high, the downloading process is slow, the efficiency is low, the user is unwilling to download, and the application utilization rate is reduced. Therefore, how to reduce the size of the application installation package becomes a vital task in application development.
Disclosure of Invention
The present invention is directed to solving, at least to some extent, one of the technical problems in the related art.
Therefore, a first object of the present invention is to provide a method for reducing an application installation package, which realizes that a layout file in the installation package is taken out from the installation package and is independently stored, and a newly created R file is used to replace an R file automatically generated by a system after a project file is packaged and compiled, so that the size of the application installation package is reduced, the space occupied by the application installation package and the flow consumed in the downloading process are saved, the downloading speed of the application installation package and the utilization rate of the application are improved, and the user experience is improved.
A second object of the present invention is to provide an apparatus for reducing application installation packages.
A third object of the invention is to propose an electronic device.
A fourth object of the invention is to propose a storage medium.
A fifth object of the invention is to propose an application.
In order to achieve the above object, an embodiment of a first aspect of the present invention provides a method for reducing an application installation package, including: packaging and compiling the project files corresponding to the application to generate compiled files corresponding to the application; storing a first binary code corresponding to a layout file in the compiled file according to a preset storage path; replacing a first binary code corresponding to the layout file with a binary code of the storage path in the compiled file; acquiring a first R file included in the compiled file; and creating a second R file in the compiled file according to the first R file so as to generate an installation package file corresponding to the application, wherein the name of the second R file is different from that of the first R file, and the content in the second R file is the same as that in the first R file.
In a possible implementation form of the first aspect, before replacing the first binary code corresponding to the layout file with the binary code of the storage path, the method further includes:
determining a path head by reflection;
the replacing the first binary code corresponding to the layout file by the binary code of the storage path includes:
and replacing the first binary code corresponding to the layout file by using the binary code of the path head and the binary code of the storage path.
In another possible implementation form of the first aspect, the replacing the first binary code corresponding to the layout file with the binary code of the path header and the binary code of the storage path includes:
generating a text file according to the path head and the storage path;
and replacing the first binary code corresponding to the layout file by the binary code of the text file.
In another possible implementation form of the first aspect, after the generating the installation package file corresponding to the application, the method further includes:
receiving a layout file acquisition request sent by a terminal, wherein the acquisition request comprises a second R file and a storage path;
acquiring a second binary code of the layout file corresponding to the storage path and the second R file;
and sending the second binary code to the terminal.
In another possible implementation form of the first aspect, the creating a second R file in the compiled file according to the first R file includes:
creating a class file in the compiled file;
and copying the content in the first R file into the class file to generate a second R file.
According to the method for reducing the application installation package, provided by the embodiment of the invention, firstly, the project files corresponding to the application are packaged and compiled to generate the compiled files corresponding to the application; then storing the first binary code corresponding to the layout file in the compiled file according to a preset storage path; replacing the first binary codes corresponding to the layout file by the binary codes of the storage paths in the compiled file; then acquiring a first R file included in the compiled file; and finally, creating a second R file in the compiled file according to the first R file so as to generate an installation package file corresponding to the application. Therefore, the layout files in the installation package are taken out of the installation package and are independently stored, the newly created R files are used for replacing the R files automatically generated by the system after the project files are packed and compiled, the size of the application installation package is reduced, the space occupied by the application installation package and the flow consumed in the downloading process are saved, the downloading speed and the application utilization rate of the application installation package are improved, and the user experience is improved.
In order to achieve the above object, a second embodiment of the present invention provides an apparatus for reducing an application installation package, including: the first processing module is used for packaging and compiling the project files corresponding to the application to generate compiled files corresponding to the application; the storage module is used for storing the first binary codes corresponding to the layout files in the compiled files according to a preset storage path; the second processing module is used for replacing the first binary code corresponding to the layout file with the binary code of the storage path in the compiled file; a first obtaining module, configured to obtain a first R file included in the compiled file; and a third processing module, configured to create a second R file in the compiled file according to the first R file, so as to generate an installation package file corresponding to the application, where a name of the second R file is different from a name of the first R file, and a content in the second R file is the same as a content in the first R file.
In a possible implementation form of the second aspect, the apparatus for reducing an application installation package further includes:
a determination module for determining a path header by reflection;
the second processing module is specifically configured to:
and replacing the first binary code corresponding to the layout file by using the binary code of the path head and the binary code of the storage path.
In another possible implementation form of the second aspect, the second processing module includes:
the first processing unit is used for generating a text file according to the path header and the storage path;
and the second processing unit is used for replacing the first binary code corresponding to the layout file by the binary code of the text file.
In another possible implementation form of the second aspect, the apparatus for reducing an application installation package further includes:
the receiving module is used for receiving a layout file acquisition request sent by a terminal, wherein the acquisition request comprises a second R file and a storage path;
a second obtaining module, configured to obtain a second binary code of the layout file corresponding to the storage path and the second R file;
and the sending module is used for sending the second binary code to the terminal.
In another possible implementation form of the second aspect, the third processing module includes:
a third processing unit, configured to create a class file in the compiled file;
and the fourth processing unit is used for copying the content in the first R file into the class file to generate a second R file.
According to the device for reducing the application installation package, provided by the embodiment of the invention, the project files corresponding to the application are packed and compiled to generate the compiled files corresponding to the application; then storing the first binary code corresponding to the layout file in the compiled file according to a preset storage path; replacing the first binary codes corresponding to the layout file by the binary codes of the storage paths in the compiled file; then acquiring a first R file included in the compiled file; and finally, creating a second R file in the compiled file according to the first R file so as to generate an installation package file corresponding to the application. Therefore, the layout files in the installation package are taken out of the installation package and are independently stored, the newly created R files are used for replacing the R files automatically generated by the system after the project files are packed and compiled, the size of the application installation package is reduced, the space occupied by the application installation package and the flow consumed in the downloading process are saved, the downloading speed and the application utilization rate of the application installation package are improved, and the user experience is improved.
To achieve the above object, a third aspect of the present invention provides an electronic device, including: a processor, a memory, and a communication component;
the memory is used for storing executable program codes;
the communication component is used for communicating with other electronic equipment to acquire project files corresponding to the applications;
the processor executes a program corresponding to the executable program code by reading the executable program code stored in the memory, for performing the steps of:
packaging and compiling the project files corresponding to the application to generate compiled files corresponding to the application;
storing a first binary code corresponding to a layout file in the compiled file according to a preset storage path;
replacing a first binary code corresponding to the layout file with a binary code of the storage path in the compiled file;
acquiring a first R file included in the compiled file;
and creating a second R file in the compiled file according to the first R file so as to generate an installation package file corresponding to the application, wherein the name of the second R file is different from that of the first R file, and the content in the second R file is the same as that in the first R file.
According to the electronic equipment provided by the embodiment of the application, firstly, the project files corresponding to the application are packaged and compiled to generate the compiled files corresponding to the application; then storing the first binary code corresponding to the layout file in the compiled file according to a preset storage path; replacing the first binary codes corresponding to the layout file by the binary codes of the storage paths in the compiled file; then acquiring a first R file included in the compiled file; and finally, creating a second R file in the compiled file according to the first R file so as to generate an installation package file corresponding to the application. Therefore, the layout files in the installation package are taken out of the installation package and are independently stored, the newly created R files are used for replacing the R files automatically generated by the system after the project files are packed and compiled, the size of the application installation package is reduced, the space occupied by the application installation package and the flow consumed in the downloading process are saved, the downloading speed and the application utilization rate of the application installation package are improved, and the user experience is improved.
To achieve the above object, a fourth aspect of the present invention provides a storage medium, where the storage medium is used to store an application program, and the application program is used to execute, at runtime, the method for reducing an application installation package according to the first aspect of the present invention.
The storage medium provided by the embodiment of the invention firstly packages and compiles the project files corresponding to the application to generate compiled files corresponding to the application; then storing the first binary code corresponding to the layout file in the compiled file according to a preset storage path; replacing the first binary codes corresponding to the layout file by the binary codes of the storage paths in the compiled file; then acquiring a first R file included in the compiled file; and finally, creating a second R file in the compiled file according to the first R file so as to generate an installation package file corresponding to the application. Therefore, the layout files in the installation package are taken out of the installation package and are independently stored, the newly created R files are used for replacing the R files automatically generated by the system after the project files are packed and compiled, the size of the application installation package is reduced, the space occupied by the application installation package and the flow consumed in the downloading process are saved, the downloading speed and the application utilization rate of the application installation package are improved, and the user experience is improved.
To achieve the above object, a fifth embodiment of the present invention provides an application program, where the application program is configured to execute the method for reducing an application installation package according to the first embodiment of the present invention at runtime.
According to the application program provided by the embodiment of the invention, firstly, the project files corresponding to the application are packaged and compiled to generate the compiled files corresponding to the application; then storing the first binary code corresponding to the layout file in the compiled file according to a preset storage path; replacing the first binary codes corresponding to the layout file by the binary codes of the storage paths in the compiled file; then acquiring a first R file included in the compiled file; and finally, creating a second R file in the compiled file according to the first R file so as to generate an installation package file corresponding to the application. Therefore, the layout files in the installation package are taken out of the installation package and are independently stored, the newly created R files are used for replacing the R files automatically generated by the system after the project files are packed and compiled, the size of the application installation package is reduced, the space occupied by the application installation package and the flow consumed in the downloading process are saved, the downloading speed and the application utilization rate of the application installation package are improved, and the user experience is improved.
Drawings
The foregoing and/or additional aspects and advantages of the present invention will become apparent and readily appreciated from the following description of the embodiments, taken in conjunction with the accompanying drawings of which:
FIG. 1 is a flow diagram of a method of reducing application installation packages, in accordance with one embodiment of the present invention;
FIG. 2 is a flow diagram of a method of reducing application installation packages according to another embodiment of the invention;
FIG. 3 is a block diagram of an apparatus for reducing application installation packages, in accordance with one embodiment of the present invention;
FIG. 4 is a block diagram of an apparatus for reducing application installation packages in accordance with another embodiment of the present invention;
fig. 5 is a block diagram of an electronic device of an embodiment of the invention.
Detailed Description
Reference will now be made in detail to embodiments of the present invention, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below with reference to the accompanying drawings are illustrative only for the purpose of explaining the present invention, and are not to be construed as limiting the present invention. On the contrary, the embodiments of the invention include all changes, modifications and equivalents coming within the spirit and terms of the claims appended hereto.
The embodiments of the invention mainly aim at the problems that when an application installation package is too large, the flow consumed in the downloading process is high, the downloading process is slow, the efficiency is low, and a user is unwilling to download, and the application utilization rate is reduced.
The following describes a method, an apparatus and an electronic device for reducing an application installation package according to an embodiment of the present invention with reference to the drawings.
FIG. 1 is a flow diagram of a method of reducing application installation packages, in accordance with one embodiment of the present invention.
As shown in fig. 1, the method for reducing the application installation package includes:
step 101, packaging and compiling the project files corresponding to the application to generate compiled files corresponding to the application.
Specifically, the method for reducing the application installation package provided by the embodiment of the present invention may be executed by the apparatus for reducing the application installation package provided by the embodiment of the present invention.
The project file corresponding to the application is a file formed in the application Development process, and specifically may be a file formed by developing the application in an Integrated Development Environment (IDE).
Specifically, since the project file corresponding to the application is written by using a high-level language program and is not a machine language that can be recognized by a computer or other electronic devices, in this embodiment, after the project file corresponding to the application is obtained, the project file is first packaged and compiled to obtain a compiled file in a binary code form corresponding to the project file, so that when the application is installed, the installation device can install the application according to the binary code.
And 102, storing the first binary code corresponding to the layout file in the compiled file according to a preset storage path.
The layout file may include a View (View) file such as a menu and a picture.
The storage path can be set as required. Specifically, the location may be a certain location in the remote server, or may be a certain location in a Secure Digital Memory Card (SD Card for short) built in the network server, which is not limited herein.
In a specific implementation, a storage path may be preset, and since the item file corresponding to the application is already packaged and compiled in step 101, a compiled file in a binary code form is generated, and then after the storage path is set, the first binary code corresponding to each layout file in the compiled file may be stored in the preset storage path through commands such as adb.
And 103, replacing the first binary code corresponding to the layout file with the binary code of the storage path in the compiled file.
Specifically, after the first binary codes corresponding to each layout file in the compiled file are stored in the preset storage path, the binary codes of the storage path can be used for replacing and applying the first binary codes corresponding to each layout file in the corresponding compiled file.
In specific implementation, as for a compiled file, the first binary code belongs to a hidden file, and therefore when being loaded, the first binary code can be loaded into the stored first binary code only by calling the addasspath method in the AssetManager through reflection, and as the addasspath is a hidden api, we cannot directly call the addasspath, so that only through reflection is possible. In this embodiment of the present application, before replacing the first binary code corresponding to the layout file with the binary code of the storage path, the method may further include: the path head is determined by reflection.
Correspondingly, replacing the first binary code corresponding to the layout file with the binary code of the storage path may specifically include:
and replacing the first binary code corresponding to the layout file by the binary code of the path head and the binary code of the storage path.
It is understood that in Java, attributes, methods, construction methods, and the like of Java objects may be accessed through a reflection mechanism, and in this embodiment, a path header of the storage path may be obtained through the reflection mechanism. After the path header is obtained, the path header can be added to the storage path to replace the first binary code corresponding to the layout file in the compilation file by using the binary code of the path header and the binary code of the storage path.
In specific implementation, in order to reduce resources occupied by the binary code of the path header and the binary code of the storage path, a text file (cookie) can be generated according to the path header and the storage path, and then the binary code of the text file is used for replacing the first binary code corresponding to the layout file.
And 104, acquiring a first R file included in the compiled file.
And 105, creating a second R file in the compiled file according to the first R file to generate an installation package file corresponding to the application.
And the name of the second R file is different from that of the first R file, and the content in the second R file is the same as that in the first R file.
The R file is a file automatically generated by the system in the process of packaging and compiling the project file, and includes identifiers (IDs for short) of all the layout files, and the application can acquire the corresponding resources according to the IDs in the first R file in the installation process.
In a specific implementation, a class file with a name different from that of the first R file may be created in the compilation file, then the content in the first R file may be copied and pasted into the newly created class file to obtain a second R file, so as to generate an installation package file corresponding to the application, that is, step 105 may specifically include:
creating a class file in the compiled file;
and copying the content in the first R file into the class file to generate a second R file.
Specifically, the layout file in the compiled file is already stored in the preset storage path, so that the first R file cannot be executed, and the corresponding layout file is obtained.
According to the method for reducing the application installation package, provided by the embodiment of the invention, firstly, the project files corresponding to the application are packaged and compiled to generate the compiled files corresponding to the application; then storing the first binary code corresponding to the layout file in the compiled file according to a preset storage path; replacing the first binary codes corresponding to the layout file by the binary codes of the storage paths in the compiled file; then acquiring a first R file included in the compiled file; and finally, creating a second R file in the compiled file according to the first R file so as to generate an installation package file corresponding to the application. Therefore, the layout files in the installation package are taken out of the installation package and are independently stored, the newly created R files are used for replacing the R files automatically generated by the system after the project files are packed and compiled, the size of the application installation package is reduced, the space occupied by the application installation package and the flow consumed in the downloading process are saved, the downloading speed and the application utilization rate of the application installation package are improved, and the user experience is improved.
According to the analysis, the layout files in the installation package can be taken out of the installation package and stored independently, and the newly created R files are used for replacing the R files automatically generated by the system after the project files are packed and compiled, so that the installation package files corresponding to the application are generated. In practical application, after downloading the installation package corresponding to the application, the user needs to obtain the replaced layout file to complete installation of the application, and the method for reducing the application installation package provided by the present application is further described below with reference to fig. 2.
FIG. 2 is a flow diagram of a method of reducing application installation packages in accordance with another embodiment of the present invention.
As shown in fig. 2, the method for reducing application installation packages includes:
step 201, packaging and compiling the project files corresponding to the application to generate a compiled file corresponding to the application.
Step 202, storing the first binary code corresponding to the layout file in the compiled file according to a preset storage path.
Step 203, determine the path header by reflection.
And 204, replacing the first binary code corresponding to the layout file with the binary code of the path header and the binary code of the storage path in the compiled file.
Step 205, obtaining a first R file included in the compiled file.
Step 206, create a class file in the compiled file.
And step 207, copying the content in the first R file into the class file, and generating a second R file so as to generate an installation package file corresponding to the application.
The detailed implementation process and principle of steps 201 to 207 may refer to the detailed description of steps 101 to 104 in the above embodiments, and are not described herein again.
And 208, receiving a layout file acquisition request sent by the terminal, wherein the acquisition request comprises a second R file and a storage path.
The second R file and the storage path included in the acquisition request may be in a binary code form or other forms, which is not limited herein.
Step 209, obtain the second binary code of the layout file corresponding to the storage path and the second R file.
It can be understood that, according to the installation package file corresponding to the application generated in the above step, the binary code and the second R file of the storage path are respectively used to replace the first binary code corresponding to the layout file and the first R file containing the resource ID automatically generated by the system, and when the application is installed by using the application installation package, a file that may need to be replaced may be needed.
The obtaining request comprises a storage path of a layout file stored in a preset storage position and required by the installation application and a second R file containing a resource ID.
In specific implementation, after the storage path and the second R file are obtained, each binary code corresponding to each layout file in the storage path can be obtained by accessing the storage path, and the second binary code of the layout file corresponding to the resource ID is obtained by the resource ID in the second R file.
And step 210, sending the second binary code to the terminal.
Specifically, after the second binary code of the layout file corresponding to the storage path and the second R file is obtained, the second binary code is sent to the terminal, so that the terminal operates the second binary code to obtain the corresponding layout file, thereby completing application installation.
For example, assuming that the binary code of the cookie generated by the storage path is used to replace the first binary code corresponding to each layout file to generate the installation package file corresponding to the application, when the application is installed by using the application installation package, each binary code stored in the storage path can be parsed by using openXmlResourceParser of the XML parser of Android to obtain the corresponding layout file according to the binary code of the cookie, and then the corresponding sub-layout file can be obtained by using the findViewByid method of the second R file, so that the application is installed by using each layout file.
According to the method for reducing the application installation package, provided by the embodiment of the invention, the layout file in the installation package is taken out from the installation package and is independently stored, the newly created R file is used for replacing the R file automatically generated by the system after the project file is packaged and compiled, after the installation package file corresponding to the application is generated, if a layout file acquisition request sent by the terminal is received, the second binary code of the layout file corresponding to the storage path and the second R file is acquired, and the second binary code is sent to the terminal. Therefore, the layout files in the installation package are taken out of the installation package and are independently stored, the newly created R files are used for replacing the R files which are automatically generated by the system after the project files are packaged and compiled, and the layout files are obtained by using the storage path and the newly created R files after the layout file obtaining request sent by the terminal is received, so that the size of the application installation package is reduced, the space occupied by the application installation package and the flow consumed in the downloading process are saved, the downloading speed of the application installation package and the utilization rate of the application are improved, and the user experience is improved.
FIG. 3 is a block diagram of an apparatus for reducing application installation packages, in accordance with one embodiment of the present invention.
As shown in fig. 3, the apparatus for reducing application installation package includes:
the first processing module 301 is configured to package and compile a project file corresponding to an application, and generate a compiled file corresponding to the application;
a storage module 302, configured to store a first binary code corresponding to a layout file in the compiled file according to a preset storage path;
a second processing module 303, configured to replace, in the compiled file, the first binary code corresponding to the layout file with the binary code of the storage path;
a first obtaining module 304, configured to obtain a first R file included in the compiled file;
a third processing module 305, configured to create a second R file in the compiled file according to the first R file, so as to generate an installation package file corresponding to the application, where a name of the second R file is different from a name of the first R file, and a content in the second R file is the same as a content in the first R file.
In a possible implementation form of this embodiment, the third processing module 305 includes:
a third processing unit, configured to create a class file in the compiled file;
and the fourth processing unit is used for copying the content in the first R file into the class file to generate a second R file.
It should be noted that the above description of the embodiment of the method for reducing an application installation package shown in fig. 1 is also applicable to the apparatus for reducing an application installation package provided in this embodiment, and is not repeated here.
The embodiment provides a device for reducing an application installation package, which is characterized in that firstly, a project file corresponding to an application is packaged and compiled to generate a compiled file corresponding to the application; then storing the first binary code corresponding to the layout file in the compiled file according to a preset storage path; replacing the first binary codes corresponding to the layout file by the binary codes of the storage paths in the compiled file; then acquiring a first R file included in the compiled file; and finally, creating a second R file in the compiled file according to the first R file so as to generate an installation package file corresponding to the application. Therefore, the layout files in the installation package are taken out of the installation package and are independently stored, the newly created R files are used for replacing the R files automatically generated by the system after the project files are packed and compiled, the size of the application installation package is reduced, the space occupied by the application installation package and the flow consumed in the downloading process are saved, the downloading speed and the application utilization rate of the application installation package are improved, and the user experience is improved.
Fig. 4 is a block diagram of an apparatus for reducing an application installation package according to another embodiment of the present invention.
As shown in fig. 4, on the basis of fig. 3, the apparatus for reducing an application installation package further includes:
a determination module 306 for determining a path head by reflection;
correspondingly, the second processing module 303 is specifically configured to:
and replacing the first binary code corresponding to the layout file by using the binary code of the path head and the binary code of the storage path.
Further, the second processing module 303 includes:
the first processing unit is used for generating a text file according to the path header and the storage path;
and the second processing unit is used for replacing the first binary code corresponding to the layout file by the binary code of the text file.
In a possible implementation form of this embodiment, the apparatus for reducing an application installation package further includes:
a receiving module 307, configured to receive a layout file acquisition request sent by a terminal, where the acquisition request includes a second R file and a storage path;
a second obtaining module 308, configured to obtain a second binary code of the layout file corresponding to the storage path and the second R file;
a sending module 309, configured to send the second binary code to the terminal.
It should be noted that the above description of the method for reducing an application installation package is also applicable to the apparatus for reducing an application installation package provided in this embodiment, and is not repeated here.
According to the device for reducing the application installation package, provided by the embodiment of the invention, the layout file in the installation package is taken out of the installation package and is independently stored, the newly created R file is used for replacing the R file automatically generated by the system after the project file is packaged and compiled, after the installation package file corresponding to the application is generated, if a layout file acquisition request sent by the terminal is received, the second binary code of the layout file corresponding to the storage path and the second R file is acquired, and the second binary code is sent to the terminal. Therefore, the layout files in the installation package are taken out of the installation package and are independently stored, the newly created R files are used for replacing the R files which are automatically generated by the system after the project files are packaged and compiled, and the layout files are obtained by using the storage path and the newly created R files after the layout file obtaining request sent by the terminal is received, so that the size of the application installation package is reduced, the space occupied by the application installation package and the flow consumed in the downloading process are saved, the downloading speed of the application installation package and the utilization rate of the application are improved, and the user experience is improved.
Fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present application. The electronic device may be of various types, such as a computer, a server, and the like, which is not limited in this embodiment.
As shown in fig. 5, the electronic device 50 includes: a processor 501, a memory 502, and a communication component 503;
the memory 502 is used for storing executable program code;
the communication component 503 is configured to communicate with other electronic devices to obtain a project file corresponding to an application;
the processor 501 runs a program corresponding to the executable program code by reading the executable program code stored in the memory 502, for performing the steps of:
packaging and compiling the project files corresponding to the application to generate compiled files corresponding to the application;
storing a first binary code corresponding to a layout file in the compiled file according to a preset storage path;
replacing a first binary code corresponding to the layout file with a binary code of the storage path in the compiled file;
acquiring a first R file included in the compiled file;
and creating a second R file in the compiled file according to the first R file so as to generate an installation package file corresponding to the application, wherein the name of the second R file is different from that of the first R file, and the content in the second R file is the same as that in the first R file.
It should be noted that the foregoing explanation on the embodiment of the method for reducing the application installation package shown in fig. 1 and fig. 2 is also applicable to the electronic device of the embodiment, and the implementation principle is similar, and is not described herein again.
According to the electronic equipment, firstly, the project files corresponding to the application are packaged and compiled, and compiled files corresponding to the application are generated; then storing the first binary code corresponding to the layout file in the compiled file according to a preset storage path; replacing the first binary codes corresponding to the layout file by the binary codes of the storage paths in the compiled file; then acquiring a first R file included in the compiled file; and finally, creating a second R file in the compiled file according to the first R file so as to generate an installation package file corresponding to the application. Therefore, the layout files in the installation package are taken out of the installation package and are independently stored, the newly created R files are used for replacing the R files automatically generated by the system after the project files are packed and compiled, the size of the application installation package is reduced, the space occupied by the application installation package and the flow consumed in the downloading process are saved, the downloading speed and the application utilization rate of the application installation package are improved, and the user experience is improved.
Based on the method for reducing the application installation package provided by the foregoing embodiment, the embodiment of the present application further provides a storage medium, which may be a read-only memory, a magnetic disk, or an optical disk, for example.
The storage medium is used for storing an application program, and the application program is used for executing the method for reducing the application installation package in the embodiment of the invention when running.
Further, an embodiment of the present application also provides an application program, where the application program is configured to execute the method for reducing an application installation package according to the embodiment of the present invention at runtime.
Specifically, the application program in the embodiment of the present application may be implemented by using any language, as long as the method for reducing the application installation package provided in the embodiment of the present application can be implemented.
In the description herein, references to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above are not necessarily intended to refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, various embodiments or examples and features of different embodiments or examples described in this specification can be combined and combined by one skilled in the art without contradiction.
Furthermore, the terms "first", "second" and "first" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. In the description of the present invention, "a plurality" means at least two, e.g., two, three, etc., unless specifically limited otherwise.
Any process or method descriptions in flow charts or otherwise described herein may be understood as representing modules, segments, or portions of code which include one or more executable instructions for implementing specific logical functions or steps of the process, and alternate implementations are included within the scope of the preferred embodiment of the present invention in which functions may be executed out of order from that shown or discussed, including substantially concurrently or in reverse order, depending on the functionality involved, as would be understood by those reasonably skilled in the art of the present invention.
It should be understood that portions of the present invention may be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, the various steps or methods may be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, any one or combination of the following techniques, which are known in the art, may be used: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application specific integrated circuit having an appropriate combinational logic gate circuit, a Programmable Gate Array (PGA), a Field Programmable Gate Array (FPGA), or the like.
It will be understood by those skilled in the art that all or part of the steps carried by the method for implementing the above embodiments may be implemented by hardware related to instructions of a program, which may be stored in a computer readable storage medium, and when the program is executed, the program includes one or a combination of the steps of the method embodiments.
The storage medium mentioned above may be a read-only memory, a magnetic or optical disk, etc. Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention, and that variations, modifications, substitutions and alterations can be made to the above embodiments by those of ordinary skill in the art within the scope of the present invention.

Claims (11)

1. A method of reducing application installation packages, comprising the steps of:
packaging and compiling project files corresponding to the application to generate compiled files corresponding to the application, wherein the project files comprise files formed in the application development process;
storing a first binary code corresponding to a layout file in the compiled file according to a preset storage path, wherein the storage path comprises any storage path in a built-in secure digital card of a remote server or a network server;
replacing a first binary code corresponding to the layout file with a binary code of the storage path in the compiled file;
acquiring a first R file included in the compiled file, wherein the R file comprises a file automatically generated by a system in the process of packaging and compiling the project file;
and creating a second R file in the compiled file according to the first R file so as to generate an installation package file corresponding to the application, wherein the name of the second R file is different from that of the first R file, and the content in the second R file is the same as that in the first R file.
2. The method of claim 1, wherein before replacing the first binary corresponding to the layout file with the binary of the storage path, further comprising:
determining a path head by reflection;
the replacing the first binary code corresponding to the layout file by the binary code of the storage path includes:
and replacing the first binary code corresponding to the layout file by using the binary code of the path head and the binary code of the storage path.
3. The method of claim 2, wherein replacing the corresponding first binary of the layout file with the binary of the path header and the binary of the storage path comprises:
generating a text file according to the path head and the storage path;
and replacing the first binary code corresponding to the layout file by the binary code of the text file.
4. The method of any of claims 1-3, wherein after generating the installation package file corresponding to the application, further comprising:
receiving a layout file acquisition request sent by a terminal, wherein the acquisition request comprises a second R file and the preset storage path, and the second R file comprises an identifier of the layout file requested by the terminal;
acquiring a second binary code of the layout file corresponding to the preset storage path and the second R file;
and sending the second binary code to the terminal.
5. The method of any of claims 1-3, the creating a second Rfile in the compiled file from the first Rfile, comprising:
creating a class file in the compiled file;
and copying the content in the first R file into the class file to generate a second R file.
6. An apparatus for reducing application installation packages, comprising:
the system comprises a first processing module, a second processing module and a third processing module, wherein the first processing module is used for packaging and compiling project files corresponding to applications and generating compiled files corresponding to the applications, and the project files comprise files formed in the application development process;
the storage module is used for storing the first binary code corresponding to the layout file in the compiled file according to a preset storage path, wherein the storage path comprises any storage path in a built-in secure digital card of a remote server or a network server;
the second processing module is used for replacing the first binary code corresponding to the layout file with the binary code of the storage path in the compiled file;
the first acquisition module is used for acquiring a first R file included in the compiled file, wherein the R file includes a file automatically generated by a system in the process of packaging and compiling the project file;
and a third processing module, configured to create a second R file in the compiled file according to the first R file, so as to generate an installation package file corresponding to the application, where a name of the second R file is different from a name of the first R file, and a content in the second R file is the same as a content in the first R file.
7. The apparatus of claim 6, further comprising:
a determination module for determining a path header by reflection;
the second processing module is specifically configured to:
and replacing the first binary code corresponding to the layout file by using the binary code of the path head and the binary code of the storage path.
8. The apparatus of claim 7, wherein the second processing module comprises:
the first processing unit is used for generating a text file according to the path header and the storage path;
and the second processing unit is used for replacing the first binary code corresponding to the layout file by the binary code of the text file.
9. The apparatus of any of claims 6-8, further comprising:
a receiving module, configured to receive a layout file acquisition request sent by a terminal, where the acquisition request includes a second R file and the preset storage path, where the second R file includes an identifier of the layout file requested by the terminal;
a second obtaining module, configured to obtain a second binary code of the layout file corresponding to the preset storage path and the second R file;
and the sending module is used for sending the second binary code to the terminal.
10. The apparatus of any of claims 6-8, the third processing module, comprising:
a third processing unit, configured to create a class file in the compiled file;
and the fourth processing unit is used for copying the content in the first R file into the class file to generate a second R file.
11. An electronic device, comprising: a processor, a memory, and a communication component;
the memory is used for storing executable program codes;
the communication component is used for communicating with other electronic equipment to acquire project files corresponding to the applications;
the processor executes a program corresponding to the executable program code by reading the executable program code stored in the memory, for performing the steps of:
packaging and compiling project files corresponding to the application to generate compiled files corresponding to the application, wherein the project files comprise files formed in the application development process;
storing a first binary code corresponding to a layout file in the compiled file according to a preset storage path, wherein the storage path comprises any storage path in a built-in secure digital card of a remote server or a network server;
replacing a first binary code corresponding to the layout file with a binary code of the storage path in the compiled file;
acquiring a first R file included in the compiled file, wherein the R file comprises a file automatically generated by a system in the process of packaging and compiling the project file;
and creating a second R file in the compiled file according to the first R file so as to generate an installation package file corresponding to the application, wherein the name of the second R file is different from that of the first R file, and the content in the second R file is the same as that in the first R file.
CN201710087209.XA 2017-02-17 2017-02-17 Method and device for reducing application installation packages and electronic equipment Active CN106775916B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710087209.XA CN106775916B (en) 2017-02-17 2017-02-17 Method and device for reducing application installation packages and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710087209.XA CN106775916B (en) 2017-02-17 2017-02-17 Method and device for reducing application installation packages and electronic equipment

Publications (2)

Publication Number Publication Date
CN106775916A CN106775916A (en) 2017-05-31
CN106775916B true CN106775916B (en) 2020-02-28

Family

ID=58957392

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710087209.XA Active CN106775916B (en) 2017-02-17 2017-02-17 Method and device for reducing application installation packages and electronic equipment

Country Status (1)

Country Link
CN (1) CN106775916B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107391182B (en) * 2017-06-30 2020-08-07 北京金山安全软件有限公司 Generation method, device, server and storage medium of theme installation package
CN110633083B (en) * 2018-06-22 2024-06-18 北京京东尚科信息技术有限公司 Code file processing method, device, electronic equipment and computer readable medium
CN111124470A (en) * 2019-12-17 2020-05-08 口碑(上海)信息技术有限公司 Automatic optimization method and device for program package based on cloud platform

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105204823A (en) * 2014-05-29 2015-12-30 腾讯科技(深圳)有限公司 Method and device for generating application installation package

Family Cites Families (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120284696A1 (en) * 2009-12-21 2012-11-08 Nokia Corporation Method, Apparatuses and a System for Compilation
CN104156225B (en) * 2013-05-14 2018-07-06 腾讯科技(深圳)有限公司 A kind of method for down loading of installation kit, system and server
CN103279453B (en) * 2013-05-31 2016-08-17 小米科技有限责任公司 Document handling method and device
CN103870303A (en) * 2014-02-10 2014-06-18 广东欧珀移动通信有限公司 Method and device for reducing size of software installation package
CN104133695A (en) * 2014-07-15 2014-11-05 珠海金山网络游戏科技有限公司 Manufacture and application method of software client side
CN104182260A (en) * 2014-08-27 2014-12-03 厦门美图之家科技有限公司 Method for providing installation packages of application programs
CN104360884A (en) * 2014-11-18 2015-02-18 久邦计算机技术(广州)有限公司 Plug-in resource packet loading method based on Android system
CN104462393B (en) * 2014-12-10 2017-11-14 北京国双科技有限公司 Determination method and device for the file path of compiling
CN105988834B (en) * 2015-02-12 2019-11-19 腾讯科技(深圳)有限公司 A kind of application installation package generates, installation method and device
CN104731625B (en) * 2015-03-27 2019-02-26 北京奇虎科技有限公司 A kind of method, apparatus and mobile terminal loading plug-in unit
CN104714828B (en) * 2015-03-31 2017-06-09 北京奇虎科技有限公司 Using installation, operation method and device
CN104765618B (en) * 2015-05-06 2017-12-08 中孚信息股份有限公司 A kind of making of linux system self-extracting installation kit and decompression installation method
CN104899025A (en) * 2015-05-18 2015-09-09 北京奇虎科技有限公司 Method and device for generating channel package
CN105915623A (en) * 2016-05-20 2016-08-31 努比亚技术有限公司 Device and method of processing application installation package
CN106020725B (en) * 2016-05-20 2019-07-12 努比亚技术有限公司 Application file processing unit and method
CN106157247A (en) * 2016-07-06 2016-11-23 北京元心科技有限公司 A kind of image processing method and system

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105204823A (en) * 2014-05-29 2015-12-30 腾讯科技(深圳)有限公司 Method and device for generating application installation package

Also Published As

Publication number Publication date
CN106775916A (en) 2017-05-31

Similar Documents

Publication Publication Date Title
US11556348B2 (en) Bootstrapping profile-guided compilation and verification
US20110154305A1 (en) System and method for remotely compiling multi-platform native applications for mobile devices
CN106844153B (en) Application program operation monitoring method and device and terminal
CN111740948B (en) Data packet issuing method, dynamic updating method, device, equipment and medium
CN106775781B (en) Method and device for reducing application installation packages and electronic equipment
CN111399840B (en) Module development method and device
CN111176626A (en) Cross-programming-language code calling method and device, medium and equipment
CN106294113B (en) creation method and device based on programmable test service
CN106775916B (en) Method and device for reducing application installation packages and electronic equipment
CN112083968A (en) Plug-in loading method and device in host
CN110659031A (en) Compiling method and device of application program, electronic equipment and storage medium
CN111651219A (en) Method and equipment for managing multi-module project configuration file
CN113312046A (en) Sub-application page processing method and device and computer equipment
CN111506368A (en) Method, device, equipment and storage medium for transferring asynchronous call to synchronous call
CN109343970B (en) Application program-based operation method and device, electronic equipment and computer medium
CN111290740B (en) Application program development method and device, computer equipment and storage medium
CN110941443B (en) Method and device for modifying file name in SDK (software development kit) and electronic equipment
CN114490103A (en) Operating system interface calling method and device and electronic equipment
AU2016378425B2 (en) Application program running method and apparatus
CN109189591B (en) Method and device for calling application component
CN116107623A (en) Software development method and device and electronic equipment
CN106778270B (en) Malicious application detection method and system
CN110661852B (en) Service processing method and device in cloud environment
CN114443316B (en) Object access method and device and electronic equipment
CN117724726B (en) Data processing method and related device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant