CN113835718A - Android application package generation method and device, terminal device and medium - Google Patents

Android application package generation method and device, terminal device and medium Download PDF

Info

Publication number
CN113835718A
CN113835718A CN202010583905.1A CN202010583905A CN113835718A CN 113835718 A CN113835718 A CN 113835718A CN 202010583905 A CN202010583905 A CN 202010583905A CN 113835718 A CN113835718 A CN 113835718A
Authority
CN
China
Prior art keywords
file
generating
text file
information
resource information
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.)
Pending
Application number
CN202010583905.1A
Other languages
Chinese (zh)
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 ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network 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 ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202010583905.1A priority Critical patent/CN113835718A/en
Publication of CN113835718A publication Critical patent/CN113835718A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management

Landscapes

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

Abstract

The disclosure discloses a generation method and device of an android application package, terminal equipment and a medium. The method comprises the following steps: acquiring resource information and an original text file; determining a view node tree corresponding to the resource information and corresponding translation information; generating a bytecode file based on the original text file, the view node tree, and the translation information; and generating an android application program package based on the byte code file. By using the method, the technical problem that APK loading based on XML file generation is time-consuming is effectively solved, and the time for loading APK is reduced.

Description

Android application package generation method and device, terminal device and medium
Technical Field
The embodiment of the disclosure relates to the technical field of computers, in particular to a method and a device for generating an android application package, a terminal device and a medium.
Background
User interface design is an important part of application development. For example, in the Android system, Extensible Markup Language (XML) is used as a programming interface, and a developer generates a user interface by writing an XML file to complete generation of an Android Application Package (APK).
However, there is a technical problem in that it takes time to load the APK generated based on the XML file.
Disclosure of Invention
The embodiment of the disclosure provides a generation method, a generation device, a terminal device and a medium of an android application package, and effectively solves the technical problem that APK loading based on XML file generation is time-consuming.
In a first aspect, an embodiment of the present disclosure provides a method for generating an android application package, including:
acquiring resource information and an original text file;
determining a view node tree corresponding to the resource information and corresponding translation information;
generating a bytecode file based on the original text file, the view node tree, and the translation information;
and generating an android application program package based on the byte code file.
In a second aspect, an embodiment of the present disclosure further provides an apparatus for generating an android application package, including:
the acquisition module is used for acquiring the resource information and the original text file;
the determining module is used for determining the view node tree corresponding to the resource information and the corresponding translation information;
a first generation module, configured to generate a bytecode file based on the original text file, the view node tree, and the translation information;
and the second generation module is used for generating an android application program package based on the byte code file.
In a third aspect, an embodiment of the present disclosure further provides a terminal device, including:
one or more processing devices;
storage means for storing one or more programs;
the one or more programs are executed by the one or more processing devices, so that the one or more processing devices implement the methods provided by the embodiments of the present disclosure.
In a fourth aspect, the disclosed embodiments also provide a computer readable medium, on which a computer program is stored, which when executed by a processing device implements the method provided by the disclosed embodiments.
The embodiment of the disclosure provides a method, a device, a terminal device and a medium for generating an android application package, and the method comprises the steps of firstly acquiring resource information and an original text file; then determining a view node tree corresponding to the resource information and corresponding translation information; secondly, generating a byte code file based on the original text file, the view node tree and the translation information; and finally, generating an android application program package based on the byte code file. By utilizing the technical scheme, the technical problem that APK loading based on XML file generation consumes time is effectively solved, and the time for loading APK is reduced.
Drawings
Fig. 1 is a schematic flowchart of a method for generating an android application package according to an embodiment of the present disclosure;
fig. 2 is a schematic flowchart of a method for generating an android application package according to a second embodiment of the present disclosure;
fig. 2a is a schematic flowchart of another android application package generation method provided in the second embodiment of the present disclosure;
fig. 2b is a schematic diagram of an architecture of a method for generating an android application package according to a second embodiment of the present disclosure;
fig. 3 is a schematic structural diagram of an apparatus for generating an android application package according to a third embodiment of the present disclosure;
fig. 4 is a schematic structural diagram of a terminal device according to a fourth embodiment of the present disclosure.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. Moreover, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "include" and variations thereof as used herein are open-ended, i.e., "including but not limited to". The term "based on" is "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". Relevant definitions for other terms will be given in the following description.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise.
The names of messages or information exchanged between devices in the embodiments of the present disclosure are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
In the following embodiments, optional features and examples are provided in each embodiment, and various features described in the embodiments may be combined to form a plurality of alternatives, and each numbered embodiment should not be regarded as only one technical solution. Furthermore, the embodiments and features of the embodiments in the present disclosure may be combined with each other without conflict.
Example one
Fig. 1 is a schematic flow diagram of a method for generating an android application package according to an embodiment of the present disclosure, where the method is applicable to a case of generating an android APK, and the method may be executed by a device for generating an android application package, where the device may be implemented by software and/or hardware and is generally integrated on a terminal device, where in this embodiment, the terminal device includes but is not limited to: a computer.
As shown in fig. 1, a method for generating an android application package according to a first embodiment of the present disclosure includes the following steps:
and S110, acquiring resource information and an original text file.
In this embodiment, the resource information may be regarded as information of a resource included in the XML file, and the specific content of the resource information is not limited herein. Different APKs may correspond to different resource information. Illustratively, the resource information includes, but is not limited to, a layout resource of XML, a control property resource of XML, a component property resource of XML, and a class property resource of XML.
The original text file may be considered a class file in an XML file. A target text file in the form of a code may be generated based on the original text file.
The method disclosed by the disclosure can be regarded as a gradle plug-in, the path of the original text file can be directly transmitted to the resource manager of the plug-in, and the path of the resource information can be acquired by the resource manager through a Hook function, namely, a Hook mode, so that the resource information is acquired.
It should be noted that, the method of Hook differs between different versions of the gradle, and the method is not limited herein, and may be determined based on the version of the gradle.
And S120, determining a view node tree corresponding to the resource information and corresponding translation information.
The view node tree may be thought of as a view of the layout of the tree generated based on the layout resource. The translation information may be considered information required when translating an XML file into a bytecode file in code form.
After the resource information is acquired, the view node tree and the translation information corresponding to the resource information can be determined in the step. Such as by a processor determining a tree of view nodes and translation information. Specifically, the step may determine the corresponding view node tree and the translation information based on different resources included in the resource information, for example, determine the view node tree based on the layout resource of the XML, and determine the translation information, that is, the information required for translation, for example, macro definition information of each resource, based on the attribute resource.
S130, generating a byte code file based on the original text file, the view node tree and the translation information.
A bytecode file can be considered as a bytecode-form code. The generation of the bytecode file may be generated by the bytecode generator based on the target text file.
After the view node tree and the translation information are determined, the step may modify the original text file according to the translation information of the XML attribute based on the XML attribute of each node in the view node tree, so as to obtain a corresponding target text file. A bytecode file is then generated based on the target text file.
When the original text file is modified, the content modification original text file corresponding to the customized XML attribute can be obtained.
And S140, generating an android application program package based on the bytecode file.
After the bytecode file is generated, the step may complete generation of the installation APK based on the bytecode file. Such as completing the process of generating a DEX based on the bytecode file. The generated android APK can comprise a byte code file, and when the APK is loaded, the XML file does not need to be loaded, and the technical problem that the XML file is time-consuming to load can be effectively solved by loading the byte code file.
When the android application program package is generated, the android application program package can be generated based on the byte code file through a HookAndInflater interface without perception; the technical means can solve the problem that the original code has a problem to cause the error report of the XML file, and the logic of the replacement system disclosed by the invention directly generates the APK based on the bytecode file.
The method for generating the android application package, provided by the embodiment of the disclosure, comprises the steps of firstly obtaining resource information and an original text file; then determining a view node tree corresponding to the resource information and corresponding translation information; secondly, generating a byte code file based on the original text file, the view node tree and the translation information; and finally, generating an android application program package based on the byte code file. By using the method, the technical problem that APK loading based on XML file generation is time-consuming is effectively solved, and the time for loading APK is reduced.
Example two
Fig. 2 is a schematic flow chart of a method for generating an android application package according to a second embodiment of the present disclosure, where the second embodiment is embodied on the basis of various optional solutions in the foregoing embodiments. In this embodiment, the acquiring resource information specifically includes:
determining resource information required for generating a user interface;
and acquiring the required resource information through a hook function.
Further, this embodiment will also obtain the original text file, specifically include:
acquiring path information of an original text file;
reading an original text file from the path information.
On the basis of the optimization, determining a view node tree corresponding to the resource information and corresponding translation information, specifically including:
determining a corresponding view node tree based on the layout resources of the extensible markup language XML included in the resource information;
and determining translation information corresponding to the resource information based on the attribute resources included in the resource information.
Further, generating a bytecode file based on the original text file, the view node tree, and the translation information, specifically including:
traversing each node in the view node tree, and modifying the original text file based on translation information corresponding to each node to obtain a target text file;
and generating a byte code file based on the target text file.
Please refer to the first embodiment for a detailed description of the present embodiment.
As shown in fig. 2, a method for generating an android application package according to a second embodiment of the present disclosure includes the following steps:
s210, determining resource information required by generating the user interface.
The resource information required by different application programs is different, the step can firstly determine the resource information required by the user interface, and the required resource information can be limited according to the actual situation, which is not limited here.
This step may determine the required resource information in advance before generating the APK, and then acquire the resource information.
And S220, acquiring the required resource information through the hook function.
After determining the required resource information, the step may obtain the required resource information through a hook function. Specifically, in this step, the resource information may be obtained by a method corresponding to the Hook resource information.
And S230, acquiring the path information of the original text file.
When acquiring the original text file, this step may first acquire path information of the original text file, such as acquiring the path information of the original text file from the gradle component. The original text file is then retrieved based on the path information.
And S240, reading the original text file from the path information.
S250, determining a corresponding view node tree based on the layout resources of the extensible markup language XML included in the resource information.
In determining the view node tree and the translation information, this step may determine the view node tree based on a layout resource of XML included in the resource information, that is, an XML-layout resource. Such as the translation of the layout resources of XML into a tree of view nodes in code. The corresponding relationship during the transcription may be preset, and is not limited herein.
Each node in the VIEW node tree may be a VIEW, i.e., VIEW.
S260, determining translation information corresponding to the resource information based on the attribute resources included in the resource information.
The property resources may be resources that characterize properties, which in one embodiment include control property resources for XML, component property resources for XML, and class property resources. The control property resource can characterize properties of the control. The component property resource can characterize a property of the component. The class attribute resource can characterize attributes of a class.
This step may determine corresponding translation information based on the attribute resource, such as determining definition information of the attribute information for the translator to translate.
S270, traversing each node in the view node tree, and modifying the original text file based on the translation information corresponding to each node to obtain a target text file.
When the bytecode file is generated, the 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 determine the modified original text file as the target text file after all the nodes in the view node tree are traversed.
Illustratively, modifying the original text file may be done by a translator, which may modify the translation information in the original text file to the corresponding content. The translator can pre-store the translation information and the corresponding content so as to finish 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 modification.
When traversing the view node tree, the step may begin to traverse each child node step by step from the root node of the view node tree until each node in the view node tree is translated.
And S280, generating a byte code file based on the target text file.
After the target text file is obtained, the bytecode generator can generate the bytecode file, the mode of generating the bytecode file is not limited, and a generation means for generating the bytecode-form code by using the text-form code can be adopted.
And S290, generating an android application program package based on the bytecode file.
The generation method of the android application package provided by the second embodiment of the disclosure embodies the operation of acquiring the resource information and the original text file, the operation of determining the view node tree and the translation information, and the operation of generating the byte code file. By using the method, the APK is generated through the byte code file, the time for loading the APK is reduced, and the technical problem caused by generating the APK based on the XML file is avoided.
On the basis of the above-described embodiment, a modified embodiment of the above-described embodiment is proposed, and it is to be noted herein that, in order to make the description brief, only the differences from the above-described embodiment are described in the modified embodiment.
In one embodiment, the method further comprises: a configuration file is obtained and executed, the configuration file indicating a function to be implemented.
In order to solve the technical problems that the XML file is poor in flexibility and customized logic is difficult to insert, the configuration file can be obtained through the resource manager, for example, the configuration file is obtained through the resource manager, and then the configuration file is executed through the byte code generator so as to achieve the customized logic. The configuration file may indicate a function to be implemented, and the function to be implemented is not limited here and may be determined according to a function to be customized.
For example, when monitoring is desired, the content desired to be monitored may be configured in a configuration file, so that the monitoring of the content is performed when the configuration file is executed. When a view of a specified type is desired to be replaced, the view desired to be replaced and the replaced view may be configured in a configuration file to be replaced when the configuration file is executed. For example, the configuration file includes monitor A to enable monitoring of A.
The following description is given for an example, and the method for generating the Android application package provided by the present disclosure may be regarded as a technical scheme for taking over an Android XML rendering User Interface (UI), that is, an XML-UI system. The generation method of the android application package optimizes the technical problem that the UI rendering of the android XML consumes time.
The android system uses XML as a programming interface, and the android has the following technical problems in the processing of the XML during the operation: additional load time; static languages are not flexible enough; directly coupled with the service code, it is difficult to insert custom logic, such as monitoring.
Aiming at the technical problems, the XML-UI system is comprehensively taken over through compiling processing, and the performance of the XML-UI system is optimized in a pure code inflate mode. And simultaneously, an interface is exposed to a developer, and a concept similar to an adaptation layer is additionally arranged between an XML-UI layer and a service code layer. The developer can acquire the functions which are difficult to realize by the XML-UI, such as the VIEW of the global replacement instruction type, based on the adaptation layer.
Fig. 2a is a schematic flow chart of another android application package generation method provided in the second embodiment of the present disclosure, and referring to fig. 2a, a process before all resources/codes are ready may be an existing XML-based resource and code preparation process. The present disclosure obtains a bytecode file based on all resources and codes, i.e., an original text file, to overcome technical problems brought when an APK is generated based on an XML file.
After all resources and code are ready, the required resources can be searched and processed, and xml is parsed piece by piece to be translated into a code form. And finally obtaining a byte code file for generating apk.
According to the method, the Task is inserted in the gradle transfrom stage to construct the adaptation layer, after the resource processing Task, namely the Task and the compiling Task, namely the compile Task, are finished, theoretically, all relevant resource information can be obtained, and at the moment, all resources are processed, and the XML file can be translated.
Fig. 2b is a schematic diagram of an architecture of an android application package generation method according to a second embodiment of the present disclosure, and referring to fig. 2b, the plug-in includes a resource manager (i.e., ResourceMgr), a processor (i.e., Reader), a view node processor (i.e., viewnodenetrees), a translator (i.e., translations), and a bytecode generator (i.e., ClassGenerator).
The resource manager is a manager of resources, and is responsible for the search logic of all resources, and the searched resources are requested to be processed by the processor. Acquiring resource reflection relies on the Application Programming Interface (API), so it is also possible to take over the adapted task.
The processor is a resource processor and is responsible for reading layout-xml files and generating a ViewNode tree for each xml file; the attrreder is responsible for acquiring layout-attr resources and providing information for translation attributes; the StyleReader is responsible for acquiring layout-style resources and providing information for translation attributes; RReader is responsible for acquiring R.class resources and providing information for translation attributes.
The view node processor is an xml-layout abstract description, can realize decoupling and expand new functions. Each xml-layout has a Root ViewNode and the corresponding Root ViewNode; the Root ViewNode triggers traversal of the ViewNode Tree, which is essentially a Depth first search algorithm (DFS) process of a multi-branch Tree; in the traversal process, each xml attribute of each ViewNode node is given to Translators to be translated into codes; and the Root ViewNode summarizes the codes of all the word nodes after traversing is finished, and finally generates the code corresponding to the xml.
The translator is a translation set of XML attributes, provides the capability of external extension, and a user can realize an interface by himself and translate the attributes of the custom View.
The bytecode generator is responsible for bytecode generation, and the code held by the view node processor is handed over to the bytecode generator for processing, and javasissst is used by default. After all byte code files are generated, inserting piles into the AndInflater interface; or through AndInflatView (), it can be acquired that the code is generated during compilation.
The present disclosure may also include a log processor, which may be a log manager, responsible for log generation during all compilations.
The plug-in shown in fig. 2b exists as an abstract adaptation layer, which can provide a comprehensive UI-invert interface (also understood as hook) because it takes over the XML-UI system. Meanwhile, for business self-defined View, the plug-in provides a self-defined translation interface based on codes for developers to use. The present disclosure provides a global resource view through the gradleTransfrom plug-in.
EXAMPLE III
Fig. 3 is a schematic structural diagram of an apparatus for generating an android application package according to a third embodiment of the present disclosure, where the apparatus is applicable to a case of generating an android APK, where the apparatus may be implemented by software and/or hardware and is generally integrated on a terminal device.
As shown in fig. 3, the apparatus includes:
an obtaining module 31, configured to obtain resource information and an original text file;
a determining module 32, configured to determine a view node tree corresponding to the resource information and corresponding translation information;
a first generating module 33, configured to generate a bytecode file based on the original text file, the view node tree, and the translation information;
and a second generating module 34, configured to generate an android application package based on the bytecode file.
In this embodiment, the apparatus first obtains the resource information and the original text file through the obtaining module 31; secondly, determining a view node tree corresponding to the resource information and corresponding translation information through a determining module 32; then, generating a byte code file based on the original text file, the view node tree and the translation information through a first generation module 33; and finally, generating an android application package based on the bytecode file through a second generation module 34.
The embodiment provides a device for generating an android application package, which effectively solves the technical problem that APK generated based on an XML file consumes time in loading, and reduces the time for loading the APK.
Further, the obtaining module 31 is specifically configured to:
determining resource information required for generating a user interface;
and acquiring the required resource information through a hook function.
Further, the obtaining module 31 is specifically configured to:
acquiring path information of an original text file;
reading an original text file from the path information.
Further, the determining module 32 is specifically configured to:
determining a corresponding view node tree based on the layout resources of the extensible markup language XML included in the resource information;
and determining translation information corresponding to the resource information based on the attribute resources included in the resource information.
Further, the attribute resources include a control attribute resource of XML, a component attribute resource of XML, and a class attribute resource.
Further, the first generating module 33 is specifically configured to:
traversing each node in the view node tree, and modifying the original text file based on translation information corresponding to each node to obtain a target text file;
and generating a byte code file based on the target text file.
Further, the apparatus further comprises an execution module configured to:
a configuration file is obtained and executed, the configuration file indicating a function to be implemented.
The generation device of the android application package can execute the generation method of the android application package provided by any embodiment of the disclosure, and has corresponding functional modules and beneficial effects of the execution method.
Example four
Fig. 4 is a schematic structural diagram of a terminal device according to a fourth embodiment of the present disclosure. Fig. 4 shows a schematic structural diagram of a terminal device 400 suitable for implementing an embodiment of the present disclosure. The terminal Device 400 in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a Digital broadcast receiver, a Personal Digital Assistant (PDA), a tablet computer (PAD), a Portable Multimedia Player (PMP), a vehicle mounted terminal (e.g., a car navigation terminal), etc., and a fixed terminal such as a Digital TV, a desktop computer, etc. The terminal device 400 shown in fig. 4 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 4, the terminal device 400 may include one or more processing means (e.g., a central processing unit, a graphics processor, etc.) 401 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)402 or a program loaded from a storage means 408 into a Random Access Memory (RAM) 403. The one or more processing devices 401 implement a method of generating an android application package as provided by the present disclosure. In the RAM403, various programs and data necessary for the operation of the terminal apparatus 400 are also stored. The processing device 401, the ROM402, and the RAM403 are connected to each other via a bus 404. An input/output (I/O) interface 405 is also connected to bus 404.
Generally, the following devices may be connected to the I/O interface 405: input devices 406 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 407 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 408, including, for example, magnetic tape, hard disk, etc., storage 408 for storing one or more programs; and a communication device 409. The communication means 409 may allow the terminal device 400 to communicate with other devices wirelessly or by wire to exchange data. While fig. 4 illustrates a terminal apparatus 400 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication device 409, or from the storage device 408, or from the ROM 402. The computer program performs the above-described functions defined in the methods of the embodiments of the present disclosure when executed by the processing device 401.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer-readable medium may be contained in the terminal device 400; or may exist separately without being assembled into the terminal device 400.
The computer readable medium stores one or more computer programs which, when executed by a processing device, implement the method of: acquiring resource information and an original text file;
determining a view node tree corresponding to the resource information and corresponding translation information;
generating a bytecode file based on the original text file, the view node tree, and the translation information;
and generating an android application program package based on the byte code file.
Computer program code for carrying out operations for aspects of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of 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 the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. Each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present disclosure may be implemented by software or hardware. Wherein the name of a module in some cases does not constitute a limitation on the module itself.
The functions described herein above 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 a chip (SOCs), Complex Programmable Logic Devices (CPLDs), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The 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, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
Example 1 provides a method for generating an android application package, including:
acquiring resource information and an original text file;
determining a view node tree corresponding to the resource information and corresponding translation information;
generating a bytecode file based on the original text file, the view node tree, and the translation information;
and generating an android application program package based on the byte code file.
Example 2 in accordance with one or more embodiments of the present disclosure, the method of example 1, obtaining resource information, comprises:
determining resource information required for generating a user interface;
and acquiring the required resource information through a hook function.
Example 3 in accordance with one or more embodiments of the present disclosure, the method of example 1,
obtaining an original text file comprising:
acquiring path information of an original text file;
reading an original text file from the path information.
Example 4 in accordance with one or more embodiments of the present disclosure, the method of example 1,
determining a view node tree corresponding to the resource information and corresponding translation information, including:
determining a corresponding view node tree based on the layout resources of the extensible markup language XML included in the resource information;
and determining translation information corresponding to the resource information based on the attribute resources included in the resource information.
Example 5 in accordance with one or more embodiments of the present disclosure, the method of example 4,
the attribute resources comprise XML control attribute resources, XML component attribute resources and class attribute resources.
Example 6 generating a bytecode file based on the raw text file, the view node tree, and the translation information according to the method of example 1, including, in accordance with one or more embodiments of the present disclosure:
traversing each node in the view node tree, and modifying the original text file based on translation information corresponding to each node to obtain a target text file;
and generating a byte code file based on the target text file.
Example 7 the method of examples 1-6, in accordance with one or more embodiments of the present disclosure, further comprising:
a configuration file is obtained and executed, the configuration file indicating a function to be implemented.
Example 8 provides an apparatus for generating an android application package, according to one or more embodiments of the present disclosure, including:
the acquisition module is used for acquiring the resource information and the original text file;
the determining module is used for determining the view node tree corresponding to the resource information and the corresponding translation information;
a first generation module, configured to generate a bytecode file based on the original text file, the view node tree, and the translation information;
and the second generation module is used for generating an android application program package based on the byte code file.
Example 9 provides, in accordance with one or more embodiments of the present disclosure, a terminal device, comprising:
one or more processing devices;
storage means for storing one or more programs;
when executed by the one or more processing devices, cause the one or more processing devices to implement the method of any of examples 1-7.
Example 10 provides a computer-readable medium having stored thereon a computer program that, when executed by a processing apparatus, implements the method of any of examples 1-7, in accordance with one or more embodiments of the present disclosure.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.

