Method, device, terminal device and medium for generating Android application package
By obtaining resource information and original text files, determining the view node tree and translation information, and generating bytecode files, the problem of time-consuming loading of Android application packages is solved, the APK loading time is shortened, and the development efficiency and user experience is improved. .
Patent Information
- Application Number
- CN202010583905.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-23
- Publication Date
- 2025-01-17
- Estimated Expiration
- 2040-07-17
AI Technical Summary
In the prior art, the Android application package (APK) generated based on XML files takes a long time to load, which affects development efficiency and user experience.
By obtaining resource information and original text files, determining the view node tree and translation information, generating bytecode files, and generating Android application packages based on bytecode files, avoiding the process of loading XML files, thereby reducing the loading time of APK.
It effectively solves the problem of time-consuming APK loading, significantly reduces loading time, and improves development efficiency and user experience.
Smart Images

Figure CN113835718B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present disclosure relate to the field of computer technology, and in particular to a method, apparatus, terminal device, and medium for generating an Android application package. Background Art
[0002] User interface design is an important part of application development. For example, the Android system uses Extensible Markup Language (XML) as a programming interface. Developers generate user interfaces by writing XML files to complete the generation of Android application packages (APK).
[0003] However, there is a time-consuming technical problem in loading APK generated based on XML files. Summary of the invention
[0004] The disclosed embodiments provide a method, apparatus, terminal device, and medium for generating an Android application package, which effectively solves the technical problem of time-consuming loading of an APK generated based on an XML file.
[0005] In a first aspect, an embodiment of the present disclosure provides a method for generating an Android application package, comprising:
[0006] Get resource information and original text files;
[0007] Determine a view node tree and corresponding translation information corresponding to the resource information;
[0008] Generate a bytecode file based on the original text file, the view node tree and the translation information;
[0009] An Android application package is generated based on the bytecode file.
[0010] In a second aspect, the present disclosure also provides a device for generating an Android application package, including:
[0011] Acquisition module, used to obtain resource information and original text files;
[0012] A determination module, used to determine the view node tree corresponding to the resource information and the corresponding translation information;
[0013] A first generating module, used for generating a bytecode file based on the original text file, the view node tree and the translation information;
[0014] The second generating module is used to generate an Android application package based on the bytecode file.
[0015] In a third aspect, an embodiment of the present disclosure further provides a terminal device, including:
[0016] one or more processing devices;
[0017] A storage device for storing one or more programs;
[0018] The one or more programs are executed by the one or more processing devices, so that the one or more processing devices implement the method provided by the embodiment of the present disclosure.
[0019] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable medium having a computer program stored thereon, which implements the method provided by the embodiment of the present disclosure when the program is executed by a processing device.
[0020] The disclosed embodiment provides a method, apparatus, terminal device and medium for generating an Android application package, firstly obtaining resource information and an original text file; then determining a view node tree and corresponding translation information corresponding to the resource information; secondly generating a bytecode file based on the original text file, the view node tree and the translation information; and finally generating an Android application package based on the bytecode file. The above technical solution effectively solves the technical problem of time-consuming loading of an APK generated based on an XML file, and reduces the time for loading the APK. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 A flowchart of a method for generating an Android application package provided in the first embodiment of the present disclosure;
[0022] Figure 2 A flowchart of a method for generating an Android application package provided in Embodiment 2 of the present disclosure;
[0023] Figure 2a A flowchart of another method for generating an Android application package provided in the second embodiment of the present disclosure;
[0024] Figure 2b A schematic diagram of the architecture of an Android application package generation method provided in Embodiment 2 of the present disclosure;
[0025] Figure 3 A schematic diagram of the structure of a device for generating an Android application package provided in Embodiment 3 of the present disclosure;
[0026] Figure 4 A schematic diagram of the structure of a terminal device provided in Embodiment 4 of the present disclosure. DETAILED DESCRIPTION
[0027] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0028] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0029] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0030] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0031] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0032] In the following embodiments, each embodiment provides optional features and examples at the same time, and the various features recorded in the embodiments can be combined to form multiple optional solutions, and each numbered embodiment should not be regarded as only one technical solution. In addition, the embodiments in this disclosure and the features in the embodiments can be combined with each other without conflict.
[0033] Embodiment 1
[0034] Figure 1 A flowchart of a method for generating an Android application package is provided for the first embodiment of the present disclosure. The method is applicable to the case of generating an Android APK. The method can be executed by a device for generating an Android application package, wherein the device can be implemented by software and / or hardware and is generally integrated on a terminal device. In this embodiment, the terminal device includes but is not limited to: a computer.
[0035] like Figure 1As shown, a method for generating an Android application package provided in Embodiment 1 of the present disclosure includes the following steps:
[0036] S110, obtaining resource information and original text files.
[0037] In this embodiment, resource information can be considered as information about resources included in an XML file, and the specific content of the resource information is not limited here. Different APKs may correspond to different resource information. Exemplarily, resource information includes but is not limited to XML layout resources, XML control attribute resources, XML component attribute resources, and XML class attribute resources.
[0038] The original text file can be considered as a class file in the XML file. Based on the original text file, a target text file in code form can be generated.
[0039] The method described in the present disclosure can be considered as a gradle plug-in. The path of the original text file can be directly passed into the resource manager of the plug-in. The path of the resource information can be obtained by the resource manager through a hook function, that is, a Hook method, thereby obtaining the resource information.
[0040] It should be noted that different versions of Gradle have different Hook methods, which can be determined based on the Gradle version and are not limited here.
[0041] S120: Determine the view node tree corresponding to the resource information and the corresponding translation information.
[0042] The view node tree can be considered as a view of a tree-like layout generated based on the layout resource. The translation information can be considered as the information required to translate the XML file into a bytecode file in code form.
[0043] After obtaining the resource information, this step can determine the view node tree and translation information corresponding to the resource information. For example, the view node tree and translation information are determined by a processor. Specifically, this step can determine the corresponding view node tree and translation information based on different resources included in the resource information, such as determining the view node tree based on XML layout resources, and determining the translation information based on attribute resources, that is, the information required for translation, such as the macro definition information of each resource.
[0044] S130: Generate a bytecode file based on the original text file, the view node tree and the translation information.
[0045] The bytecode file can be considered as a code in bytecode form. The bytecode file can be generated by a bytecode generator based on a target text file.
[0046] After determining the view node tree and translation information, this step can modify the original text file based on the XML attribute of each node in the view node tree and the translation information of the XML attribute to obtain the corresponding target text file, and then generate a bytecode file based on the target text file.
[0047] When modifying the original text file, you can obtain the content corresponding to the custom XML attribute to modify the original text file.
[0048] S140: Generate an Android application package based on the bytecode file.
[0049] After the bytecode file is generated, this step can complete the generation of the installation APK based on the bytecode file. For example, the process of generating DEX is completed based on the bytecode file. The generated Android APK can include a bytecode file. When loading the APK, there is no need to load the XML file. Loading the bytecode file can effectively solve the technical problem of time-consuming loading of the XML file.
[0050] When generating an Android application package, the HookAndInflater interface can be used unconsciously to generate an Android application package based on the bytecode file; the bytecode file can also be acquired consciously to generate the Android application package. The above technical means can solve the problem of XML file errors caused by problems with the original code. The present invention replaces the system logic to generate APK directly based on the bytecode file.
[0051] The first embodiment of the present disclosure provides a method for generating an Android application package, which first obtains resource information and an original text file; then determines a view node tree and corresponding translation information corresponding to the resource information; secondly generates a bytecode file based on the original text file, the view node tree and the translation information; and finally generates an Android application package based on the bytecode file. The above method effectively solves the technical problem of time-consuming loading of an APK generated based on an XML file, and reduces the time for loading the APK.
[0052] Embodiment 2
[0053] Figure 2 The following is a flow chart of a method for generating an Android application package provided in the second embodiment of the present disclosure. The second embodiment is specific based on the various optional solutions in the above embodiments. In this embodiment, resource information is obtained, specifically including:
[0054] Determine the resource information required to generate the user interface;
[0055] Get the required resource information through the hook function.
[0056] Furthermore, this embodiment will also obtain the original text file, specifically including:
[0057] Get the path information of the original text file;
[0058] The original text file is read from the path information.
[0059] Based on the above optimization, the view node tree and the corresponding translation information corresponding to the resource information will be determined, including:
[0060] Determine a corresponding view node tree based on the layout resource of the extensible markup language XML included in the resource information;
[0061] Based on the attribute resources included in the resource information, translation information corresponding to the resource information is determined.
[0062] Further, based on the original text file, the view node tree and the translation information, a bytecode file is generated, specifically including:
[0063] Traversing each node in the view node tree, modifying the original text file based on the translation information corresponding to each node, and obtaining a target text file;
[0064] A bytecode file is generated based on the target text file.
[0065] For details not yet provided in this embodiment, please refer to Embodiment 1.
[0066] like Figure 2 As shown, a method for generating an Android application package provided in Embodiment 2 of the present disclosure includes the following steps:
[0067] S210: Determine resource information required to generate a user interface.
[0068] Different application programs require different resource information. In this step, the resource information required by the user interface can be first determined. The required resource information can be limited according to actual conditions and is not limited here.
[0069] This step can predetermine the required resource information before generating the APK, and then obtain the resource information.
[0070] S220. Obtain required resource information through a hook function.
[0071] After determining the required resource information, this step can obtain the required resource information through a hook function. Specifically, this step can hook the method corresponding to the resource information to obtain the resource information.
[0072] S230: Obtain path information of the original text file.
[0073] When obtaining the original text file, this step may first obtain the path information of the original text file, such as obtaining the path information of the original text file from a gradle component, and then obtain the original text file based on the path information.
[0074] S240: Read the original text file from the path information.
[0075] S250. Determine a corresponding view node tree based on the layout resource of the extensible markup language XML included in the resource information.
[0076] When determining the view node tree and translation information, this step can determine the view node tree based on the XML layout resource included in the resource information, that is, the XML-layout resource. For example, the XML layout resource is transcribed into a view node tree in code form. The corresponding relationship during the transcription can be preset and is not limited here.
[0077] Each node in the view node tree can be a view, that is, VIEW.
[0078] S260: Determine translation information corresponding to the resource information based on the attribute resources included in the resource information.
[0079] The attribute resource may be a resource that represents an attribute. In one embodiment, the attribute resource includes an XML control attribute resource, an XML component attribute resource, and a class attribute resource. The control attribute resource may represent the attribute of a control. The component attribute resource may represent the attribute of a component. The class attribute resource may represent the attribute of a class.
[0080] This step may determine corresponding translation information based on the attribute resource, such as determining definition information of the attribute information, for use by the translator for translation.
[0081] S270, traversing each node in the view node tree, modifying the original text file based on the translation information corresponding to each node, and obtaining a target text file.
[0082] When generating a bytecode file, this step can traverse each node in the view node tree, modify the original text file based on the translation information corresponding to each node, and after all nodes in the view node tree are traversed, determine the modified original text file as the target text file.
[0083] Exemplarily, the modification of the original text file can be completed by a translator, and the translation information in the original text file can be modified into the corresponding content. The translation information and the corresponding content can be pre-stored in the translator to complete the translation. When the translation information corresponding to the node does not exist in the translator, the content input by the custom translation interface can be obtained to complete the modification.
[0084] When traversing the view node tree, this step may start from the root node of the view node tree and traverse each child node level by level until all nodes in the view node tree are translated.
[0085] S280. Generate a bytecode file based on the target text file.
[0086] After obtaining the target text file, the bytecode generator can generate a bytecode file. The method of generating the bytecode file is not limited, and a method of generating a bytecode file from a text-based code can be used.
[0087] S290. Generate an Android application package based on the bytecode file.
[0088] The second embodiment of the present disclosure provides a method for generating an Android application package, which specifies the operations of obtaining resource information and original text files, determining a view node tree and translation information, and generating a bytecode file. Using this method, generating an APK through a bytecode file reduces the time for loading the APK and avoids the technical problems caused by generating an APK based on an XML file.
[0089] Based on the above embodiment, a variant embodiment of the above embodiment is proposed. It should be noted that in order to make the description concise, only the differences from the above embodiment are described in the variant embodiment.
[0090] In one embodiment, the method further includes: obtaining and executing a configuration file, wherein the configuration file indicates the functions to be implemented.
[0091] In order to solve the technical problem that XML files are poorly flexible and difficult to insert custom logic, the present disclosure can obtain a configuration file, such as obtaining the configuration file through a resource manager, and then the bytecode generator executes the configuration file to implement the custom logic. The configuration file can indicate the functions to be implemented, which are not limited here and can be determined according to the desired custom functions.
[0092] For example, when monitoring is desired, the content to be monitored can be configured in the configuration file, so that the content can be monitored when the configuration file is executed. When replacing a view of a specified type, the view to be replaced and the replaced view can be configured in the configuration file, so that the replacement can be performed when the configuration file is executed. For example, the configuration file includes monitorA to monitor A.
[0093] The disclosure is described below as an example. The method for generating an Android application package provided by the disclosure can be considered as a technical solution for taking over the Android XML rendering user interface (UI), that is, the XML-UI system. The method for generating an Android application package provided by the disclosure optimizes the technical problem of the time-consuming Android XML rendering UI.
[0094] The Android system uses XML as a programming interface. Android's processing of XML at runtime has the following technical problems: additional loading takes time; static language is not flexible enough; it is directly coupled with business code, making it difficult to insert custom logic, such as monitoring.
[0095] In response to the above technical problems, the present invention takes over the XML-UI system through compilation and processing, and optimizes the performance of the XML-UI system through pure code inflation. At the same time, the interface is exposed to developers, and a concept similar to an adaptation layer is added between the XML-UI layer and the business code layer. Developers can obtain functions that are difficult to achieve with XML-UI based on the adaptation layer, such as VIEW of the global replacement instruction type.
[0096] Figure 2a A flowchart of another method for generating an Android application package provided in the second embodiment of the present disclosure is shown in FIG. Figure 2a The process before all resources / codes are ready can be the existing process of preparing resources and codes based on XML. The present invention obtains bytecode files based on all resources and codes, that is, original text files, to overcome the technical problems caused by APK generated based on XML files.
[0097] After all resources and codes are ready, you can search and process the required resources, parse the XML one by one, and translate them into code. Finally, you can get the bytecode file to generate the apk.
[0098] The present disclosure inserts tasks in the gradle transfrom phase to construct the above adaptation layer. After the resource processing task, i.e. Task, and the compilation task, i.e. compile Task, are completed, in theory, we can obtain all relevant resource information. At this time, after all resources are processed, we can start translating the XML file.
[0099] Figure 2b This is a schematic diagram of the architecture of a method for generating an Android application package provided in the second embodiment of the present disclosure, see Figure 2bThe plug-in includes a resource manager (ie ResourceMgr), a processor (ie Reader), a view node processor (ie ViewNodeTrees), a translator (ie Translators) and a bytecode generator (ie ClassGenerator).
[0100] The resource manager is the manager of resources and is responsible for the search logic of all resources. The searched resources are delegated to the processor for processing. Obtaining resource reflection depends on the Gradle Application Programming Interface (API), so it may also need to undertake adaptation tasks.
[0101] The processor is the resource handler, responsible for reading the layout-xml file and generating a ViewNode tree for each xml file; AttrReader is responsible for obtaining layout-attr resources and providing information for translation attributes; StyleReader is responsible for obtaining layout-style resources and providing information for translation attributes; RReader is responsible for obtaining R.class resources and providing information for translation attributes.
[0102] The view node processor is an abstract description of xml-layout, which can achieve decoupling and expand new functions. Each xml-layout has a corresponding Root ViewNode; the Root ViewNode will trigger the traversal of the ViewNode Tree, which is essentially a multi-tree depth-first search algorithm (DFS) process; during the traversal, each xml attribute of each ViewNode node will be handed over to the Translators for translation into code; after the traversal, the Root ViewNode summarizes the code of all child nodes and finally generates the corresponding xml code.
[0103] The translator is a translation collection of XML attributes, providing external extension capabilities. Users can implement the interface themselves and translate the attributes of custom Views.
[0104] The bytecode generator is responsible for bytecode generation. The code held by the view node processor will be processed by the bytecode generator, which uses Javassist by default. After all bytecode files are generated, the AndInflater interface will be instrumented; or through AndInflater.getView(), you can get the code generated during compilation.
[0105] The present disclosure may further include a log processor, which may be a log manager responsible for generating logs during all compilations.
[0106] Figure 2b The plug-in shown exists as an abstract adaptation layer. Because it takes over the XML-UI system, it can provide a comprehensive UI-Inflate interface (also known as a hook). At the same time, for business custom views, the plug-in provides a code-based custom translation interface for developers to use. The present disclosure provides a global resource perspective through the GradleTransfrom plug-in.
[0107] Embodiment 3
[0108] Figure 3 This is a structural diagram of a device for generating an Android application package provided in Embodiment 3 of the present disclosure. The device can be applicable to the case of generating an Android APK, wherein the device can be implemented by software and / or hardware and is generally integrated on a terminal device.
[0109] like Figure 3 As shown, the device comprises:
[0110] An acquisition module 31 is used to acquire resource information and original text files;
[0111] A determination module 32, used to determine a view node tree corresponding to the resource information and corresponding translation information;
[0112] A first generating module 33, used to generate a bytecode file based on the original text file, the view node tree and the translation information;
[0113] The second generating module 34 is used to generate an Android application package based on the bytecode file.
[0114] In this embodiment, the device first obtains resource information and an original text file through an acquisition module 31; secondly, determines a view node tree and corresponding translation information corresponding to the resource information through a determination module 32; then generates a bytecode file based on the original text file, the view node tree and the translation information through a first generation module 33; and finally, generates an Android application package based on the bytecode file through a second generation module 34.
[0115] This embodiment provides a device for generating an Android application package, which effectively solves the technical problem of time-consuming loading of an APK generated based on an XML file and reduces the time for loading the APK.
[0116] Furthermore, the acquisition module 31 is specifically used for:
[0117] Determine the resource information required to generate the user interface;
[0118] Get the required resource information through the hook function.
[0119] Furthermore, the acquisition module 31 is specifically used for:
[0120] Get the path information of the original text file;
[0121] The original text file is read from the path information.
[0122] Further, the determination module 32 is specifically used for:
[0123] Determine a corresponding view node tree based on the layout resource of the extensible markup language XML included in the resource information;
[0124] Based on the attribute resources included in the resource information, translation information corresponding to the resource information is determined.
[0125] Furthermore, the attribute resources include XML control attribute resources, XML component attribute resources and class attribute resources.
[0126] Furthermore, the first generating module 33 is specifically used for:
[0127] Traversing each node in the view node tree, modifying the original text file based on the translation information corresponding to each node, and obtaining a target text file;
[0128] A bytecode file is generated based on the target text file.
[0129] Furthermore, the device also includes an execution module, which is used to:
[0130] A configuration file is obtained and executed, the configuration file indicating the functions to be implemented.
[0131] The above-mentioned device for generating an Android application package can execute the method for generating an Android application package provided by any embodiment of the present disclosure, and has functional modules and beneficial effects corresponding to the execution method.
[0132] Embodiment 4
[0133] Figure 4 A schematic diagram of the structure of a terminal device provided in Embodiment 4 of the present disclosure. Figure 4The schematic diagram of the structure of a terminal device 400 suitable for implementing the embodiment of the present disclosure is shown. The terminal device 400 in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, personal digital assistants (PDAs), tablet computers (Portable Android Devices, PADs), portable multimedia players (Portable Media Players, PMPs), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 4 The terminal device 400 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0134] like Figure 4 As shown, the terminal device 400 may include one or more processing devices (such as a central processing unit, a graphics processing unit, etc.) 401, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 402 or a program loaded from a storage device 408 to a random access memory (RAM) 403. One or more processing devices 401 implement the generation method of an Android application package as provided in the present disclosure. In RAM403, various programs and data required for the operation of the terminal device 400 are also stored. The processing device 401, ROM 402 and RAM403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.
[0135] Typically, the following devices may be connected to the I / O interface 405: an input device 406 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 407 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 408 including, for example, a magnetic tape, a hard disk, etc., the storage device 408 being used to store one or more programs; and a communication device 409. The communication device 409 may allow the terminal device 400 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 4 The terminal device 400 is shown to have various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0136] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 409, or installed from the storage device 408, or installed from the ROM402. When the computer program is executed by the processing device 401, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0137] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0138] The computer-readable medium may be included in the terminal device 400 ; or may exist independently without being assembled into the terminal device 400 .
[0139] The computer-readable medium stores one or more computer programs, and when the one or more programs are executed by the processing device, the following method is implemented: obtaining resource information and original text files;
[0140] Determine a view node tree and corresponding translation information corresponding to the resource information;
[0141] Generate a bytecode file based on the original text file, the view node tree and the translation information;
[0142] An Android application package is generated based on the bytecode file.
[0143] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0144] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present disclosure. Each box in the flowchart or block diagram can represent a module, a program segment, or a part of a code, and the module, the program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of the boxes in the block diagram and / or the flowchart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0145] The modules involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a module does not, in some cases, limit the module itself.
[0146] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0147] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0148] According to one or more embodiments of the present disclosure, Example 1 provides a method for generating an Android application package, including:
[0149] Get resource information and original text files;
[0150] Determine a view node tree and corresponding translation information corresponding to the resource information;
[0151] Generate a bytecode file based on the original text file, the view node tree and the translation information;
[0152] An Android application package is generated based on the bytecode file.
[0153] According to one or more embodiments of the present disclosure, Example 2 obtains resource information according to the method described in Example 1, including:
[0154] Determine the resource information required to generate the user interface;
[0155] Get the required resource information through the hook function.
[0156] According to one or more embodiments of the present disclosure, Example 3 is the method according to Example 1,
[0157] Get the original text file, including:
[0158] Get the path information of the original text file;
[0159] The original text file is read from the path information.
[0160] According to one or more embodiments of the present disclosure, Example 4 is the method according to Example 1,
[0161] Determining the view node tree corresponding to the resource information and the corresponding translation information includes:
[0162] Determine a corresponding view node tree based on the layout resource of the extensible markup language XML included in the resource information;
[0163] Based on the attribute resources included in the resource information, translation information corresponding to the resource information is determined.
[0164] According to one or more embodiments of the present disclosure, Example 5 is the method according to Example 4,
[0165] The attribute resources include XML control attribute resources, XML component attribute resources and class attribute resources.
[0166] According to one or more embodiments of the present disclosure, Example 6 generates a bytecode file based on the original text file, the view node tree, and the translation information according to the method of Example 1, including:
[0167] Traversing each node in the view node tree, modifying the original text file based on the translation information corresponding to each node, and obtaining a target text file;
[0168] A bytecode file is generated based on the target text file.
[0169] According to one or more embodiments of the present disclosure, Example 7 is the method according to Examples 1-6, further comprising:
[0170] A configuration file is obtained and executed, the configuration file indicating the functions to be implemented.
[0171] According to one or more embodiments of the present disclosure, Example 8 provides a device for generating an Android application package, including:
[0172] Acquisition module, used to obtain resource information and original text files;
[0173] A determination module, used to determine the view node tree corresponding to the resource information and the corresponding translation information;
[0174] A first generating module, used for generating a bytecode file based on the original text file, the view node tree and the translation information;
[0175] The second generating module is used to generate an Android application package based on the bytecode file.
[0176] According to one or more embodiments of the present disclosure, Example 9 provides a terminal device, including:
[0177] one or more processing devices;
[0178] A storage device for storing one or more programs;
[0179] When the one or more programs are executed by the one or more processing devices, the one or more processing devices implement the method described in any one of Examples 1-7.
[0180] According to one or more embodiments of the present disclosure, Example 10 provides a computer-readable medium having a computer program stored thereon, which, when executed by a processing device, implements the method described in any one of Examples 1-7.
[0181] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
Claims
1. A method for generating an Android application package, characterized in that: include: Acquire resource information and an original text file, wherein the resource information includes information of resources included in the XML file, and the original text file includes a class file in the XML file; Determine a corresponding view node tree based on the layout resource of the extensible markup language XML included in the resource information; Based on the attribute resources included in the resource information, determining translation information corresponding to the resource information, the translation information is information required for translation, the attribute resources include XML control attribute resources, XML component attribute resources and class attribute resources, and the translation information includes information required when translating an XML file into a bytecode file in code form; Traversing each node in the view node tree, modifying the original text file based on the translation information corresponding to each node, and obtaining a target text file; Generate a bytecode file based on the target text file; An Android application package is generated based on the bytecode file.
2. The method according to claim 1, characterized in that Get resource information, including: Determine the resource information required to generate the user interface; Get the required resource information through the hook function.
3. The method according to claim 1, characterized in that Get the original text file, including: Get the path information of the original text file; The original text file is read from the path information.
4. The method according to any one of claims 1 to 3, characterized in that: Also includes: A configuration file is obtained and executed, the configuration file indicating the functions to be implemented.
5. A device for generating an Android application package, characterized in that: include: An acquisition module, used for acquiring resource information and an original text file, wherein the resource information includes information of resources included in the XML file, and the original text file includes a class file in the XML file; A determination module, configured to determine a corresponding view node tree based on the layout resource of the extensible markup language XML included in the resource information; Based on the attribute resources included in the resource information, determining translation information corresponding to the resource information, the translation information is information required for translation, the attribute resources include XML control attribute resources, XML component attribute resources and class attribute resources, and the translation information includes information required when translating an XML file into a bytecode file in code form; A first generating module is used to traverse each node in the view node tree, modify the original text file based on the translation information corresponding to each node, and obtain a target text file; and generate a bytecode file based on the target text file; The second generating module is used to generate an Android application package based on the bytecode file.
6. A terminal device, characterized in that: include: one or more processing devices; A storage device for storing one or more programs; When the one or more programs are executed by the one or more processing devices, the one or more processing devices implement the method according to any one of claims 1 to 4.
7. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processing device, the method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Android platform module dynamic loading method and system
CN105511902A
Interface layout method and device for Android application
CN110442419A