CN117311853B - APK file processing method and device, computer equipment and storage medium - Google Patents

APK file processing method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN117311853B
CN117311853B CN202311596772.1A CN202311596772A CN117311853B CN 117311853 B CN117311853 B CN 117311853B CN 202311596772 A CN202311596772 A CN 202311596772A CN 117311853 B CN117311853 B CN 117311853B
Authority
CN
China
Prior art keywords
library
target
directory
compressed
apk file
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
CN202311596772.1A
Other languages
Chinese (zh)
Other versions
CN117311853A (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.)
Shenzhen Yeahka Technology Co ltd
Original Assignee
Shenzhen Yeahka Technology 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 Shenzhen Yeahka Technology Co ltd filed Critical Shenzhen Yeahka Technology Co ltd
Priority to CN202311596772.1A priority Critical patent/CN117311853B/en
Publication of CN117311853A publication Critical patent/CN117311853A/en
Application granted granted Critical
Publication of CN117311853B publication Critical patent/CN117311853B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

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

Abstract

The embodiment of the application discloses a processing method, a processing device, computer equipment and a storage medium of an APK file. The method comprises the following steps: acquiring a target APK file; intercepting a current directory to be loaded of a system loader by a loader interception hook; judging whether a target SOB name corresponding to the SOB name to be loaded exists in the SOB configuration file; if the target so library name exists in the so library configuration file, determining at least one target compressed so library from a plurality of compressed so libraries according to the cpu model corresponding to the target so library name, the corresponding so library dependency relationship and the system cpu model; and decompressing each target compressed so library to the system so library directory to obtain target decompressed so libraries corresponding to each target compressed so library, and loading the target decompressed so libraries under the system so library directory through a system loading program and the current catalog to be loaded. The volume of the APK file can be reduced through the embodiment of the application.

Description