Claims (10)

1. A method for generating an android application package is characterized by comprising the following steps:
acquiring resource information and an original text file;
determining a view node tree corresponding to the resource information and corresponding translation information;
generating a bytecode file based on the original text file, the view node tree, and the translation information;
and generating an android application program package based on the byte code file.
2. The method of claim 1, wherein obtaining resource information comprises:
determining resource information required for generating a user interface;
and acquiring the required resource information through a hook function.
3. The method of claim 1, wherein obtaining an original text file comprises:
acquiring path information of an original text file;
reading an original text file from the path information.
4. The method of claim 1, wherein determining the view node tree and the corresponding translation information corresponding to the resource information comprises:
determining a corresponding view node tree based on the layout resources of the extensible markup language XML included in the resource information;
and determining translation information corresponding to the resource information based on the attribute resources included in the resource information.
5. The method of claim 4, wherein the property resources include a control property resource of XML, a component property resource of XML, and a class property resource.
6. The method of claim 1, wherein generating a bytecode file based on the native text file, the view node tree, and the translation information comprises:
traversing each node in the view node tree, and modifying the original text file based on translation information corresponding to each node to obtain a target text file;
and generating a byte code file based on the target text file.
7. The method of any of claims 1-6, further comprising:
a configuration file is obtained and executed, the configuration file indicating a function to be implemented.
8. An apparatus for generating an android application package, comprising:
the acquisition module is used for acquiring the resource information and the original text file;
the determining module is used for determining the view node tree corresponding to the resource information and the corresponding translation information;
a first generation module, configured to generate a bytecode file based on the original text file, the view node tree, and the translation information;
and the second generation module is used for generating an android application program package based on the byte code file.
9. A terminal device, comprising:
one or more processing devices;
storage means for storing one or more programs;
when executed by the one or more processing devices, cause the one or more processing devices to implement the method of any of claims 1-7.
10. A computer-readable medium, on which a computer program is stored, characterized in that the program, when being executed by processing means, carries out the method according to any one of claims 1-7.
CN202010583905.1A 2020-06-23 2020-06-23 Android application package generation method and device, terminal device and medium Pending CN113835718A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010583905.1A CN113835718A (en) 2020-06-23 2020-06-23 Android application package generation method and device, terminal device and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010583905.1A CN113835718A (en) 2020-06-23 2020-06-23 Android application package generation method and device, terminal device and medium

