CN110389762A - The method and apparatus of AAR packet are handled in Android engineering - Google Patents

The method and apparatus of AAR packet are handled in Android engineering Download PDF

Info

Publication number
CN110389762A
CN110389762A CN201810353103.4A CN201810353103A CN110389762A CN 110389762 A CN110389762 A CN 110389762A CN 201810353103 A CN201810353103 A CN 201810353103A CN 110389762 A CN110389762 A CN 110389762A
Authority
CN
China
Prior art keywords
file
specified
aar
packet
list
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.)
Granted
Application number
CN201810353103.4A
Other languages
Chinese (zh)
Other versions
CN110389762B (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 Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information 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 Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201810353103.4A priority Critical patent/CN110389762B/en
Publication of CN110389762A publication Critical patent/CN110389762A/en
Application granted granted Critical
Publication of CN110389762B publication Critical patent/CN110389762B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

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)

Abstract

The method and apparatus that the invention discloses a kind of to handle AAR packet in Android engineering, are related to field of computer technology.Wherein, this method comprises: the information of the specified AAR packet relied on according to application module in Android engineering generates and relies on list;Wherein, the specified AAR coating that the application module relies on is preconfigured to the pattern compiler of " use, and be packed into compiling result in compiling ";Multiple compiler tasks of the Android engineering are hooked, based on Hook Technique to remove the specified AAR packet according to the dependence list.By above step, it can make application module that the function of " provided AAR " also may be implemented, i.e. the AAR packet of dependence is not packed into compiling result finally by compiling duration using the AAR packet relied on, and then is melted hair for Android plug-in unit and provided technical support.

Description