APK file processing method and device, computer equipment and storage medium
Technical Field
The present disclosure relates to the field of data processing technologies, and in particular, to a method and an apparatus for processing an APK file, a computer device, and a storage medium.
Background
With the development of science and technology, mobile phones, computers and various electronic products are popularized, the products of the android system take up the main market, the number of software based on the android platform is increased year by year, the functions of the same software are more and more abundant, and the data volume of the software is also more and more large.
The more mature the android project, the more the Native code contributes, the larger the volume ratio of the so library brought by the Native code, and the larger the volume of the android installation package (AndroidPackage, APK) file.
Disclosure of Invention
The embodiment of the application provides a processing method, a device, computer equipment and a storage medium for an APK file, which can load the APK file on the premise of lower volume of the APK file.
In a first aspect, an embodiment of the present application provides a method for processing an APK file, including:
acquiring a target APK file, wherein the target APK file comprises a loader interception hook and a custom solibrary directory, the custom directory comprises a solibrary configuration file and a plurality of compressed solibraries, the solibrary configuration file comprises configuration information of each compressed solibrary, and the configuration information comprises a solibrary name, a solibrary dependency relationship and a cpu model;
intercepting a current directory to be loaded of a system loader through the loader interception hook, wherein the current directory to be loaded comprises a name of a so library to be loaded;
judging whether a target SOB name corresponding to the SOB name to be loaded exists in the SOB configuration file;
if the target sostore name exists in the sostore configuration file, determining at least one target compressed sostore from a plurality of compressed sostores according to a cpu model corresponding to the target sostore name, a corresponding sostore dependency relationship and a system cpu model;
decompressing each target compressed so library to a system so library directory to obtain target decompressed so libraries corresponding to each target compressed so library, and loading the target decompressed so libraries under the system so library directory through the system loading program and the current directory to be loaded.
In a second aspect, an embodiment of the present application further provides a processing device for an APK file, including: the system comprises a first receiving and transmitting unit, a second receiving and transmitting unit and a third receiving and transmitting unit, wherein the first receiving and transmitting unit is used for acquiring a target APK file, the target APK file comprises a loader interception hook and a custom so library catalog, the custom catalog comprises a so library configuration file and a plurality of compressed so libraries, the so library configuration file comprises configuration information of each compressed so library, and the configuration information comprises a so library name, a so library dependency relationship and a cpu model;
the first processing unit is used for intercepting a current directory to be loaded of a system loader through the loader interception hook, wherein the current directory to be loaded comprises a name of a so library to be loaded; judging whether a target SOB name corresponding to the SOB name to be loaded exists in the SOB configuration file; if the target sostore name exists in the sostore configuration file, determining at least one target compressed sostore from a plurality of compressed sostores according to a cpu model corresponding to the target sostore name, a corresponding sostore dependency relationship and a system cpu model; decompressing each target compressed so library to a system so library directory to obtain target decompressed so libraries corresponding to each target compressed so library, and loading the target decompressed so libraries under the system so library directory through the system loading program and the current directory to be loaded.
In a third aspect, embodiments of the present application further provide a computer device, including a memory and a processor, where the memory stores a computer program, and the processor implements the method when executing the computer program.
In a fourth aspect, embodiments of the present application also provide a computer readable storage medium storing a computer program comprising program instructions which, when executed by a processor, implement the above-described method.
The embodiment of the application provides a processing method, a processing device, computer equipment and a storage medium of an APK file. Wherein the method comprises the following steps: acquiring a target APK file, wherein the target APK file comprises a loader interception hook and a custom solibrary directory, the custom directory comprises a solibrary configuration file and a plurality of compressed solibraries, the solibrary configuration file comprises configuration information of each compressed solibrary, and the configuration information comprises a solibrary name, a solibrary dependency relationship and a cpu model; intercepting a current directory to be loaded of a system loader through the loader interception hook, wherein the current directory to be loaded comprises a name of a so library to be loaded; judging whether a target SOB name corresponding to the SOB name to be loaded exists in the SOB configuration file; if the target sostore name exists in the sostore configuration file, determining at least one target compressed sostore from a plurality of compressed sostores according to a cpu model corresponding to the target sostore name, a corresponding sostore dependency relationship and a system cpu model; decompressing each target compressed so library to a system so library directory to obtain target decompressed so libraries corresponding to each target compressed so library, and loading the target decompressed so libraries under the system so library directory through the system loading program and the current directory to be loaded. In addition, the target APK file in this embodiment further includes a loader interception hook, through which a system loader can be intercepted, and the compressed so library is decompressed first, so that the system loader can load the so library of the target APK file.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present application, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is an application scenario schematic diagram of a processing method of an APK file provided in an embodiment of the present application;
fig. 2 is a flow chart of a processing method of an APK file provided in an embodiment of the present application;
fig. 3 is a schematic diagram of a lib directory in the APK file processing method provided in the embodiment of the present application;
fig. 4 is a flow chart of a processing method of an APK file according to another embodiment of the present application;
FIG. 5 is a schematic block diagram of an APK file processing device according to an embodiment of the present disclosure;
fig. 6 is a schematic block diagram of a computer device provided in an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
It should be understood that the terms "comprises" and "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It is also to be understood that the terminology used in the description of the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in this specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
The embodiment of the application provides a processing method, a processing device, computer equipment and a storage medium of an APK file.
The execution main body of the APK file processing method may be an APK file processing device provided in the embodiment of the present application, or an APK file processing system integrated with the APK file processing device, where the APK file processing device may be implemented in a hardware or software manner, and the APK file processing system includes a terminal and/or a server.
Referring to fig. 1, fig. 1 is an application scenario schematic diagram of a processing method of an APK file according to an embodiment of the present application. In some embodiments, the APK file processing system includes an APK file compression platform 10 and an APK file loading terminal 20, where the APK file compression platform 10 is a platform for a developer to use, and may automatically compress a so library in an APK file, and upload a target APK file obtained after compression to a download platform, so that the APK file loading terminal 20 downloads the target APK file from the download platform, or after the APK file compression platform 10 obtains the target APK file, directly sends the target APK file to the corresponding APK file loading terminal 20, so as to install an application corresponding to the target APK file in the APK file loading terminal 20.
Referring to fig. 2, fig. 2 is a schematic flow chart of a method for processing an APK file according to an embodiment of the present application, where an execution body of the embodiment is an APK file compression platform in an APK file processing system, and in a corresponding embodiment of fig. 2, a description is mainly given of a step of compressing a so library in the method for processing an APK file, where an execution body of the corresponding embodiment of fig. 2 is an APK file compression platform in an APK file processing system, and the method includes steps S110 to S140:
s110, acquiring an initial APK file, wherein the initial APK file comprises a system so library directory, and the system so library directory comprises a plurality of so libraries.
It should be noted that, in this embodiment, the initial APK file is a conventional APK file, and an APK file that is initially compressed is also a compressed file, and what is needed in the present application is to further compress the so library in the APK file that is initially compressed, so as to further reduce the volume of the APK file.
Specifically, in some embodiments, the initial APK file is an APK file obtained after the execution of the packing flow packageRelease task of the APK packing system is completed.
The system so library catalog specifically may be a lib catalog, the catalog includes a plurality of so libraries, specifically, the catalog further includes a plurality of folders, for example, different folders are constructed for different cpu models, as shown in fig. 3, the library catalog includes two word folders named arm64-8va and armeabi-v7a, and the two word folders include a plurality of so libraries, wherein the cpu model corresponding to the so library under the arm64-8va folder is arm64-8va, and the cpu model corresponding to the so library under the armeabi-v7a folder is armeabi-v7a.
In addition, the initial APK file further includes a so library dependency relationship of each so library, where the so library dependency relationship indicates some other so libraries that must be loaded in association with each other when the corresponding so library is loaded.
S120, determining a plurality of to-be-compressed so libraries from the plurality of so libraries according to a preset so library compression rule.
In this embodiment, since there are some so libraries in the APK file that do not need to be compressed, for example, some so libraries related to system start-up, these so libraries cannot be compressed, where the so library compression rule may be: the so library which is irrelevant to the system start is determined as the to-be-compressed so library.
At this time, step S120 specifically includes: a so library of the plurality of so libraries that is not related to system start-up is determined as a to-be-compressed so library.
S130, compressing a plurality of to-be-compressed so libraries to the custom catalog in the initial APK file by using a preset compression plug-in, and creating the so library configuration file under the custom catalog.
In this embodiment, the preset compression plug-in may be a 7z compression plug-in, and the 7z compression plug-in is compressed more thoroughly for other conventional compression plug-ins.
The custom directory in this embodiment is an assembly directory.
Specifically, compressing a to-be-compressed so library under an initial APK file lib directory to an assembly directory of the initial APK file, writing a so library dependency relationship and a cpu model of the compressed so library into a so library configuration file, and writing the so library configuration file into the assembly directory.
And S140, adding the loader interception hook into the initial APK file to obtain the target APK file.
In this embodiment, after further compressing a plurality of to-be-compressed so libraries in an initial APK file, in order to enable the subsequent APK file loading terminal 20 to smoothly load the to-be-compressed so libraries, a loader interception hook needs to be added to the APK file.
The loader interception hook is used for intercepting a current catalog to be loaded of the system loader, and before the intercepting system loader obtains the current catalog to be loaded, the current catalog to be loaded is intercepted first, then a compressed so library corresponding to the current catalog to be loaded is decompressed to a designated position under the catalog of the system so library, wherein the designated position can be under a folder corresponding to the cpu model of the compressed so library.
Further, the target APK file is obtained, and the target APK file needs to be uploaded to a download platform, so that the APK file loading terminal 20 can obtain the target APK file from the download platform.
In summary, in this embodiment, a portion of the so library in the initial APK file is further compressed, and the so library in the initial APK file is not modified invasively, so that the stability of the so library in the initial APK file can be ensured, and meanwhile, the package volume of the APK file is reduced.
Fig. 4 is another flow chart of a processing method of an APK file provided in an embodiment of the present application. The corresponding flow of fig. 4 is implemented after the corresponding embodiment of fig. 2, where the execution body of the embodiment is an APK file loading terminal in the APK file processing system, and the method includes steps S210-S250:
s210, acquiring a target APK file, wherein the target APK file comprises a loader interception hook and a custom solibrary directory, the custom directory comprises a solibrary configuration file and a plurality of compressed solibraries, the solibrary configuration file comprises configuration information of each compressed solibrary, and the configuration information comprises a solibrary name, a solibrary dependency relationship and a cpu model.
In this embodiment, specifically, the target APK file may be obtained by the following steps, and a download instruction for the target APK file may be received; and responding to the downloading instruction, and downloading the target APK file from a downloading platform.
For example, a download address of the target APK file is input in an APK file loading terminal (such as a mobile phone), a download instruction is generated based on the download address, and then the download of the target APK file is performed from the download platform through the download instruction.
The custom soo library directory can be named according to the version number of the application, and when the soo library is loaded, the subsequent self-defined soo library directory with the latest version number is decompressed and loaded automatically.
S220, intercepting a current directory to be loaded of a system loader by the loader interception hook, wherein the current directory to be loaded comprises a name of a to-be-loaded so library.
Specifically, in this embodiment, when the loader interception hook detects that the system is about to send to the current directory to be loaded of the system loader (e.g., system loadlibrary or system. Load), the current directory to be loaded is intercepted before the current directory to be loaded is sent to the system loader.
S230, judging whether a target SOB name corresponding to the SOB name to be loaded exists in the SOB configuration file.
In this embodiment, the current directory to be loaded includes a main so library load directory or a plug-in so library load directory.
When the current catalog to be loaded is the main so library loading catalog; the intercepting, by the loader, the current directory to be loaded of the loader of the system by the hook includes:
when receiving an installation instruction of the target APK file, generating a loading directory of the main so library; and intercepting the main so library loading directory by the loader intercepting hook.
Therefore, in the embodiment, when the target APK file is installed, only the so library corresponding to the main APK needs to be installed, so that the installation speed of the application can be improved. The target APK file comprises a main APK and at least one plug-in APK.
When the current catalog to be loaded is a plug-in so library loading catalog; the intercepting, by the loader, the current directory to be loaded of the loader of the system by the hook includes:
when a trigger instruction of a user for a target plugin in a target application is received, a plugin so library loading catalog corresponding to the target plugin is generated; and intercepting the plug-in so library loading directory by the loader intercepting hook.
Therefore, the plug-in so library in the embodiment is loaded when the target plug-in is triggered in the target application (for example, when the user needs to use the plug-in, clicking operation is performed), and some plug-in users do not need to load the plug-ins which are not used by the users, so that the mobile phone memory occupied by the application can be effectively reduced.
S240, if the target SOB name exists in the SOB configuration file, determining at least one target compressed SOB from a plurality of compressed SOB according to the CPU model corresponding to the target SOB name, the corresponding SOB dependency relationship and the system CPU model.
In some embodiments, step S240 includes:
determining configuration information corresponding to the target so library name as target configuration information, wherein the target configuration information comprises a target so library dependency relationship and a cpu model; determining a dependent so library name associated with the target so library name according to the target so library dependency relationship; determining a first so library corresponding to the target so library name from a plurality of the compressed so libraries; and determining a second so library corresponding to the dependent so library name from a plurality of the compressed so libraries; and determining the first so library and the second so library, wherein the cpu model of the first so library and the second so library corresponds to the cpu model of the system, as the target compressed so library.
For example, the target so library name is a.so, and according to the target so library dependency relationship, a.so depends on b.so, and at this time, b.so is the dependent so library name, the first so library includes a plurality of cpu models corresponding to a.so, and the second so library includes b.so of a plurality of cpu models.
The system cpu model is the cpu model of the corresponding APK file loading terminal, and in this embodiment, only the so file corresponding to the cpu model of the device needs to be decompressed and loaded, so that the mobile phone memory occupied by the application is further reduced.
It should be noted that, if there is no dependent so-library name associated with the target so-library name, the confirmation of the second so-library is not required; if there is a dependent so-library name associated with the target so-library name, but there is no so-library corresponding to the dependent so-library name in the plurality of compressed so-libraries (under the custom directory), this indicates that the second so-library is not further compressed, and no further decompression of the second so-library is required.
In addition, after the determining whether the target soku name corresponding to the soku name to be loaded exists in the soku configuration file, the method further includes:
and if the target solibrary name does not exist in the solibrary configuration file, directly loading the solibrary under the system solibrary catalog through the system loader and the current catalog to be loaded.
If the target sostore name does not exist in the sostore configuration file, it is indicated that the sostore corresponding to the target sostore name is not further compressed, and at this time, loading can be directly performed.
S250, decompressing each target compressed so library to a system so library catalog to obtain target decompressed so libraries corresponding to each target compressed so library, and loading the target decompressed so libraries under the system so library catalog through the system loading program and the current catalog to be loaded.
In this embodiment, the so library corresponding to the current directory to be loaded is decompressed to the system so library directory, and at this time, the current directory to be loaded may be sent to the system loader, so that the system loader loads the so library based on the current directory to be loaded.
In summary, the so library in the target APK file obtained in the embodiment of the present application is a so library subjected to compression processing, so that the volume of the APK file is reduced, and in addition, the target APK file in the embodiment further includes a loader interception hook, through which a system loader may be intercepted, and the so library subjected to compression processing may be decompressed first, so that the system loader may load the so library of the target APK file.
In addition, the embodiment also provides another loading method of the so library, in the method, a decompression path can be injected, when the application is installed, the system is enabled to decompress and load all the so libraries under the custom so library directory in advance, and when the APK plug-in is used subsequently, the starting speed of the plug-in is faster.
Fig. 5 is a schematic block diagram of an APK file processing apparatus provided in an embodiment of the present application. As shown in fig. 5, the present application further provides an APK file processing apparatus corresponding to the above APK file processing method. The APK file processing apparatus includes a unit for executing the above APK file processing method, and the apparatus may be configured in an APK file processing system. Specifically, referring to fig. 5, the APK file processing apparatus includes a first transceiver unit 501, a first processing unit 502, a second transceiver unit 503, and a second processing unit 504, and specifically, the APK file processing apparatus includes a first APK file processing apparatus and a second APK file processing apparatus, where the first APK file processing apparatus includes the first transceiver unit 501 and the first processing unit 502, and is disposed at an APK file loading terminal; the second APK file processing device includes a second transceiver unit 503 and a second processing unit 504, and is disposed on the APK file compression platform:
a first transceiver unit 501, configured to obtain a target APK file, where the target APK file includes a loader interception hook and a custom so library directory, where the custom directory includes a so library configuration file and a plurality of compressed so libraries, the so library configuration file includes configuration information of each of the compressed so libraries, and the configuration information includes a so library name, a so library dependency relationship, and a cpu model;
a first processing unit 502, configured to intercept, by using the loader interception hook, a current directory to be loaded of a system loader, where the current directory to be loaded includes a name of a so library to be loaded; judging whether a target SOB name corresponding to the SOB name to be loaded exists in the SOB configuration file; if the target sostore name exists in the sostore configuration file, determining at least one target compressed sostore from a plurality of compressed sostores according to a cpu model corresponding to the target sostore name, a corresponding sostore dependency relationship and a system cpu model; decompressing each target compressed so library to a system so library directory to obtain target decompressed so libraries corresponding to each target compressed so library, and loading the target decompressed so libraries under the system so library directory through the system loading program and the current directory to be loaded.
In some embodiments, when the first processing unit 502 performs the step of determining at least one target compressed so library from the compressed so libraries according to the cpu model corresponding to the target so library name, the corresponding so library dependency relationship, and the system cpu model, the method is specifically configured to:
determining configuration information corresponding to the target so library name as target configuration information, wherein the target configuration information comprises a target so library dependency relationship and a cpu model; determining a dependent so library name associated with the target so library name according to the target so library dependency relationship; determining a first so library corresponding to the target so library name from a plurality of the compressed so libraries; and determining a second so library corresponding to the dependent so library name from a plurality of the compressed so libraries; and determining the first so library and the second so library, wherein the cpu model of the first so library and the second so library corresponds to the cpu model of the system, as the target compressed so library.
In some embodiments, after performing the step of determining whether the target soku name corresponding to the soku name to be loaded exists in the soku configuration file, the first processing unit 502 is further configured to:
and if the target solibrary name does not exist in the solibrary configuration file, directly loading the solibrary under the system solibrary catalog through the system loader and the current catalog to be loaded.
In some embodiments, when the current directory to be loaded is a master so library loading directory; the first processing unit 502 is specifically configured to, when executing the step of intercepting, by the loader interception hook, a current directory to be loaded of a system loader:
when receiving an installation instruction of the target APK file, generating a loading directory of the main so library; and intercepting the main so library loading directory by the loader intercepting hook.
In some embodiments, when the current catalog to be loaded is a add-in so library loading catalog; the first processing unit 502 is specifically configured to, when executing the step of intercepting, by the loader interception hook, a current directory to be loaded of a system loader:
when a trigger instruction of a user for a target plugin in a target application is received, a plugin so library loading catalog corresponding to the target plugin is generated; and intercepting the plug-in so library loading directory by the loader intercepting hook.
In some embodiments, the first transceiver unit 501 is specifically configured to, when executing the step of obtaining the target APK file:
receiving a downloading instruction aiming at the target APK file; and responding to the downloading instruction, and downloading the target APK file from a downloading platform.
In some embodiments, the second transceiver unit 503 is configured to obtain an initial APK file, where the initial APK file includes a system so library directory, and the system so library directory includes a plurality of so libraries;
the second processing unit 504 is configured to determine a plurality of to-be-compressed so libraries from a plurality of so libraries according to a preset so library compression rule; compressing a plurality of to-be-compressed so libraries to the custom directory in the initial APK file by using a preset compression plug-in, and creating the so library configuration file under the custom directory; and adding the loader interception hook into the initial APK file to obtain the target APK file.
In summary, the processing system of the APK file in the embodiment of the present application performs further compression processing (secondary compression processing) on the so library in the target APK file, so that the volume of the APK file is reduced, and in addition, the target APK file in the embodiment further includes a loader interception hook, through which the system loader may be intercepted, and the compressed so library may be decompressed first, so that the system loader may load the so library of the target APK file.
It should be noted that, as those skilled in the art can clearly understand, the specific implementation process of the processing device and each unit of the APK file may refer to the corresponding description in the foregoing method embodiment, and for convenience and brevity of description, the description is omitted here.
The processing means of the APK file described above may be implemented in the form of a computer program which can be run on a computer device as shown in fig. 6.
Referring to fig. 6, fig. 6 is a schematic block diagram of a computer device according to an embodiment of the present application. The computer device 600 may be a terminal or a server, and specifically, the computer device 600 is an APK file compression platform or an APK file loading terminal in an APK file processing system.
With reference to FIG. 6, the computer device 600 includes a processor 602, memory and a network interface 605 connected by a system bus 601, wherein the memory may include a non-volatile storage medium 603 and an internal memory 604.
The non-volatile storage medium 603 may store an operating system 6031 and a computer program 6032. The computer program 6032 comprises program instructions that, when executed, cause the processor 602 to perform a method of processing an APK file.
The processor 602 is used to provide computing and control capabilities to support the operation of the overall computer device 600.
The internal memory 604 provides an environment for the execution of a computer program 6032 in the non-volatile storage medium 603, which computer program 6032, when executed by the processor 602, causes the processor 602 to perform a method for processing APK files.
The network interface 605 is used for network communication with other devices. Those skilled in the art will appreciate that the architecture shown in fig. 6 is merely a block diagram of a portion of the architecture in connection with the present application and is not intended to limit the computer device 600 to which the present application is applied, and that a particular computer device 600 may include more or fewer components than shown, or may combine certain components, or have a different arrangement of components.
Wherein, when the computer device 600 is an APK file loading terminal, the processor 602 is configured to execute the computer program 6032 stored in the memory, so as to implement the following steps:
acquiring a target APK file, wherein the target APK file comprises a loader interception hook and a custom solibrary directory, the custom directory comprises a solibrary configuration file and a plurality of compressed solibraries, the solibrary configuration file comprises configuration information of each compressed solibrary, and the configuration information comprises a solibrary name, a solibrary dependency relationship and a cpu model;
intercepting a current directory to be loaded of a system loader through the loader interception hook, wherein the current directory to be loaded comprises a name of a so library to be loaded;
judging whether a target SOB name corresponding to the SOB name to be loaded exists in the SOB configuration file;
if the target sostore name exists in the sostore configuration file, determining at least one target compressed sostore from a plurality of compressed sostores according to a cpu model corresponding to the target sostore name, a corresponding sostore dependency relationship and a system cpu model;
decompressing each target compressed so library to a system so library directory to obtain target decompressed so libraries corresponding to each target compressed so library, and loading the target decompressed so libraries under the system so library directory through the system loading program and the current directory to be loaded.
Wherein, when the computer device 600 is an APK file compression platform, the processor 602 is configured to execute the computer program 6032 stored in the memory, so as to implement the steps of:
acquiring an initial APK file, wherein the initial APK file comprises a system so library directory, and the system so library directory comprises a plurality of so libraries;
determining a plurality of to-be-compressed so libraries from a plurality of so libraries according to a preset so library compression rule;
compressing a plurality of to-be-compressed so libraries to the custom directory in the initial APK file by using a preset compression plug-in, and creating the so library configuration file under the custom directory;
and adding the loader interception hook into the initial APK file to obtain the target APK file.
It should be appreciated that in embodiments of the present application, the processor 602 may be a central first processing unit (Central Processing Unit, CPU), the processor 602 may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSPs), application specific integrated circuits (Application Specific Integrated Circuit, ASICs), off-the-shelf programmable gate arrays (Field-Programmable Gate Array, FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. Wherein the general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Those skilled in the art will appreciate that all or part of the flow in a method embodying the above described embodiments may be accomplished by computer programs instructing the relevant hardware. The computer program comprises program instructions, and the computer program can be stored in a storage medium, which is a computer readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the flow steps of the embodiments of the method described above.
Accordingly, the present application also provides a storage medium. The storage medium may be a computer readable storage medium. The storage medium stores a computer program, wherein the computer program includes program instructions. The program instructions, when executed by the processor, cause the processor to perform the steps of:
acquiring a target APK file, wherein the target APK file comprises a loader interception hook and a custom solibrary directory, the custom directory comprises a solibrary configuration file and a plurality of compressed solibraries, the solibrary configuration file comprises configuration information of each compressed solibrary, and the configuration information comprises a solibrary name, a solibrary dependency relationship and a cpu model;
intercepting a current directory to be loaded of a system loader through the loader interception hook, wherein the current directory to be loaded comprises a name of a so library to be loaded;
judging whether a target SOB name corresponding to the SOB name to be loaded exists in the SOB configuration file;
if the target sostore name exists in the sostore configuration file, determining at least one target compressed sostore from a plurality of compressed sostores according to a cpu model corresponding to the target sostore name, a corresponding sostore dependency relationship and a system cpu model;
decompressing each target compressed so library to a system so library directory to obtain target decompressed so libraries corresponding to each target compressed so library, and loading the target decompressed so libraries under the system so library directory through the system loading program and the current directory to be loaded.
The storage medium may be a U-disk, a removable hard disk, a Read-Only Memory (ROM), a magnetic disk, or an optical disk, or other various computer-readable storage media that can store program codes.
Those of ordinary skill in the art will appreciate that the elements and algorithm steps described in connection with the embodiments disclosed herein may be embodied in electronic hardware, in computer software, or in a combination of the two, and that the elements and steps of the examples have been generally described in terms of function in the foregoing description to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the several embodiments provided in this application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of each unit is only one logic function division, and there may be another division manner in actual implementation. For example, multiple units or components may be combined or may be integrated into another system, or some features may be omitted, or not performed.
The steps in the method of the embodiment of the application can be sequentially adjusted, combined and deleted according to actual needs. The units in the device of the embodiment of the application can be combined, divided and deleted according to actual needs. In addition, each functional unit in each embodiment of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The integrated unit may be stored in a storage medium if implemented in the form of a software functional unit and sold or used as a stand-alone product. Based on such understanding, the technical solution of the present application is essentially or a part contributing to the prior art, or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a terminal, or a network device, etc.) to perform all or part of the steps of the method described in the embodiments of the present application.
While the invention has been described with reference to certain preferred embodiments, it will be understood by those skilled in the art that various changes and substitutions of equivalents may be made and equivalents will be apparent to those skilled in the art without departing from the scope of the invention. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (8)