Publications (1)

Publication Number Publication Date
CN113835718A true CN113835718A (en) 2021-12-24

Family

ID=78964250

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010583905.1A Pending CN113835718A (en) 2020-06-23 2020-06-23 Android application package generation method and device, terminal device and medium

Country Status (1)

Country Link
CN (1) CN113835718A (en)

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104317625A (en) * 2014-11-09 2015-01-28 刘鹏 Dynamic loading method for APK files
CN105511902A (en) * 2015-11-09 2016-04-20 Tcl集团股份有限公司 Android platform module dynamic loading method and system
CN106933645A (en) * 2017-01-17 2017-07-07 深圳市能信安科技股份有限公司 A kind of Apk security risks automatic Static auditing system and method
CN107305606A (en) * 2016-04-20 2017-10-31 中兴通讯股份有限公司 The processing method and processing device of application file and the access method of file and device
CN107391169A (en) * 2017-06-09 2017-11-24 口碑控股有限公司 The dynamic updating method and device of the Android page
CN108595187A (en) * 2018-03-27 2018-09-28 北京美好人生伙伴信息技术有限公司 Method, device and the storage medium of Android installation kit integrated software development kit
CN109783138A (en) * 2018-12-05 2019-05-21 北京奇艺世纪科技有限公司 Method for splitting, device, terminal and the medium that application package is constituted
CN110442419A (en) * 2019-08-15 2019-11-12 北京字节跳动网络技术有限公司 The quick interface arrangement method and device of Android application
CN111159662A (en) * 2019-12-25 2020-05-15 郑州阿帕斯数云信息科技有限公司 Data processing method and device

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104317625A (en) * 2014-11-09 2015-01-28 刘鹏 Dynamic loading method for APK files
CN105511902A (en) * 2015-11-09 2016-04-20 Tcl集团股份有限公司 Android platform module dynamic loading method and system
CN107305606A (en) * 2016-04-20 2017-10-31 中兴通讯股份有限公司 The processing method and processing device of application file and the access method of file and device
CN106933645A (en) * 2017-01-17 2017-07-07 深圳市能信安科技股份有限公司 A kind of Apk security risks automatic Static auditing system and method
CN107391169A (en) * 2017-06-09 2017-11-24 口碑控股有限公司 The dynamic updating method and device of the Android page
CN108595187A (en) * 2018-03-27 2018-09-28 北京美好人生伙伴信息技术有限公司 Method, device and the storage medium of Android installation kit integrated software development kit
CN109783138A (en) * 2018-12-05 2019-05-21 北京奇艺世纪科技有限公司 Method for splitting, device, terminal and the medium that application package is constituted
CN110442419A (en) * 2019-08-15 2019-11-12 北京字节跳动网络技术有限公司 The quick interface arrangement method and device of Android application
CN111159662A (en) * 2019-12-25 2020-05-15 郑州阿帕斯数云信息科技有限公司 Data processing method and device