The method and apparatus of AAR packet are handled in Android engineering
Technical field
The present invention relates to field of computer technology more particularly to it is a kind of in Android engineering handle AAR packet method with Device.
Background technique
There are a variety of pattern compilers, such as compile mode, provided mode etc. in Android engineering development. The archive file (such as JAR packet, AAR packet) of dependence can be bundled in compiling result by compile mode.Provided mode is then Archive file only is used in compiling duration, archive file is not bundled in compiling result finally.
In realizing process of the present invention, at least there are the following problems in the prior art for inventor's discovery: this for JAR packet For archive file, either in library module (library module) or in application module (application module), Compile mode and provided mode all come into force.For archive file this for AAR packet, in library module Compile mode and provided mode all come into force, in application module compile mode be come into force, Provided mode is infirm.
Summary of the invention
In view of this, the present invention provides a kind of method and apparatus for handling AAR packet in Android engineering, can make to answer The function of " provided AAR " also may be implemented with module, i.e., compiling duration is using the AAR packet relied on, finally not by dependence AAR packet is packed into compiling result, and then is melted hair for Android plug-in unit and provided technical support.
To achieve the above object, according to an aspect of the invention, there is provided a kind of handle AAR in Android engineering The method of packet.
The method of AAR packet that handles in Android engineering of the invention includes: according to application module in Android engineering The information of the specified AAR packet relied on, which generates, relies on list;Wherein, the specified AAR coating that the application module relies on is pre-configured with For the pattern compiler of " use, and be packed into compiling result in compiling ";The Android engineering is hooked based on Hook Technique Multiple compiler tasks, to remove the specified AAR packet according to the dependence list.
Optionally, the method also includes: it is specified executing described according to application module in Android engineering and relying on Before the information of AAR packet generates the step of relying on list, all AAR packets that application module relies in Android engineering are parsed Information, and find out from the information of all AAR packets the information of the specified AAR packet.
Optionally, multiple compiler tasks that the Android engineering is hooked based on Hook Technique, with according to it is described according to The step of relying list to remove specified AAR packet includes: the compiler task for hooking the process resource file of the Android engineering, with The resource file in specified AAR packet is removed according to the dependence list;Hook the handler file of the Android engineering Compiler task, to remove the program file in specified AAR packet according to the dependence list.
Optionally, multiple compiler tasks that the Android engineering is hooked based on Hook Technique, with according to it is described according to The step of relying list to remove specified AAR packet further include: the task of processing routine global configuration file is hooked, according to the dependence Described program global configuration file is deleted in list.
Optionally, the resource file includes: res resource file and assets resource file;It is described hook it is described The compiler task of the process resource file of Android engineering, to remove the resource text in specified AAR packet according to the dependence list The step of part includes: the hooking processing res resource file of the task, removes the res in specified AAR packet according to the dependence list and provides Source file;The hooking processing assets resource file of the task removes the assets in specified AAR packet according to the dependence list and provides Source file.
Optionally, the method also includes: res resource in specified AAR packet is removed according to the dependence list described After the step of file, arranged in sequence is carried out to the mark of remaining res resource file, then more according to the result of arranged in sequence New res the Resources list file.
Optionally, described program file includes: class file and so library file;The place for hooking the Android engineering The compiler task of program file is managed, to include: hook according to the step of program file relied in the specified AAR packet of list removal The task of class file is managed in dwelling, to remove the class file in specified AAR packet according to the dependence list;Hook processing so library file Task, to remove so library file in specified AAR packet according to the dependence list.
To achieve the above object, according to another aspect of the present invention, it provides one kind and handles AAR in Android engineering The device of packet.
The device of AAR packet that handles in Android engineering of the invention includes: generation module, for according to Android work The information for the specified AAR packet that application module relies in journey, which generates, relies on list;Wherein, the specified AAR that the application module relies on Coating is preconfigured to the pattern compiler of " use, and be packed into compiling result in compiling ";Processing module, for being based on hook Sub- technology hooks multiple compiler tasks of the Android engineering, to remove the specified AAR packet according to the dependence list.
Optionally, described device further include: parsing module, for parsing application module dependence in Android engineering The information of all AAR packets, and find out from the information of all AAR packets the information of the specified AAR packet.
Optionally, the processing module hooks multiple compiler tasks of the Android engineering based on Hook Technique, with root Removing specified AAR packet according to the dependence list includes: the process resource file that the processing module hooks the Android engineering Compiler task, to remove the resource file in specified AAR packet according to the dependence list;The processing module is hooked described The compiler task of the handler file of Android engineering, to remove the program text in specified AAR packet according to the dependence list Part.
Optionally, the processing module hooks multiple compiler tasks of the Android engineering based on Hook Technique, with root Specified AAR packet is removed according to the dependence list further include: the processing module hooks the task of processing routine global configuration file, To be deleted according to the dependence list described program global configuration file.
Optionally, the resource file includes: res resource file and assets resource file;The processing module is hooked The compiler task of the process resource file of the Android engineering, to remove the money in specified AAR packet according to the dependence list Source file includes: the task that the processing module hooks processing res resource file, removes specified AAR according to the dependence list Res resource file in packet;The processing module hooks the task of processing assets resource file, according to the dependence list Remove the assets resource file in specified AAR packet.
Optionally, the processing module is also used to: being specified in AAR packet executing described remove according to the dependence list After the operation of res resource file, arranged in sequence is carried out to the mark of remaining res resource file, then according to arranged in sequence Result update res the Resources list file.
Optionally, described program file includes: class file and so library file;The processing module hooks the Android The compiler task of the handler file of engineering, to include: according to the program file in the specified AAR packet of dependence list removal The processing module hooks the task of processing class file, to remove the class file in specified AAR packet according to the dependence list;Institute The task that processing module hooks processing so library file is stated, to remove so library file in specified AAR packet according to the dependence list.
To achieve the above object, according to a further aspect of the invention, a kind of electronic equipment is provided.
Electronic equipment of the invention, comprising: one or more processors;And storage device, for storing one or more A program;When one or more of programs are executed by one or more of processors, so that one or more of processing Device realizes the method for the invention that AAR packet is handled in Android engineering.
To achieve the above object, according to a further aspect of the invention, a kind of computer-readable medium is provided.
Computer-readable medium of the invention is stored thereon with computer program, real when described program is executed by processor The existing method of the invention that AAR packet is handled in Android engineering.
One embodiment in foregoing invention has the following advantages that or the utility model has the advantages that is compiled to Android engineering When, by configuring " use, and be packed into compiling result in compiling " for the specified AAR packet that application module relies in advance Pattern compiler, the information of the specified AAR packet relied on according to application module, which generates, relies on list, is hooked based on Hook Technique described Multiple compiler tasks of Android engineering can make Android engineering to remove specified AAR packet according to the dependence list The function of " provided AAR " also may be implemented in application module, i.e., compiling duration is using the AAR packet relied on, finally not by dependence AAR packet is packed into compiling result, and then is melted hair for Android plug-in unit and provided technical support.
Further effect possessed by above-mentioned non-usual optional way adds hereinafter in conjunction with specific embodiment With explanation.
Detailed description of the invention
Attached drawing for a better understanding of the present invention, does not constitute an undue limitation on the present invention.Wherein:
Fig. 1 is that the key step of the method according to an embodiment of the invention that AAR packet is handled in Android engineering is shown It is intended to;
Fig. 2 is that the key step of the method according to another embodiment of the present invention that AAR packet is handled in Android engineering is shown It is intended to;
Fig. 3 is that the key step of the method that AAR packet is handled in Android engineering according to yet another embodiment of the invention is shown It is intended to;
Fig. 4 is that the main modular of the device according to an embodiment of the invention that AAR packet is handled in Android engineering is shown It is intended to;
Fig. 5 is that the main modular of the device according to another embodiment of the present invention that AAR packet is handled in Android engineering is shown It is intended to;
Fig. 6 is that the embodiment of the present invention can be applied to exemplary system architecture figure therein;
Fig. 7 is adapted for the structural schematic diagram for the computer system for realizing the electronic equipment of the embodiment of the present invention.
Specific embodiment
Below in conjunction with attached drawing, an exemplary embodiment of the present invention will be described, including the various of the embodiment of the present invention Details should think them only exemplary to help understanding.Therefore, those of ordinary skill in the art should recognize It arrives, it can be with various changes and modifications are made to the embodiments described herein, without departing from scope and spirit of the present invention.Together Sample, for clarity and conciseness, descriptions of well-known functions and structures are omitted from the following description.
It should be pointed out that in the absence of conflict, the feature in embodiment and embodiment in the present invention can be with It is combined with each other.
Before each embodiment of the invention is discussed in detail, portion of techniques term of the present invention is said first It is bright.
AAR packet: Android Archive, a kind of Android library item purpose binary system archive file.
JAR packet: Java Archive, Java archive file.
Compile: dependence in compiling using dependence, and is finally packed into compiling knot by a kind of Android pattern compiler In fruit.
Provided: dependence in compiling using dependence, and is not finally packed into volume by a kind of Android pattern compiler It translates in result.
Hook technology: Hook Technique is intercepted and captured and the transmission of monitor event before event transmission to terminal, and can be Some specific events are handled while hooking event.
Gradle: being based on Groovy language, based on Java application, the automation based on DSL grammer is constructed Tool.
So library file: the library write with C or C++ can be called so library file (or native file), file Suffix is " .so ".
Fig. 1 is that the key step of the method according to an embodiment of the invention that AAR packet is handled in Android engineering is shown It is intended to.As shown in Figure 1, the method for handling AAR packet in Android engineering of the embodiment of the present invention includes:
Step S101, the information of the specified AAR packet relied on according to application module in Android engineering, which generates, relies on list; Wherein, the specified AAR coating that the application module relies on is preconfigured to " use, and be packed into compiling result in compiling " Pattern compiler.
In embodiments of the present invention, the specified AAR packet can be regarded as " needing to realize the AAR packet of Provided function ". Wherein, the information of the specified AAR packet may include the information such as the packet name of specified AAR packet, version number.
It should be pointed out that when being compiled packing to Android engineering using the Gradle tool of different editions, institute The pattern compiler for stating " use, and be packed into compiling result in compiling " has different literary styles.For example, at Gradle4.0 editions After this, the corresponding literary style of the pattern compiler is implementation;Before Gradle4.0 version, the pattern compiler pair The literary style answered is compile.
Step S102, multiple compiler tasks that the Android engineering is hooked based on Hook Technique, according to the dependence List removes the specified AAR packet.
In embodiments of the present invention, the application module of Android engineering can be made also to may be implemented by above step The AAR packet of dependence is not finally packed into compiling knot using the AAR packet relied on by the function of " provided AAR ", i.e. compiling duration In fruit, and then hair is melted for Android plug-in unit, technical support is provided.
Fig. 2 is that the key step of the method according to another embodiment of the present invention that AAR packet is handled in Android engineering is shown It is intended to.Wherein, process shown in Fig. 2 can be executed by the inserter tool of independent development.As shown in Fig. 2, the embodiment of the present invention The method of processing AAR packet includes: in Android engineering
Step S201, the information for all AAR packets that application module in Android engineering relies on is parsed, and from the institute The information of specified AAR packet is found out in the information for having AAR packet.
In embodiments of the present invention, the specified AAR packet can be regarded as " needing to realize the AAR packet of Provided function ". Wherein, the information of the specified AAR packet may include the information such as the packet name of specified AAR packet, version number.
Further, before executing process shown in Fig. 2 by inserter tool, the method for the embodiment of the present invention may also include with Lower step: adding configuration information in the configuration file of Android engineering, the configuration file of application module, is existed with statement The inserter tool is added in Android engineering, and the inserter tool is applied in application module;In addition, application module is relied on Specified AAR packet be configured to " compiling when use, and be packed into compiling result in " pattern compiler.
It should be pointed out that when being compiled packing to Android engineering using the Gradle tool of different editions, institute The pattern compiler for stating " use, and be packed into compiling result in compiling " has different literary styles.For example, at Gradle4.0 editions After this, the corresponding literary style of the pattern compiler is implementation;Before Gradle4.0 version, the pattern compiler pair The literary style answered is compile.
Step S202, it is generated according to the information of the specified AAR packet and relies on list.
Wherein, the information for relying on list and preserving specified AAR packet, such as the information such as packet name and version number.
Step S203, hook the task of processing routine global configuration file, with according to the dependence list to described program Global configuration file is deleted.
Illustratively, in the stage of processing routine global configuration file (i.e. AndroidManifest.xml), inserter tool The task of processing routine global configuration file (ProcessManifest) can be hooked by Hook technology, with according to it is described according to Relying list by ProcessManifest task, treated that AndroidManifest.xml is deleted, and then removes specified The AndroidManifest.xml of AAR.
Step S204, the compiler task of the process resource file of the Android engineering is hooked, to arrange according to the dependence Table removes the resource file in specified AAR.
Step S205, the compiler task of the handler file of the Android engineering is hooked, to arrange according to the dependence Table removes the program file in specified AAR packet.
In embodiments of the present invention, by the application module application plug-in tool in Android engineering, and pass through the plug-in unit Tool executes the process flow of step S201 to step S205, and the function of " provided AAR " can be realized in application module, It is compiled in result (such as APK) in compiling duration using the AAR packet of dependence, final be not packed into AAR packet, and then is plug-in unit Exploitation etc. provides strong technical support.
Fig. 3 is that the key step of the method that AAR packet is handled in Android engineering according to yet another embodiment of the invention is shown It is intended to.As shown in figure 3, the method for handling AAR packet in Android engineering of the embodiment of the present invention includes:
Step S301, the information for all AAR packets that application module in Android engineering relies on is parsed, and from the institute The information of specified AAR packet is found out in the information for having AAR packet.
In embodiments of the present invention, the specified AAR packet can be regarded as " needing to realize the AAR packet of Provided function ". Wherein, the information of the specified AAR packet may include the information such as the packet name of specified AAR packet, version number.Further, passing through plug-in unit Before tool executes process shown in Fig. 3, the method for the embodiment of the present invention can comprise the further steps of: matching in Android engineering It sets in the configuration file of file, application module and adds configuration information, which is added in Android engineering with statement, And the inserter tool is applied in application module;In addition, the specified AAR packet that application module relies on is configured to " make in compiling With, and be packed into compiling result in " pattern compiler.
It should be pointed out that when being compiled packing to Android engineering using the Gradle tool of different editions, institute The pattern compiler for stating " use, and be packed into compiling result in compiling " has different literary styles.For example, at Gradle4.0 editions After this, the corresponding literary style of the pattern compiler is implementation;Before Gradle4.0 version, the pattern compiler pair The literary style answered is compile.
Step S302, it is generated according to the information of the specified AAR packet and relies on list.
Wherein, the information for relying on list and preserving specified AAR packet, such as the information such as packet name and version number.
Step S303, hook the task of processing routine global configuration file, with according to the dependence list to described program Global configuration file is deleted.
Illustratively, in the stage of processing routine global configuration file (i.e. AndroidManifest.xml), inserter tool ProcessManifest task can be hooked, by Hook technology to appoint ProcessManifest according to the dependence list Treated that AndroidManifest.xml is deleted for business, and then removes the AndroidManifest.xml of specified AAR.
Step S304, the compiler task of processing res resource file is hooked, to remove specified AAR according to the dependence list Res resource file in packet.
Illustratively, in the processing res resource stage, inserter tool can be hooked by Hook technology ProcessResources task is handled with the resources-debug.ap file obtained to processing.Specifically, should Treatment process includes:
1) resources-debug.ap file is unziped it.
2) the temporary file merger.xml of the res resource generated in the dependence list and compilation process obtained before The list of file generated first resource and Secondary resource list.Wherein, first resource list includes: the res resource of specified AAR packet Information (such as ID, res resource file storage position of res resource file etc.);Secondary resource list includes: to remove described specify The information of remaining res resource except the res resource of AAR packet.
3) the resources-debug.ap file after decompression is traversed according to first resource list, by specified AAR The res resource file of packet is deleted.
4) arranged in sequence is carried out to the mark of remaining res resource file, res is then updated according to the result of arranged in sequence Resource index file (resources.arsc file).
5) the resources-debug.ap file after processing is repacked, and covers original.
In embodiments of the present invention, by journey processed above, the res resource file of specified AAR packet is not removed only, And have updated res resource index file.
Step S305, arranged in sequence is carried out to the mark of remaining res resource file, then according to the result of arranged in sequence Update res the Resources list file.
In embodiments of the present invention, by updating res the Resources list file (R.java file), convenient for being subsequently generated R.class file is visited so that modified application program can be identified according to res resource file correct in R.class file Ask resource.
Step S306, the compiler task of processing assets resource file is hooked, it is specified to be removed according to the dependence list Assets resource file in AAR packet.
In one example, in the processing assets resource file stage, inserter tool can be hooked by Hook technology MergeAssets task, and the file of the assets resource after merging is handled as follows: it is arranged according to the dependence obtained before The temporary file merger.xml file generated information resources list of the assets resource generated in table and compilation process, wherein Information resources list include: the assets resource of specified AAR packet information (such as assets resource file filename, The storage position etc. of assets resource file);According to information resources list to the file of the assets resource after the merging into Row traversal, the assets resource file of specified AAR packet is deleted.
In another example, in the processing assets resource file stage, inserter tool can be hooked by Hook technology MergeAssets task, and be handled as follows: the resource of MergeAssets task is inputted (inputDirectorySets) it modifies, specifically by the parameter of the assets resource file in specified AAR from the money It is deleted in the input of source, with realization " not including the assets resource of the specified AAR packet in the assets resource file after merging " This technical effect.
Step S307, the compiler task of processing class file is hooked, to remove in specified AAR packet according to the dependence list Class file.
Illustratively, in the processing class file stage, inserter tool can hook the volume of processing class file by Hook technology Task is translated, is deleted the class file in specified AAR packet with the list that relies on obtained before.Wherein, the class file includes JAR packet.Further, since there may be the assets resource file (assets of i.e. specified AAR packet that needs remove in JAR packet Resource file), it therefore, can also be handled as follows: remove corresponding main.jar file according to list is relied on;Or it is right MergerJavaRes task is handled, according to the assets resource relied in list removal JAR packet.
Step S308, the compiler task of processing so library file is hooked, to remove in specified AAR packet according to the dependence list So library file.
In one example, in processing so library file stage, inserter tool can hook processing so library text by Hook technology The custom task (Transform task) of part, with before obtained dependence list by so library file in specified AAR packet It deletes.Alternatively, it is also possible to merge JniLibs document stage, MergerJniLibs task is hooked by Hook technology, with root So library file in specified AAR packet is removed according to the dependence list.
In embodiments of the present invention, by above step, the application module of Android engineering is allowed to pass through plug-in unit work Tool realizes the function of " provided AAR ", i.e. AAR packet is not packed into compiling result finally by compiling duration using AAR packet, into And hair is melted for Android plug-in unit and provides technical support.
It should be pointed out that the title and Gradle of dependent compilation task are related with the continuous development of android system Interface may change.In the case where not influencing present invention implementation, those skilled in the art can according to need change and insert The title for the compiler task that part tool hooks and the relevant interface of Gradle.
Fig. 4 is that the main modular of the device according to an embodiment of the invention that AAR packet is handled in Android engineering is shown It is intended to.As shown in figure 4, the device 400 of AAR packet that handles in Android engineering of the embodiment of the present invention includes: generation module 401, processing module 402.
Generation module 401, for according in Android engineering application module rely on specified AAR packet information generation according to Rely list;Wherein, the specified AAR coating that the application module relies on, which is preconfigured to, " to be used in compiling, and is packed into compiling As a result in " pattern compiler.
In embodiments of the present invention, the specified AAR packet can be regarded as " needing to realize the AAR packet of Provided function ". Wherein, the information of the specified AAR packet may include the information such as the packet name of specified AAR packet, version number.
It should be pointed out that when being compiled packing to Android engineering using the Gradle tool of different editions, institute The pattern compiler for stating " use, and be packed into compiling result in compiling " has different literary styles.For example, at Gradle4.0 editions After this, the corresponding literary style of the pattern compiler is implementation;Before Gradle4.0 version, the pattern compiler pair The literary style answered is compile.
Processing module 402, for hooking multiple compiler tasks of the Android engineering based on Hook Technique, with basis The dependence list removes the specified AAR packet.
In embodiments of the present invention, the application module of Android engineering can be made also to may be implemented by apparatus above The AAR packet of dependence is not finally packed into compiling knot using the AAR packet relied on by the function of " provided AAR ", i.e. compiling duration In fruit, and then hair is melted for Android plug-in unit, technical support is provided.
Fig. 5 is that the main modular of the device according to another embodiment of the present invention that AAR packet is handled in Android engineering is shown It is intended to.As shown in figure 5, the device 500 of AAR packet that handles in Android engineering of the embodiment of the present invention includes: parsing module 501, generation module 502, processing module 503.
Parsing module 501, for parsing the information for all AAR packets that application module in Android engineering relies on, and from The information of specified AAR packet is found out in the information of all AAR packets.
In embodiments of the present invention, the specified AAR packet can be regarded as " needing to realize the AAR packet of Provided function ". Wherein, the information of the specified AAR packet may include the information such as the packet name of specified AAR packet, version number.
When it is implemented, also needing to proceed as follows: in the configuration of Android engineering before calling parsing module 501 File, application module configuration file in add configuration information, to state the adding set 500 in Android engineering, and answering With application apparatus 500 in module;In addition, the specified AAR packet that application module relies on is configured to " use, and be packaged in compiling To compiling result in " pattern compiler.
It should be pointed out that when being compiled packing to Android engineering using the Gradle tool of different editions, institute The pattern compiler for stating " use, and be packed into compiling result in compiling " has different literary styles.For example, at Gradle4.0 editions After this, the corresponding literary style of the pattern compiler is implementation;Before Gradle4.0 version, the pattern compiler pair The literary style answered is compile.
Generation module 502 relies on list for generating according to the information of the specified AAR packet.Wherein, the dependence list Preserve the information of specified AAR packet, such as the information such as packet name and version number.
Processing module 503 includes: Manifest document handling unit 5031, resource file processing unit 5032 and program text Part processing unit 5033.
Manifest document handling unit 5031, for hooking processing Manifest file The task of (AndroidManifest.xml, or be program global configuration file), with according to the dependence list to described Manifest file is deleted.
Illustratively, in the stage of processing Manifest file, Manifest document handling unit 5031 can pass through Hook technology hooks the task of ProcessManifest, to be handled ProcessManifest task according to the dependence list Manifest file afterwards is deleted, and then removes the Manifest file of specified AAR.
Resource file processing unit 5032, the compiler task of the process resource file for hooking the Android engineering, To remove the resource file in specified AAR according to the dependence list.
Illustratively, the resource file includes res resource file and assets resource file.In this example, resource The executable following operation of document handling unit 5032:
The task of processing res resource file is hooked in operation one, resource file processing unit 5032, to be arranged according to the dependence Table removes the res resource file in specified AAR packet.
Operation two, resource file processing unit 5032 carry out arranged in sequence to the mark of remaining res resource file, then Res the Resources list file is updated according to the result of arranged in sequence.
The task of processing assets resource file is hooked in operation three, resource file processing unit 5032, with according to it is described according to List is relied to remove the assets resource file in specified AAR packet.
The operation one specifically how is executed about resource file processing unit 5032 to operation three, can refer to shown in Fig. 3 To the related description of step S304 to S306 in embodiment, details are not described herein.
Program file processing unit 5033, the compiler task of the handler file for hooking the Android engineering, To remove the program file in specified AAR packet according to the dependence list.
Illustratively, described program file includes class file and so library file.In this example, program file processing unit 5033 executable following operations:
Operation a, program file processing unit 5033 hook the task of processing class file, to be removed according to the dependence list Class file in specified AAR packet.
Operation b, program file processing unit 5033 hook the task of processing so library file, to be gone according to the dependence list Except so library file in specified AAR packet.
The operation a how is specifically executed to b is operated about program file processing unit 5033, can refer to real shown in Fig. 3 It applies to the related description of step S307 to S308 in example, details are not described herein.
The device of the embodiment of the present invention makes the application module of Android engineering that the function of " provided AAR " may be implemented Can, i.e. AAR packet is not packed into compiling result finally by compiling duration using AAR packet, and then is melted hair for Android plug-in unit and mentioned Technical support is supplied.
Fig. 6 show the method that can handle AAR packet in Android engineering using the embodiment of the present invention or The exemplary system architecture 600 of the device of AAR packet is handled in Android engineering.
As shown in fig. 6, system architecture 600 may include terminal device 601,602,603, network 604 and server 605. Network 604 between terminal device 601,602,603 and server 605 to provide the medium of communication link.Network 604 can be with Including various connection types, such as wired, wireless communication link or fiber optic cables etc..
User can be used terminal device 601,602,603 and be interacted by network 604 with server 605, to receive or send out Send message etc..Terminal device 601,602,603 can be the various electronic equipments with display screen and supported web page browsing, packet Include but be not limited to smart phone, tablet computer, pocket computer on knee and desktop computer etc..
Server 605 can be to provide the server of various services, such as utilize terminal device 601,602,603 to user Used software development class application provides the back-stage management server supported.Back-stage management server can be to the use received Family operation requests etc. carry out the processing such as analyzing, and processing result is fed back to terminal device.
It should be noted that the embodiment of the present invention provided by Android engineering handle AAR packet method generally by Server 605 executes, and correspondingly, the square law device that AAR packet is handled in Android engineering is generally positioned in server 605.
It should be understood that the number of terminal device, network and server in Fig. 6 is only schematical.According to realization need It wants, can have any number of terminal device, network and server.
Fig. 7 shows the structural representation for being suitable for the computer system 700 for the electronic equipment for being used to realize the embodiment of the present invention Figure.Electronic equipment shown in Fig. 7 is only an example, should not function to the embodiment of the present invention and use scope bring it is any Limitation.
As shown in fig. 7, computer system 700 includes central processing unit (CPU) 701, it can be read-only according to being stored in Program in memory (ROM) 702 or be loaded into the program in random access storage device (RAM) 703 from storage section 708 and Execute various movements appropriate and processing.In RAM 703, also it is stored with system 700 and operates required various programs and data. CPU 701, ROM 702 and RAM 703 are connected with each other by bus 704.Input/output (I/O) interface 705 is also connected to always Line 704.
I/O interface 705 is connected to lower component: the importation 706 including keyboard, mouse etc.;It is penetrated including such as cathode The output par, c 707 of spool (CRT), liquid crystal display (LCD) etc. and loudspeaker etc.;Storage section 708 including hard disk etc.; And the communications portion 709 of the network interface card including LAN card, modem etc..Communications portion 709 via such as because The network of spy's net executes communication process.Driver 710 is also connected to I/O interface 705 as needed.Detachable media 711, such as Disk, CD, magneto-optic disk, semiconductor memory etc. are mounted on as needed on driver 710, in order to read from thereon Computer program be mounted into storage section 708 as needed.
Particularly, disclosed embodiment, the process described above with reference to flow chart may be implemented as counting according to the present invention Calculation machine software program.For example, embodiment disclosed by the invention includes a kind of computer program product comprising be carried on computer Computer program on readable medium, the computer program include the program code for method shown in execution flow chart.In In such embodiment, which can be downloaded and installed from network by communications portion 709, and/or from can Medium 711 is dismantled to be mounted.When the computer program is executed by central processing unit (CPU) 701, system of the invention is executed The above-mentioned function of middle restriction.
It should be noted that computer-readable medium shown in the present invention can be computer-readable signal media or meter Calculation machine readable storage medium storing program for executing either the two any combination.Computer readable storage medium for example can be --- but not Be limited to --- electricity, magnetic, optical, electromagnetic, infrared ray or semiconductor system, device or device, or any above combination.Meter The more specific example of calculation machine readable storage medium storing program for executing can include but is not limited to: have the electrical connection, just of one or more conducting wires Taking formula computer disk, hard disk, random access storage device (RAM), read-only memory (ROM), erasable type may be programmed read-only storage Device (EPROM or flash memory), optical fiber, portable compact disc read-only memory (CD-ROM), light storage device, magnetic memory device, Or above-mentioned any appropriate combination.In the present invention, computer readable storage medium can be it is any include or storage journey The tangible medium of sequence, the program can be commanded execution system, device or device use or in connection.And at this In invention, computer-readable signal media may include in a base band or as carrier wave a part propagate data-signal, Wherein carry computer-readable program code.The data-signal of this propagation can take various forms, including but unlimited In electromagnetic signal, optical signal or above-mentioned any appropriate combination.Computer-readable signal media can also be that computer can Any computer-readable medium other than storage medium is read, which can send, propagates or transmit and be used for By the use of instruction execution system, device or device or program in connection.Include on computer-readable medium Program code can transmit with any suitable medium, including but not limited to: wireless, electric wire, optical cable, RF etc. are above-mentioned Any appropriate combination.
Flow chart and block diagram in attached drawing are illustrated according to the system of various embodiments of the invention, method and computer journey The architecture, function and operation in the cards of sequence product.In this regard, each box in flowchart or block diagram can generation A part of one module, program segment or code of table, a part of above-mentioned module, program segment or code include one or more Executable instruction for implementing the specified logical function.It should also be noted that in some implementations as replacements, institute in box The function of mark can also occur in a different order than that indicated in the drawings.For example, two boxes succeedingly indicated are practical On can be basically executed in parallel, they can also be executed in the opposite order sometimes, and this depends on the function involved.Also it wants It is noted that the combination of each box in block diagram or flow chart and the box in block diagram or flow chart, can use and execute rule The dedicated hardware based systems of fixed functions or operations is realized, or can use the group of specialized hardware and computer instruction It closes to realize.
Being described in module involved in the embodiment of the present invention can be realized by way of software, can also be by hard The mode of part is realized.Described module also can be set in the processor, for example, can be described as: a kind of processor packet Include generation module and processing module.Wherein, the title of these modules does not constitute the limit to the module itself under certain conditions It is fixed, for example, generation module is also described as " generating the module for relying on list ".
As on the other hand, the present invention also provides a kind of computer-readable medium, which be can be Included in equipment described in above-described embodiment;It is also possible to individualism, and without in the supplying equipment.Above-mentioned calculating Machine readable medium carries one or more program, when said one or multiple programs are executed by the equipment, makes Obtain the equipment and execute following below scheme: the information of the specified AAR packet relied on according to application module in Android engineering is generated to rely on and be arranged Table;Wherein, the specified AAR coating that the application module relies on, which is preconfigured to, " to be used in compiling, and is packed into compiling result In " pattern compiler;Multiple compiler tasks of the Android engineering are hooked, based on Hook Technique to arrange according to the dependence Table removes the specified AAR packet.
Above-mentioned specific embodiment, does not constitute a limitation on the scope of protection of the present invention.Those skilled in the art should be bright It is white, design requirement and other factors are depended on, various modifications, combination, sub-portfolio and substitution can occur.It is any Made modifications, equivalent substitutions and improvements etc. within the spirit and principles in the present invention, should be included in the scope of the present invention Within.