1. A method for processing an APK file, the method comprising:
acquiring a target APK file, wherein the target APK file comprises a loader interception hook and a custom solibrary directory, the custom solibrary directory comprises a solibrary configuration file and a plurality of compressed solibraries, the solibrary configuration file comprises configuration information of each compressed solibrary, the configuration information comprises a solibrary name, a solibrary dependency relationship and a cpu model, the custom solibrary directory is named according to an application version number, and the version number is used for decompressing and loading the compressed solibraries in the custom solibrary directory with the latest version number when loading the solibraries;
intercepting a current directory to be loaded of a system loader through the loader interception hook, wherein the current directory to be loaded comprises a name of a so library to be loaded;
judging whether a target SOB name corresponding to the SOB name to be loaded exists in the SOB configuration file;
if the target sostore name exists in the sostore configuration file, determining at least one target compressed sostore from a plurality of compressed sostores according to a cpu model corresponding to the target sostore name, a corresponding sostore dependency relationship and a system cpu model;
decompressing each target compressed so library to a system so library catalog to obtain target decompressed so libraries corresponding to each target compressed so library respectively, and loading the target decompressed so libraries under the system so library catalog through the system loading program and the current catalog to be loaded;
when the current catalog to be loaded is the main sol library loading catalog; the intercepting, by the loader, the current directory to be loaded of the loader of the system by the hook includes:
when receiving an installation instruction of the target APK file, generating a loading directory of the main so library;
intercepting the main so library loading directory by the loader intercepting hook;
before the target APK file is acquired, the method further includes:
acquiring an initial APK file, wherein the initial APK file comprises a system so library directory, and the system so library directory comprises a plurality of so libraries;
determining a plurality of to-be-compressed so libraries from a plurality of so libraries according to a preset so library compression rule;
compressing a plurality of to-be-compressed so libraries to the custom so library catalogue in the initial APK file by using a preset compression plug-in, and creating the so library configuration file under the custom so library catalogue;
and adding the loader interception hook into the initial APK file to obtain the target APK file.
2. The method of claim 1, wherein the determining at least one target compressed so library from a plurality of the compressed so libraries according to the cpu model corresponding to the target so library name, the corresponding so library dependency, and the system cpu model comprises:
determining configuration information corresponding to the target so library name as target configuration information, wherein the target configuration information comprises a target so library dependency relationship and a cpu model;
determining a dependent so library name associated with the target so library name according to the target so library dependency relationship;
determining a first so library corresponding to the target so library name from a plurality of the compressed so libraries; and determining a second so library corresponding to the dependent so library name from a plurality of the compressed so libraries;
and determining the first so library and the second so library, wherein the cpu model of the first so library and the second so library corresponds to the cpu model of the system, as the target compressed so library.
3. The method according to claim 1, wherein after said determining whether there is a target so-library name corresponding to the so-library name to be loaded in the so-library profile, the method further comprises:
and if the target solibrary name does not exist in the solibrary configuration file, directly loading the solibrary under the system solibrary catalog through the system loader and the current catalog to be loaded.
4. The method according to claim 1, wherein when the current directory to be loaded is a add-in so-library loaded directory; the intercepting, by the loader, the current directory to be loaded of the loader of the system by the hook includes:
when a trigger instruction of a user for a target plugin in a target application is received, a plugin so library loading catalog corresponding to the target plugin is generated;
and intercepting the plug-in so library loading directory by the loader intercepting hook.
5. The method of claim 1, wherein the obtaining the target APK file comprises:
receiving a downloading instruction aiming at the target APK file;
and responding to the downloading instruction, and downloading the target APK file from a downloading platform.
6. An APK file processing apparatus, comprising:
the system comprises a first transceiver unit, a second transceiver unit and a third transceiver unit, wherein the first transceiver unit is used for acquiring a target APK file, the target APK file comprises a loader interception hook and a custom so library directory, the custom so library directory comprises a so library configuration file and a plurality of compressed so libraries, the so library configuration file comprises configuration information of each compressed so library, the configuration information comprises a so library name, a so library dependence relationship and a cpu model, the custom so library directory is named according to an application version number, and the version number is used for decompressing and loading the compressed so libraries in the custom so library directory with the latest version number when the so library is loaded;
the first processing unit is used for intercepting a current directory to be loaded of a system loader through the loader interception hook, wherein the current directory to be loaded comprises a name of a so library to be loaded; judging whether a target SOB name corresponding to the SOB name to be loaded exists in the SOB configuration file; if the target sostore name exists in the sostore configuration file, determining at least one target compressed sostore from a plurality of compressed sostores according to a cpu model corresponding to the target sostore name, a corresponding sostore dependency relationship and a system cpu model; decompressing each target compressed so library to a system so library catalog to obtain target decompressed so libraries corresponding to each target compressed so library respectively, and loading the target decompressed so libraries under the system so library catalog through the system loading program and the current catalog to be loaded;
when the current catalog to be loaded is the main sol library loading catalog; the first processing unit is specifically configured to, when executing the step of intercepting, by the loader interception hook, a current directory to be loaded of a system loader:
when receiving an installation instruction of the target APK file, generating a loading directory of the main so library; intercepting the main so library loading directory by the loader intercepting hook;
the second transceiver unit is used for acquiring an initial APK file, wherein the initial APK file comprises a system so library directory, and the system so library directory comprises a plurality of so libraries;
the second processing unit is used for determining a plurality of to-be-compressed so libraries from a plurality of so libraries according to a preset so library compression rule; compressing a plurality of to-be-compressed so libraries to the custom so library catalogue in the initial APK file by using a preset compression plug-in, and creating the so library configuration file under the custom so library catalogue; and adding the loader interception hook into the initial APK file to obtain the target APK file.
7. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method of processing an APK file according to any of claims 1-5 when executing the computer program.
8. A storage medium storing a computer program comprising program instructions which, when executed by a processor, cause the processor to perform the method of processing an APK file according to any one of claims 1 to 5.
CN202311596772.1A 2023-11-28 2023-11-28 APK file processing method and device, computer equipment and storage medium Active CN117311853B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311596772.1A CN117311853B (en) 2023-11-28 2023-11-28 APK file processing method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311596772.1A CN117311853B (en) 2023-11-28 2023-11-28 APK file processing method and device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN117311853A CN117311853A (en) 2023-12-29
CN117311853B true CN117311853B (en) 2024-03-12