Similar Documents

Publication Publication Date Title
WO2020119485A1 (en) Page display method and device, apparatus, and storage medium
CN109918166B (en) Applet processing method and device and electronic equipment
CN108984174B (en) Cross-platform application creation method, device, server and storage medium
CN111740948B (en) Data packet issuing method, dynamic updating method, device, equipment and medium
CN111367516B (en) Application interface generation method and device and electronic equipment
CN110764748B (en) Code calling method, device, terminal and storage medium
CN111309304B (en) Method, device, medium and electronic equipment for generating IDL file
CN110780874B (en) Method and device for generating information
CN111338944B (en) Remote Procedure Call (RPC) interface testing method, device, medium and equipment
CN111338623A (en) Method, device, medium and electronic equipment for developing user interface
CN112433730B (en) Code detection rule generation method and device and electronic equipment
CN109657249B (en) Automatic text replacement method and device for application program and electronic equipment
CN111506300A (en) Applet generation method, device, equipment and storage medium
CN110960855A (en) Communication protocol code updating method and device, electronic equipment and storage medium
CN116028028B (en) Request function generation method, device, equipment and storage medium
US20240095022A1 (en) Hotfix method, apparatus, device and storage medium
CN110442419B (en) Interface layout method and device for Android application
CN112416303B (en) Software development kit hot repair method and device and electronic equipment
CN112650521A (en) Software development kit SDK (software development kit) hot repair method and device and electronic equipment
CN112328841A (en) Document processing method and device, electronic equipment and storage medium
CN113761588A (en) Data verification method and device, terminal equipment and storage medium
CN111752644A (en) Interface simulation method, device, equipment and storage medium
CN111177089A (en) Method and device for generating log processing code, computer system and storage medium
CN113835718A (en) Android application package generation method and device, terminal device and medium
CN111539200B (en) Method, device, medium and electronic equipment for generating rich text

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