Claims (16)

1. a kind of method for handling AAR packet in Android engineering, which is characterized in that the described method includes:
The information of the specified AAR packet relied on according to application module in Android engineering, which generates, relies on list;Wherein, the application The specified AAR coating that module relies on is preconfigured to the pattern compiler of " use, and be packed into compiling result in compiling ";
Multiple compiler tasks of the Android engineering are hooked based on Hook Technique, according to dependence list removal Specified AAR packet.
2. the method according to claim 1, wherein the method also includes:
The step for relying on list is generated in the information for executing the specified AAR packet relied on according to application module in Android engineering Before rapid, the information for all AAR packets that application module relies in Android engineering is parsed, and from the letter of all AAR packets The information of the specified AAR packet is found out in breath.
3. the method according to claim 1, wherein described hook the Android engineering based on Hook Technique Multiple compiler tasks, to remove specified AAR packet according to dependence list the step of includes: to hook the Android engineering Process resource file compiler task, to remove the resource file in specified AAR packet according to the dependence list;It hooks described The compiler task of the handler file of Android engineering, to remove the program text in specified AAR packet according to the dependence list Part.
4. according to the method described in claim 3, it is characterized in that, described hook the Android engineering based on Hook Technique Multiple compiler tasks, the step of to remove specified AAR packet according to the dependence list further include: hook the processing routine overall situation and match The task of file is set, to delete according to the dependence list described program global configuration file.
5. according to the method described in claim 3, it is characterized in that, the resource file includes: res resource file and assets Resource file;The compiler task of the process resource file for hooking the Android engineering, to be gone according to the dependence list Except the step of resource file in specified AAR packet includes: the hooking processing res resource file of the task, according to the dependence list Remove the res resource file in specified AAR packet;The hooking processing assets resource file of the task, goes according to the dependence list Except the assets resource file in specified AAR packet.
6. according to the method described in claim 5, it is characterized in that, the method also includes:
After described the step of removing the res resource file in specified AAR packet according to the dependence list, to remaining res The mark of resource file carries out arranged in sequence, then updates res the Resources list file according to the result of arranged in sequence.
7. according to the method described in claim 3, it is characterized in that, described program file includes: class file and so library file;Institute The compiler task for hooking the handler file of the Android engineering is stated, to remove specified AAR packet according to the dependence list In program file the step of include: hook processing class file task, with according to the dependences list removal specify AAR packet in Class file;The task of processing so library file is hooked, to remove so library file in specified AAR packet according to the dependence list.
8. a kind of device for handling AAR packet in Android engineering, which is characterized in that described device includes:
Generation module, the information of the specified AAR packet for being relied on according to application module in Android engineering, which generates, relies on list; Wherein, the pattern compiler for the specified AAR packet that the application module relies on, which is preconfigured to be, " to be used in compiling, and is packed into Compile result in " mode;
Processing module, for hooking multiple compiler tasks of the Android engineering based on Hook Technique, according to the dependence List removes the specified AAR packet.
9. device according to claim 8, which is characterized in that described device further include:
Parsing module, for parsing the information for all AAR packets that application module in Android engineering relies on, and from the institute The information of the specified AAR packet is found out in the information for having AAR packet.
10. device according to claim 8, which is characterized in that the processing module is hooked described based on Hook Technique Multiple compiler tasks of Android engineering include: the processing module hook to remove specified AAR packet according to the dependence list The compiler task of the process resource file of Android engineering is stated in residence, to be removed in specified AAR packet according to the dependence list Resource file;The processing module hooks the compiler task of the handler file of the Android engineering, with according to it is described according to List is relied to remove the program file in specified AAR packet.
11. device according to claim 10, which is characterized in that the processing module is hooked described based on Hook Technique Multiple compiler tasks of Android engineering, to remove specified AAR packet according to the dependence list further include: the processing module The task of processing routine global configuration file is hooked, to delete according to the dependence list to described program global configuration file Subtract.
12. device according to claim 10, which is characterized in that the resource file includes: res resource file and Assets resource file;The processing module hooks the compiler task of the process resource file of the Android engineering, with basis The resource file relied in the specified AAR packet of list removal includes: the processing module hooks appointing for processing res resource file Business removes the res resource file in specified AAR packet according to the dependence list;The processing module hooks processing assets money The task of source file, to remove the assets resource file in specified AAR packet according to the dependence list.
13. device according to claim 12, which is characterized in that the processing module is also used to: executing the basis After the operation for relying on the res resource file in the specified AAR packet of list removal, to the mark of remaining res resource file Arranged in sequence is carried out, res the Resources list file is then updated according to the result of arranged in sequence.
14. device according to claim 10, which is characterized in that described program file includes: class file and so library file; The processing module hooks the compiler task of the handler file of the Android engineering, to be gone according to the dependence list Except the program file in specified AAR packet includes: the task that the processing module hooks processing class file, to be arranged according to the dependence Table removes the class file in specified AAR packet;The processing module hooks the task of processing so library file, to be arranged according to the dependence Table removes so library file in specified AAR packet.
15. a kind of electronic equipment characterized by comprising
One or more processors;
Storage device, for storing one or more programs,
When one or more of programs are executed by one or more of processors, so that one or more of processors are real The now method as described in any in claim 1 to 7.
16. a kind of computer-readable medium, is stored thereon with computer program, which is characterized in that described program is held by processor The method as described in any in claim 1 to 7 is realized when row.
CN201810353103.4A 2018-04-19 2018-04-19 Method and device for processing AAR package in Android engineering Active CN110389762B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810353103.4A CN110389762B (en) 2018-04-19 2018-04-19 Method and device for processing AAR package in Android engineering

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810353103.4A CN110389762B (en) 2018-04-19 2018-04-19 Method and device for processing AAR package in Android engineering