Family

ID=89273939

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311596772.1A Active CN117311853B (en) 2023-11-28 2023-11-28 APK file processing method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117311853B (en)

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108279941A (en) * 2016-12-31 2018-07-13 阿里巴巴集团控股有限公司 A kind of compression method and device of application program
CN109960902A (en) * 2019-04-08 2019-07-02 北京智游网安科技有限公司 A kind of safety protecting method of dynamic link library, storage medium and terminal device
CN110765394A (en) * 2019-09-20 2020-02-07 中国平安人寿保险股份有限公司 So file loading method and device, storage medium and terminal equipment
CN113296781A (en) * 2021-02-01 2021-08-24 阿里巴巴集团控股有限公司 Application program installation package file compiling and constructing method and device and electronic equipment
CN113568680A (en) * 2021-07-23 2021-10-29 杭州网易智企科技有限公司 Dynamic link library protection method, device, equipment and medium for application program
WO2021218173A1 (en) * 2020-04-30 2021-11-04 平安科技(深圳)有限公司 Source code reinforcement method and apparatus, and computer device and storage medium
CN113901010A (en) * 2021-10-29 2022-01-07 广州品唯软件有限公司 Android application package compression method and device
CN114090070A (en) * 2021-09-28 2022-02-25 阿里巴巴(中国)有限公司 Application program installation package file processing method and electronic equipment
WO2022083316A1 (en) * 2020-10-21 2022-04-28 北京字节跳动网络技术有限公司 Application running method and apparatus, and computer storage medium

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108279941A (en) * 2016-12-31 2018-07-13 阿里巴巴集团控股有限公司 A kind of compression method and device of application program
CN109960902A (en) * 2019-04-08 2019-07-02 北京智游网安科技有限公司 A kind of safety protecting method of dynamic link library, storage medium and terminal device
CN110765394A (en) * 2019-09-20 2020-02-07 中国平安人寿保险股份有限公司 So file loading method and device, storage medium and terminal equipment
WO2021218173A1 (en) * 2020-04-30 2021-11-04 平安科技(深圳)有限公司 Source code reinforcement method and apparatus, and computer device and storage medium
WO2022083316A1 (en) * 2020-10-21 2022-04-28 北京字节跳动网络技术有限公司 Application running method and apparatus, and computer storage medium
CN113296781A (en) * 2021-02-01 2021-08-24 阿里巴巴集团控股有限公司 Application program installation package file compiling and constructing method and device and electronic equipment
CN113568680A (en) * 2021-07-23 2021-10-29 杭州网易智企科技有限公司 Dynamic link library protection method, device, equipment and medium for application program
CN114090070A (en) * 2021-09-28 2022-02-25 阿里巴巴(中国)有限公司 Application program installation package file processing method and electronic equipment
CN113901010A (en) * 2021-10-29 2022-01-07 广州品唯软件有限公司 Android application package compression method and device

Also Published As

Publication number Publication date
CN117311853A (en) 2023-12-29

Similar Documents

Publication Publication Date Title
JP5658283B2 (en) Application operating method, apparatus and system
US20150220326A1 (en) Mobile Terminal and Software Upgrade Method Thereof
CN108520059A (en) Loading method, system, computer equipment and the storage medium of the client H5 pages
CN109857454B (en) Method, device, electronic equipment and storage medium for generating and caching installation package
CN109857423B (en) Program version updating method and device, server and readable storage medium
CN111897520A (en) Front-end project framework construction method and device, computer equipment and storage medium
CN107844306B (en) Application program repairing method and device, storage medium and terminal
CN110780883A (en) Method call chain tracking method, electronic device, and computer-readable storage medium
CN106325896B (en) Shared function library file processing method and device for installation package
CN110765394A (en) So file loading method and device, storage medium and terminal equipment
CN110532016B (en) Version management method, version updating method and version management system
CN108132832B (en) Application program starting method and device
CN111552517B (en) Application program starting method and device, electronic equipment and computer storage medium
CN106293790B (en) application program upgrading method and device based on Firefox operating system
CN117311853B (en) APK file processing method and device, computer equipment and storage medium
CN113157337A (en) Application program starting method and device, terminal equipment and storage medium
CN107908634B (en) Cache control method of browser and mobile terminal
WO2022028046A1 (en) Image configuration method, device and system, and storage medium
CN111475220B (en) Cold start method and device, electronic equipment and computer storage medium
CN114077458A (en) Method, device, equipment and storage medium for starting service module in application program
CN114090070A (en) Application program installation package file processing method and electronic equipment
CN113282363A (en) Method and device for optimizing hybrid APP
CN113157348A (en) Game starting method and device, computer equipment and storage medium
CN113296781A (en) Application program installation package file compiling and constructing method and device and electronic equipment
CN116382796B (en) Plug-in management method and device of H5 applet runner and electronic equipment

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