Publications (2)

Publication Number Publication Date
CN110389762A true CN110389762A (en) 2019-10-29
CN110389762B CN110389762B (en) 2024-06-18

Family

ID=68282827

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810353103.4A Active CN110389762B (en) 2018-04-19 2018-04-19 Method and device for processing AAR package in Android engineering

Country Status (1)

Country Link
CN (1) CN110389762B (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111078199A (en) * 2019-11-28 2020-04-28 福建新大陆支付技术有限公司 Implementation scheme for Android middleware customized component platform
CN111290738A (en) * 2020-01-21 2020-06-16 北京字节跳动网络技术有限公司 Resource processing method, device and equipment of application program and storage medium
CN111367512A (en) * 2020-03-16 2020-07-03 北京五八信息技术有限公司 Method and device for creating Android library module dependency relationship in application development
CN112416372A (en) * 2020-11-16 2021-02-26 五八同城信息技术有限公司 AAR modification construction method and device, electronic equipment and storage medium
CN112748946A (en) * 2019-10-30 2021-05-04 腾讯科技(深圳)有限公司 Application program installation file generation method and device, computing equipment and storage medium
CN112882718A (en) * 2021-02-26 2021-06-01 百果园技术(新加坡)有限公司 Compiling processing method, device, equipment and storage medium
CN113076146A (en) * 2021-03-09 2021-07-06 北京一亩田新农网络科技有限公司 Dynamic APK loading method, device, system and medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103870310A (en) * 2014-02-18 2014-06-18 小米科技有限责任公司 Program compilation method and relevant device
CN106528258A (en) * 2016-10-28 2017-03-22 武汉斗鱼网络科技有限公司 Method and system for improving compiling speed of Android project
CN106648559A (en) * 2015-10-28 2017-05-10 广东电网有限责任公司佛山供电局 Android application pluggable development system and method
CN106886394A (en) * 2015-12-15 2017-06-23 五八同城信息技术有限公司 application program packaging method and device
CN107562429A (en) * 2017-08-25 2018-01-09 中国科学院软件研究所 A kind of android system static division method based on compiling rule

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103870310A (en) * 2014-02-18 2014-06-18 小米科技有限责任公司 Program compilation method and relevant device
CN106648559A (en) * 2015-10-28 2017-05-10 广东电网有限责任公司佛山供电局 Android application pluggable development system and method
CN106886394A (en) * 2015-12-15 2017-06-23 五八同城信息技术有限公司 application program packaging method and device
CN106528258A (en) * 2016-10-28 2017-03-22 武汉斗鱼网络科技有限公司 Method and system for improving compiling speed of Android project
CN107562429A (en) * 2017-08-25 2018-01-09 中国科学院软件研究所 A kind of android system static division method based on compiling rule

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
OMNI-SPACE: ""Android application 中使用 provided aar 并没有那么简单"", Retrieved from the Internet <URL:https://blog.csdn.net/omnispace/article/details/79803104> *

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112748946A (en) * 2019-10-30 2021-05-04 腾讯科技(深圳)有限公司 Application program installation file generation method and device, computing equipment and storage medium
CN112748946B (en) * 2019-10-30 2023-11-24 腾讯科技(深圳)有限公司 Application program installation file generation method and device, computing equipment and storage medium
CN111078199A (en) * 2019-11-28 2020-04-28 福建新大陆支付技术有限公司 Implementation scheme for Android middleware customized component platform
CN111290738A (en) * 2020-01-21 2020-06-16 北京字节跳动网络技术有限公司 Resource processing method, device and equipment of application program and storage medium
CN111367512A (en) * 2020-03-16 2020-07-03 北京五八信息技术有限公司 Method and device for creating Android library module dependency relationship in application development
CN112328241A (en) * 2020-03-16 2021-02-05 北京五八信息技术有限公司 Method and device for creating Android library module dependency relationship in application development
CN112328241B (en) * 2020-03-16 2023-12-12 北京五八信息技术有限公司 Method and device for creating Android library module dependency relationship in application program development
CN112416372A (en) * 2020-11-16 2021-02-26 五八同城信息技术有限公司 AAR modification construction method and device, electronic equipment and storage medium
CN112882718A (en) * 2021-02-26 2021-06-01 百果园技术(新加坡)有限公司 Compiling processing method, device, equipment and storage medium
CN112882718B (en) * 2021-02-26 2024-03-01 百果园技术(新加坡)有限公司 Compiling processing method, device, equipment and storage medium
CN113076146A (en) * 2021-03-09 2021-07-06 北京一亩田新农网络科技有限公司 Dynamic APK loading method, device, system and medium
CN113076146B (en) * 2021-03-09 2024-06-07 北京一亩田新农网络科技有限公司 Dynamic APK loading method, device, system and medium

Also Published As

Publication number Publication date
CN110389762B (en) 2024-06-18

Similar Documents

Publication Publication Date Title
CN110389762A (en) The method and apparatus of AAR packet are handled in Android engineering
CN109542445A (en) A kind of method and apparatus that Android plug-in unit melts hair
CN105302563B (en) The plug-in unit method and system of mobile application service
CN106843976B (en) Method and apparatus for generating image file
CN108920222A (en) A kind of method and device for business processing of rule-based engine
CN108897612A (en) Route the method and apparatus jumped
CN104049991A (en) Method and system for converting network applications into mobile applications
CN110209662A (en) A kind of method and apparatus of automation load data
CN109032620A (en) The configuration file generation method and device of application program
CN109766127A (en) Method for updating application version information
CN107463406A (en) Issue the method and electronic equipment of Mobile solution
CN109213536A (en) Resource exhibition method, resource show configuration method, device and the equipment of class control
CN113407165B (en) SDK generation and self-upgrade method, device, readable medium and equipment
CN112835568A (en) Project construction method and device
CN107678755B (en) Installation package packaging method and device, electronic equipment and computer readable medium
CN107608672B (en) UI module manager, UI module management method and system
CN108845864A (en) A kind of JVM rubbish recovering method and device based on spring frame
CN109683992A (en) Method and apparatus for managing object
CN105933887B (en) Apply the adaptation method and device between different dual-card intelligent mobile phones
CN109901934B (en) Method and device for generating interface help document
CN111767498A (en) Method and device for realizing file information sharing
CN116974716A (en) Scheduling task issuing method and device, electronic equipment and storage medium
CN110399187A (en) A kind for the treatment of method and apparatus of language resource
CN110213333A (en) Task processing method, device, electronic equipment and computer-readable medium
CN109933727A (en) User&#39;s portrait generation method and system, user&#39;s portrait application method and system

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