CN114610318A - Android application packaging method, device, equipment and storage medium - Google Patents

Android application packaging method, device, equipment and storage medium Download PDF

Info

Publication number
CN114610318A
CN114610318A CN202210268247.6A CN202210268247A CN114610318A CN 114610318 A CN114610318 A CN 114610318A CN 202210268247 A CN202210268247 A CN 202210268247A CN 114610318 A CN114610318 A CN 114610318A
Authority
CN
China
Prior art keywords
android
gradle
packaging
configuration file
application program
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
CN202210268247.6A
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.)
Ping An International Smart City Technology Co Ltd
Original Assignee
Ping An International Smart City 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 Ping An International Smart City Technology Co Ltd filed Critical Ping An International Smart City Technology Co Ltd
Priority to CN202210268247.6A priority Critical patent/CN114610318A/en
Publication of CN114610318A publication Critical patent/CN114610318A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • G06F8/425Lexical analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/10Protecting distributed programs or content, e.g. vending or licensing of copyrighted material ; Digital rights management [DRM]
    • G06F21/12Protecting executable software
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/72Code refactoring
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Multimedia (AREA)
  • Technology Law (AREA)
  • Computer Hardware Design (AREA)
  • Stored Programmes (AREA)

Abstract

The invention relates to the field of pedestal operation and maintenance, and discloses a packaging method, device, equipment and storage medium for an android application program. The method comprises the following steps: receiving and responding to a packaging instruction, and acquiring an android project to be packaged; respectively adding a Gradle sub configuration file under the root directory of each business sub item in the android item; adding a Gradle main configuration file under a root directory of an android project, and respectively introducing each Gradle sub-configuration file into the Gradle main configuration file; compiling each Gradle configuration file based on a preset template rule and a depth priority algorithm to generate a plurality of packing tasks; and respectively executing each packaging task to obtain an android application program package corresponding to the android project. According to the invention, the conflict parameters are subjected to priority coverage by adopting a depth-first algorithm in the file compiling process, so that the problem of compiling failure caused by potential parameter conflict is solved, and the packing efficiency is further improved.

Description

Android application packaging method, device, equipment and storage medium
Technical Field
The invention relates to the field of pedestal operation and maintenance, in particular to a packaging method, device, equipment and storage medium of an android application program.
Background
Gradle is a project automation building tool based on the concepts of Apache Ant and Apache Maven. The method uses a Domain Specific Language (DSL) based on Groovy to declare the item setting, abandons various complicated configurations based on Extensible Markup Language (XML), and has easy adaptability and richness to allow the universal design principle to be directly applied in construction. Industry typically packages android applications based on Gradle to generate application packages that run in the android environment.
The existing packaging method of the android application program is easy to cause compiling failure due to the conflict of partial parameters in the resource compiling process.
Disclosure of Invention
The invention mainly aims to solve the problem that the compiling fails due to parameter conflict in the conventional packaging method of the android application program.
The invention provides a packaging method of an android application program in a first aspect, which comprises the following steps:
receiving and responding to a packaging instruction input by a user, and acquiring an android project to be packaged, wherein a root directory of the android project comprises a main application program and at least one service sub-project, and each service sub-project comprises a service application program;
respectively adding a Gradle sub-configuration file under the root directory of each business sub-item, wherein each Gradle primary-level configuration file defines an external variable label, and the external variable label is used for indicating dependence required by the operation of a business application program and version information thereof;
adding a Gradle main configuration file under a root directory of the android item, and respectively introducing each Gradle sub configuration file into the Gradle main configuration file, wherein an external variable label used for indicating dependence required by operation of a main application program and version information of the dependence is defined in the Gradle main configuration file;
compiling each Gradle configuration file based on a preset template rule and a depth priority algorithm to generate a plurality of packing tasks;
and respectively executing each packaging task to obtain an android application program package corresponding to the android project.
Optionally, in a first implementation manner of the first aspect of the present invention, the compiling each Gradle configuration file to generate multiple packing tasks based on a preset template rule and a depth-first algorithm includes:
traversing each Gradle configuration file, and if the target parameter conflict exists among the Gradle configuration files, respectively calculating the path depth of the configuration file where each conflict target parameter is located;
covering the rest conflict target parameters by using the target parameters in the configuration file with the maximum path depth until the traversal is finished to obtain traversed Gradle configuration files;
and compiling each traversed Gradle configuration file respectively based on a preset template rule to obtain a plurality of packing tasks, wherein each Gradle configuration file is compiled into one packing task correspondingly.
Optionally, in a second implementation manner of the first aspect of the present invention, before compiling each Gradle configuration file to generate a plurality of packing tasks based on preset template rules and a depth-first algorithm, the method further includes:
and receiving a version updating instruction sent by a terminal, and updating the external variable tags in the Gradle sub-configuration files and the Gradle main configuration files according to the version updating instruction.
Optionally, in a third implementation manner of the first aspect of the present invention, before the respectively executing the packaging tasks to obtain the android application packages corresponding to the android projects, the method further includes:
acquiring a task file corresponding to each packaging task, and judging whether each task file is abnormal or not;
acquiring a task file with an exception, and receiving a modification command parameter input by a user;
and modifying the task file with the exception by using the modification command parameters based on the IO stream.
Optionally, in a fourth implementation manner of the first aspect of the present invention, the separately executing the packaging tasks to obtain an android application package corresponding to the android project includes:
and executing each packaging task in batches in a multithreading mode to obtain an android application program package corresponding to the android project.
Optionally, in a fifth implementation manner of the first aspect of the present invention, the method further includes:
acquiring a preset encryption and decryption dependent packet, wherein the encryption and decryption dependent packet comprises a Gradle encryption script used for encrypting a resource file and a code file, a decryption entry function and an interception function used for intercepting a Java layer system API;
and encrypting the data in the android application program package according to the Gradle encryption script, and inserting a decryption entry function and an interception function for intercepting a Java layer system API.
Optionally, in a sixth implementation manner of the first aspect of the present invention, the method further includes:
simulating an android running environment, and pre-starting the android project in the simulated android running environment based on the android application program package to obtain a target loading sequence of a plurality of class files contained in the android project in the pre-starting process;
adjusting the arrangement sequence of the plurality of class files according to the target loading sequence;
reconstructing the android application program package based on the plurality of class files after the sequence is adjusted, and starting the android project in the simulated android running environment based on the reconstructed android application program package.
The second aspect of the present invention provides a packaging apparatus for an android application, including:
the data acquisition module is used for receiving and responding to a packaging instruction input by a user and acquiring an android project to be packaged, wherein a root directory of the android project comprises a main application program and at least one service sub-project, and each service sub-project comprises a service application program;
a sub-item configuration module, configured to add a Gradle sub-configuration file under the root directory of each business sub-item, where each Gradle primary configuration file defines an external variable tag, and the external variable tag is used to indicate dependence required by business application program operation and version information thereof;
the main project configuration module is used for adding a Gradle main configuration file under a root directory of the android project and respectively introducing each Gradle sub configuration file into the Gradle main configuration file, wherein an external variable label used for indicating dependence and version information of a main application program required by operation is defined in the Gradle main configuration file;
the compiling module is used for compiling each Gradle configuration file based on preset template rules and a depth priority algorithm to generate a plurality of packing tasks;
and the packaging module is used for respectively executing each packaging task to obtain an android application program package corresponding to the android project.
Optionally, in a first implementation manner of the second aspect of the present invention, the compiling module specifically includes:
the file traversal unit is used for traversing the Gradle configuration files, and if the conflict of the target parameters among the Gradle configuration files is detected through traversal, the path depth of the configuration file where the conflict target parameters are located is calculated respectively;
the parameter covering unit is used for covering the rest conflict target parameters with the target parameters in the configuration file with the maximum path depth until the traversal is finished to obtain traversed Gradle configuration files;
and the task generating unit is used for compiling the traversed Gradle configuration files respectively based on a preset template rule to obtain a plurality of packing tasks, wherein each Gradle configuration file is correspondingly compiled into one packing task.
Optionally, in a second implementation manner of the second aspect of the present invention, the packing module is specifically configured to:
and executing each packaging task in batches in a multithreading mode to obtain an android application program package corresponding to the android project.
Optionally, in a third implementation manner of the second aspect of the present invention, the apparatus further includes a task modification module, where the task modification module specifically includes:
the file judging unit is used for acquiring the task files corresponding to the packaging tasks and judging whether the task files are abnormal or not;
the parameter receiving unit is used for acquiring the task file with the abnormality and receiving a modification command parameter input by a user;
and the parameter modifying unit is used for modifying the task file with the exception by using the modifying command parameter based on the IO stream.
Optionally, in a fourth implementation manner of the second aspect of the present invention, the apparatus further includes a package encryption module, where the package encryption module specifically includes:
the device comprises a dependent packet acquisition unit, a processing unit and a processing unit, wherein the dependent packet acquisition unit is used for acquiring a preset encryption and decryption dependent packet, and the encryption and decryption dependent packet comprises a Gradle encryption script used for encrypting a resource file and a code file, a decryption entry function and an interception function used for intercepting a Java layer system API;
and the data encryption unit is used for encrypting the data in the android application program package according to the Gradle encryption script and inserting a decryption entry function and an interception function for intercepting a Java layer system API.
Optionally, in a fifth implementation manner of the second aspect of the present invention, the apparatus further includes an item starting module, where the item starting module specifically includes:
the android system comprises a pre-starting unit, a pre-starting unit and a pre-starting unit, wherein the pre-starting unit is used for simulating an android running environment, pre-starting an android project in the simulated android running environment based on the android application program package, and obtaining a target loading sequence of a plurality of class files contained in the android project in the pre-starting process;
the sequencing unit is used for adjusting the arrangement sequence of the plurality of class files according to the target loading sequence;
and the reconstruction unit is used for reconstructing the android application program package based on the plurality of class files after the sequence is adjusted, and starting the android project in the simulated android running environment based on the reconstructed android application program package.
The third aspect of the present invention provides a packaging device for android applications, including: a memory and at least one processor, the memory having instructions stored therein; the at least one processor calls the instructions in the memory to cause the packaging device of the android application to execute the packaging method of the android application.
A fourth aspect of the present invention provides a computer-readable storage medium having stored therein instructions, which, when run on a computer, cause the computer to execute the above-mentioned packaging method for an android application.
According to the technical scheme, a packaging instruction is received and responded, an android project to be packaged is obtained, Gradle sub-configuration files are respectively added to root directories of all business sub-projects in the android project, Gradle main configuration files are added to the root directories of the android project, the Gradle sub-configuration files are respectively introduced into the Gradle main configuration files, based on preset template rules and a depth priority algorithm, the Gradle configuration files are compiled to generate a plurality of packaging tasks, namely if a plurality of conflicting parameters exist, the path depth of the file where each parameter is located is respectively calculated, and finally the parameter in the file with the maximum path depth is used as an effective parameter to generate a corresponding packaging task; and respectively executing each packaging task to obtain an android application program package corresponding to the android project. According to the invention, the conflict parameters are subjected to priority coverage by adopting a depth-first algorithm in the file compiling process, so that the problem of compiling failure caused by potential parameter conflict is solved, and the packing efficiency is further improved.
Drawings
FIG. 1 is a schematic diagram of a first embodiment of a packaging method for an android application in the embodiment of the present invention;
FIG. 2 is a diagram illustrating a second embodiment of a packaging method for an android application in the embodiment of the present invention;
FIG. 3 is a schematic diagram of a third embodiment of a packaging method for an android application in the embodiment of the present invention;
FIG. 4 is a diagram of an embodiment of a packaging apparatus for an android application in the embodiment of the present invention;
FIG. 5 is a diagram of another embodiment of a packaging apparatus for android applications in the embodiment of the present invention;
fig. 6 is a schematic diagram of an embodiment of a packaging device for an android application in the embodiment of the present invention.
Detailed Description
The embodiment of the invention provides a method, a device and equipment for packaging an android application program and a storage medium, and the packaging efficiency is higher.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims, as well as in the drawings, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that the embodiments described herein may be practiced otherwise than as specifically illustrated or described herein. Furthermore, the terms "comprises," "comprising," or "having," and any variations thereof, are intended to cover non-exclusive inclusions, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
For convenience of understanding, a specific flow of the embodiment of the present invention is described below, and referring to fig. 1, an embodiment of the method for packaging an android application in the embodiment of the present invention includes:
101. receiving and responding to a packaging instruction input by a user, and acquiring an android project to be packaged, wherein a root directory of the android project comprises a main application program and at least one business sub-project, and each business sub-project comprises a business application program;
it can be understood that, after an Android project is developed in an integrated development tool (e.g., Android Studio), source code needs to be compiled and packaged into an Android Application Package (APK) to be installed in an Android operating system, which is a compressed package in nature, and the Android project is a folder containing source code files.
For an android project, the whole project is layered according to the functions of the product, namely, specific modules are divided among different layers according to actual services or functions. Each business sub-project corresponds to different modules, for example, a product is divided into a news module, a video module, an operation advertisement module, a login and registration module and the like based on a business view angle. And the main application program, namely the shell project of the main application program in the android project, is responsible for scheduling resources and modules of the android application in the running process, so that the complete application is output.
Optionally, for an android project with complex functions, the android project further groups the modules, for example, the android project comprises two groups, namely a "module _ App" group and an "extensions" group, wherein the "module _ App" group comprises "shell engineering of each module" which has no influence on application subject construction, for example, the shell engineering of the main application program, the shell engineering of the news module, the shell engineering of the video module, and the like; while the "extensions" packet includes basic functional modules oriented in a particular variant or build configuration, such as Eguan modules, Dev modules, etc. Therefore, the structurality of the engineering project is stronger, development work of developers is facilitated, and meanwhile, the efficiency of data indexing can be improved, and the packing and compiling efficiency is improved.
Meanwhile, an entire android project includes, in addition to the above modules, android manifest xml files (global configuration files), assets folders (static resource folders), lib folders (third-party library resources), META-INF folders (security and integrity check files), res folders (resource folders), and resource arcc files (resource index files) required for packaging.
102. Respectively adding a Gradle sub-configuration file under the root directory of each business sub-item, wherein each Gradle primary-level configuration file defines an external variable label which is used for indicating dependence required by the operation of a business application program and version information thereof;
it should be understood that theoretically, android applications can be manually packaged and compiled by manually entering command line parameters in the terminal, but such packaging and compiling is not only cumbersome, but is also particularly inefficient.
Accordingly, various tools developed by humans are productivity tools for replacing human labor, and Gradle is a tool for project automation building by declaring project settings, i.e., Gradle profiles, using a Groovy-based domain-specific language.
After receiving an operation instruction indicated by a user, the terminal adds a Gradle sub-configuration file under the root directory of each service sub-item, so that the compiling parameter differential configuration of each service sub-item is performed, the sub-configuration file is defined by the user in advance according to the requirements of packing and compiling, such as the positions of an SDK (software development kit) and an NDK (non-relational database), the dependence and the version of the service sub-item required for running, the required Java source code and the required resource file are respectively provided, and the like.
103. Adding a Gradle main configuration file under a root directory of an android project, and respectively introducing each Gradle sub-configuration file into the Gradle main configuration file, wherein an external variable label used for indicating dependence and version information of a main application program required by operation is defined in the Gradle main configuration file;
it can be understood that the Gradle main configuration file is introduced into the project entry file in the android project, and the Gradle sub configuration files are respectively introduced into the Gradle main configuration file, so that a dependency chain of the configuration parameters is formed.
104. Compiling each Gradle configuration file based on a preset template rule and a depth priority algorithm to generate a plurality of packing tasks;
it can be understood that the terminal firstly traverses each of the Gradle configuration files, and if the conflict of the target parameters between the Gradle configuration files is detected through traversal, the path depth of the configuration file where each conflict target parameter is located is respectively calculated; covering the rest conflict target parameters with the target parameters in the configuration file with the maximum path depth or directly deleting the rest conflict target parameters until the traversal is finished to obtain traversed Gradle configuration files; and compiling each traversed Gradle configuration file respectively based on a preset template rule to obtain a plurality of packing tasks, wherein each Gradle configuration file is correspondingly compiled into one packing task.
For the same public module parameter declared in each grace configuration file, that is, parameter conflict occurs between the two, for example, the name of an Android item is Android, the setting.grace configuration file under the path "Android/" and the setting.grace configuration file under the path "Android/moudleappl/a/" declare the public module parameter a at the same time, the effective priority is determined according to the "depth priority algorithm", the depth priority refers to the "path depth" of the configuration file relative to the root directory of the Android item, for example, the unit path depth is "1", the file path depth corresponding to the setting.grace configuration file under the path "Android/" is 1, the path depth corresponding to the setting.grace configuration file under the path "Android/moudleappl/a/" is 3, the latter is determined to be effective during compiling, and the content of the same public module parameter is compiled into a corresponding task package, in this embodiment, the method for determining the parameter validity in the configuration file is not limited, and the conflict parameter in the file with the depth less than the maximum path depth may be directly removed, or the parameter in the file with the depth of the maximum path may be used to override other conflict parameters.
And the terminal analyzes the Gradle main configuration file and the Gradle sub configuration file depending on the Gradle main configuration file according to the compiling grammar rule, and generates corresponding packaging tasks according to the content declared in the configuration file to obtain a plurality of packaging tasks.
Optionally, before the terminal compiles each Gradle file, it may further receive a version update instruction sent by the terminal, and update the external variable tag in each Gradle configuration file according to the version update instruction.
Because the respective defined Gradle configuration files realize the distributed management of the external variables, when at least one plug-in function module carries out version updating, the corresponding plug-in function module in the Gradle configuration files can be directly updated with the external variable labels according to the version updating instruction sent by the terminal, thereby being convenient for version management and maintenance.
105. And respectively executing each packaging task to obtain an android application program package corresponding to the android project.
It can be understood that the terminal executes various packaging tasks so as to compile and package android projects according to specified packaging parameters, and obtain corresponding android application packages. Specifically, an Android resource packaging tool aapt is called to analyze Android manifest files in an Android project, resource files and xml files of a res folder in the Android project are collected, and compression and compilation are performed on the resource files and the xml files to obtain packaged resource files. In this process, a resource id is allocated and an r.java file and an arsc file are generated. Secondly, calling a compiler Java to compile the generated R.java file, thereby generating a corresponding class file; then, continuously converting the generated class file into a dex file supported by a Davik virtual machine through Javac, and combining the dex file and the compiled resource into a single unsigned apk file through an apkbuilder tool; and finally, signing the unsigned apk file and aligning to obtain the final android application package.
Preferentially, the terminal can simultaneously run each packing task based on multiple threads, and packing efficiency is improved.
Optionally, before executing each packaging task, the terminal may further obtain a task file corresponding to each packaging task, and determine whether each task file is abnormal; and if the abnormal task file exists, acquiring the abnormal task file, receiving a modification command parameter input by a user, and modifying the abnormal task file by using the modification command parameter based on the IO stream so as to ensure the normal compiling of the packaging task.
In the embodiment, the conflict parameters are subjected to priority coverage by adopting a depth-first algorithm in the file compiling process, so that the problem of compiling failure caused by potential parameter conflict is solved, and the packing efficiency is further improved.
Referring to fig. 2, a second embodiment of the packaging method for an android application in the embodiment of the present invention includes:
201. receiving and responding to a packaging instruction input by a user, and acquiring an android project to be packaged, wherein a root directory of the android project comprises a main application program and at least one business sub-project, and each business sub-project comprises a business application program;
202. respectively adding a Gradle sub-configuration file under the root directory of each business sub-item, wherein each Gradle primary-level configuration file defines an external variable label which is used for indicating dependence required by the operation of a business application program and version information thereof;
203. adding a Gradle main configuration file under a root directory of an android project, and respectively introducing each Gradle sub configuration file into the Gradle main configuration file, wherein an external variable label used for indicating dependence and version information of a main application program required by running is defined in the Gradle main configuration file;
204. compiling each Gradle configuration file based on a preset template rule and a depth priority algorithm to generate a plurality of packing tasks;
205. and respectively executing each packaging task to obtain an android application program package corresponding to the android project.
Wherein, the steps 201-205 are similar to the steps of the steps 101-105, and detailed description thereof is omitted here.
206. Simulating an android running environment, and pre-starting an android project in the simulated android running environment based on the android application program package to obtain a target loading sequence of a plurality of class files contained in the android project in the pre-starting process;
it can be understood that the terminal can simulate the android running environment through the android virtual machine and other modes, so that the packaged android application package is subjected to installation testing, and the mode of simulating the android running environment by the terminal is not limited in the embodiment.
In the pre-starting process of the application program, the terminal can sequentially load a plurality of required class files from the initial android application program package according to the starting requirement so as to finish the starting of the application program in the simulated android running environment. Therefore, in the step, the application program is started in advance through the initial android application program package, and the loading sequence of the multiple class files in the pre-starting process can be determined in the pre-starting process of the application program.
The pre-boot process of the present embodiment is substantially the same as the normal boot process of the application program. Therefore, the loading sequence of the plurality of class files in the pre-boot process is the loading sequence of the plurality of class files in the formal boot process.
207. Adjusting the arrangement sequence of the plurality of class files according to the target loading sequence;
it can be understood that, after the loading sequence of the plurality of class files in the application program starting process is obtained, the terminal adjusts the arrangement sequence of the plurality of class files according to the loading sequence, so that the arrangement sequence of the plurality of class files is the same as the loading sequence of the plurality of class files in the application program starting process.
In a specific application scenario, the arrangement order of the plurality of class files can be adjusted according to the loading order in a manual adjustment mode. In another specific application scenario, the arrangement order of the plurality of class files may also be adjusted according to the loading order by a binary processing tool with a preset format. The specific adjustment method is not limited herein. The preset format may be set according to actual conditions, and is not limited herein.
208. And reconstructing the android application program package based on the plurality of class files after the sequence is adjusted, and starting an android project in the simulated android running environment based on the reconstructed android application program package.
It can be understood that the terminal reconstructs the android application package based on the plurality of class files after the arrangement sequence is adjusted, wherein the arrangement sequence of the plurality of class files in the reconstructed android application package is the same as the loading sequence. After the android application package is reconstructed, the starting of the subsequent application program can be realized based on the reconstructed android application package.
Further, after receiving a starting instruction of the application program, the terminal starts the application program based on the android application program package with the adjusted arrangement sequence of the class files. The method comprises the steps that the class files in the reconstructed android application package are arranged in the same sequence as the loading sequence of the class files required to be loaded when the application program is started, so that when the class files in the android application program are loaded, the class files can be directly and sequentially obtained according to the loading sequence, the situation that the terminal needs to traverse all the class files in the reconstructed android application package in the starting process and can obtain the required class files to load according to needs is avoided, and the starting speed of an android project is improved.
In this embodiment, a process of quickly starting an android application package generated by packaging and compiling is described in detail, and by adjusting the arrangement sequence of class files, the loading speed of the class files is increased, and the starting speed of an android project is increased.
Referring to fig. 3, a fourth embodiment of the packaging method for an android application in the embodiment of the present invention includes:
301. receiving and responding to a packaging instruction input by a user, and acquiring an android project to be packaged, wherein a root directory of the android project comprises a main application program and at least one business sub-project, and each business sub-project comprises a business application program;
302. respectively adding a Gradle sub-configuration file under the root directory of each business sub-item, wherein each Gradle primary-level configuration file defines an external variable label which is used for indicating dependence required by the operation of a business application program and version information thereof;
303. adding a Gradle main configuration file under a root directory of an android project, and respectively introducing each Gradle sub-configuration file into the Gradle main configuration file, wherein an external variable label used for indicating dependence and version information of a main application program required by operation is defined in the Gradle main configuration file;
304. compiling each Gradle configuration file based on a preset template rule and a depth priority algorithm to generate a plurality of packing tasks;
305. and respectively executing each packaging task to obtain an android application program package corresponding to the android project.
Wherein, the steps 301-305 are similar to the execution steps of the steps 101-105, and detailed description thereof is omitted here.
306. Acquiring a preset encryption and decryption dependent packet, wherein the encryption and decryption dependent packet comprises a Gradle encryption script used for encrypting the resource file and the code file, a decryption entry function and an interception function used for intercepting a Java layer system API;
it can be understood that, in order to improve the security of the android application package, the terminal further performs encryption processing on the android application package. The method comprises the steps that a script is encrypted by a Gradle encryption script, and the script triggers the encryption of a resource file and a code file of an android application program and replaces an original plaintext file in the execution process.
307. And according to the Gradle encryption script, encrypting data in the android application program package, and inserting a decryption entry function and an interception function for intercepting a Java layer system API.
It should be understood that the encryption process includes: encrypt and replace assets directory resources, encrypt and replace res directory resources, encrypt and replace lib directory resources, encrypt and replace code files.
Specifically, the terminal executes the gradle script, so as to trigger a mergedebuggeassets function or a mergeReleaseAssets function, extract all resources of the assets directory to encrypt and replace the original plaintext file; triggering a processDebusRecources function or a processSeResources function, extracting all resources of the res directory for encryption and replacing the original plaintext file; triggering a stripDebugDebugSymbols function or a stripReleaseDebugSymbols function, extracting all resource encryption of a lib directory and replacing an original plaintext file; and triggering the mergeDexDexDebug or mergeDexRelease, extracting all classes. And finally, inserting the decryption entry function and the API for intercepting the Java layer system into the android application package.
In this embodiment, a process of encrypting the android application package is described in detail, and by encrypting the code file and the resource file, the security is further effectively improved.
With reference to fig. 4, the method for packaging an android application program in the embodiment of the present invention is described above, and a device for packaging an android application program in the embodiment of the present invention is described below, where an embodiment of the device for packaging an android application program in the embodiment of the present invention includes:
the data acquisition module 401 is configured to receive and respond to a packaging instruction input by a user, and acquire an android project to be packaged, where a root directory of the android project includes a main application program and at least one service sub-project, and each service sub-project includes a service application program;
a sub-item configuration module 402, configured to add a Gradle sub-configuration file under the root directory of each business sub-item, where each Gradle primary configuration file defines an external variable tag, and the external variable tag is used to indicate dependence required by running a business application program and version information thereof;
a main item configuration module 403, configured to add a Gradle main configuration file under a root directory of the android item, and introduce each Gradle sub configuration file into the Gradle main configuration file, where an external variable tag used for indicating dependency and version information required by running of a main application program is defined in the Gradle main configuration file;
a compiling module 404, configured to compile each Gradle configuration file to generate a plurality of packing tasks based on preset template rules and a depth-first algorithm;
and the packaging module 405 is configured to execute each packaging task respectively to obtain an android application package corresponding to the android project.
In the embodiment, the conflict parameters are subjected to priority coverage by adopting a depth-first algorithm in the file compiling process, so that the problem of compiling failure caused by potential parameter conflict is solved, and the packing efficiency is further improved.
Referring to fig. 5, another embodiment of the packaging apparatus for an android application in the embodiment of the present invention includes:
the data obtaining module 501 is configured to receive and respond to a packaging instruction input by a user, and obtain an android project to be packaged, where a root directory of the android project includes a main application program and at least one service sub-project, and each service sub-project includes a service application program;
a sub-item configuration module 502, configured to add a Gradle sub-configuration file under the root directory of each business sub-item, where each Gradle primary configuration file defines an external variable tag, and the external variable tag is used to indicate dependence required by running a business application program and version information thereof;
a main item configuration module 503, configured to add a Gradle main configuration file under a root directory of the android item, and introduce each Gradle sub configuration file into the Gradle main configuration file, where an external variable tag used for indicating dependency and version information required by running of a main application program is defined in the Gradle main configuration file;
a compiling module 504, configured to compile each Gradle configuration file to generate a plurality of packing tasks based on preset template rules and a depth-first algorithm;
a packaging module 505, configured to respectively execute each packaging task to obtain an android application package corresponding to the android project;
an encryption module 506, configured to obtain a preset encryption and decryption dependent packet, where the encryption and decryption dependent packet includes a Gradle encryption script used for encrypting the resource file and the code file, a decryption entry function, and an interception function used for intercepting a Java layer system API; and encrypting the data in the android application program package according to the Gradle encryption script, and inserting a decryption entry function and an interception function for intercepting a Java layer system API.
The project starting module 507 is configured to simulate an android running environment, and pre-start the android project in the simulated android running environment based on the android application package to obtain a target loading sequence of a plurality of class files included in the android project in a pre-starting process; adjusting the arrangement sequence of the plurality of class files according to the target loading sequence; reconstructing the android application program package based on the plurality of class files after the sequence is adjusted, and starting the android project in the simulated android running environment based on the reconstructed android application program package.
The compiling module 504 specifically includes:
the file traversing unit 5041 is configured to traverse each of the Gradle configuration files, and if a conflict of the target parameters between the Gradle configuration files is detected through traversal, respectively calculate a path depth of the configuration file in which each conflict target parameter is located;
a parameter covering unit 5042, configured to cover the remaining conflict target parameters with the target parameter in the configuration file with the maximum path depth until the traversal is completed, and obtain traversed Gradle configuration files;
and the task generating unit 5043 is configured to compile each traversed Gradle configuration file respectively based on a preset template rule to obtain multiple packing tasks, where each Gradle configuration file is compiled into one packing task correspondingly.
The packing module 505 is specifically configured to:
and executing each packaging task in batches in a multithreading mode to obtain an android application program package corresponding to the android project.
In the embodiment of the invention, the modularized design ensures that hardware of each part of the packing device of the android application program is concentrated on realizing a certain function, the performance of the hardware is realized to the maximum extent, and meanwhile, the modularized design also reduces the coupling between the modules of the device, thereby being more convenient to maintain.
Fig. 4 and 5 describe the packaging apparatus of the android application in the embodiment of the present invention in detail from the perspective of the modular functional entity, and the following describes the packaging device of the android application in the embodiment of the present invention in detail from the perspective of hardware processing.
Fig. 6 is a schematic structural diagram of a packaging apparatus for an android application, which may generate a relatively large difference due to different configurations or performances, according to an embodiment of the present invention, and may include one or more processors (CPUs) 610 (e.g., one or more processors) and a memory 620, one or more storage media 630 (e.g., one or more mass storage devices) for storing applications 633 or data 632. Memory 620 and storage medium 630 may be, among other things, transient or persistent storage. The program stored on the storage medium 630 may include one or more modules (not shown), each of which may include a series of instruction operations in the packaging apparatus 600 for android applications. Still further, the processor 610 may be configured to communicate with the storage medium 630 to execute a series of instruction operations in the storage medium 630 on the packaging device 600 for android applications.
The packaging apparatus 600 for android applications may also include one or more power supplies 640, one or more wired or wireless network interfaces 650, one or more input-output interfaces 660, and/or one or more operating systems 631, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, and the like. Those skilled in the art will appreciate that the packaging device architecture of the android application shown in FIG. 6 does not constitute a limitation of the packaging device of the android application, and may include more or fewer components than shown, or some components in combination, or a different arrangement of components.
The invention further provides a packaging device of the android application program, which comprises a memory and a processor, wherein computer readable instructions are stored in the memory, and when the computer readable instructions are executed by the processor, the processor executes the steps of the risk monitoring method of the financial product in the embodiments.
The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium, which may also be a volatile computer-readable storage medium, having stored therein instructions, which, when run on a computer, cause the computer to perform the steps of the method for risk monitoring of a financial product.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention, which is substantially or partly contributed by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a portable hard disk, a read-only memory (ROM), a Random Access Memory (RAM), a magnetic disk, an optical disk, or other various media capable of storing program codes.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. A packaging method of an android application program is characterized by comprising the following steps:
receiving and responding to a packaging instruction input by a user, and acquiring an android project to be packaged, wherein a root directory of the android project comprises a main application program and at least one service sub-project, and each service sub-project comprises a service application program;
respectively adding a Gradle sub-configuration file under the root directory of each business sub-item, wherein each Gradle primary-level configuration file defines an external variable label, and the external variable label is used for indicating dependence required by the operation of a business application program and version information thereof;
adding a Gradle main configuration file under a root directory of the android item, and respectively introducing each Gradle sub configuration file into the Gradle main configuration file, wherein an external variable label used for indicating dependence and version information of a main application program required by operation is defined in the Gradle main configuration file;
compiling each Gradle configuration file based on a preset template rule and a depth priority algorithm to generate a plurality of packing tasks;
and respectively executing each packaging task to obtain an android application program package corresponding to the android project.
2. The android application packaging method of claim 1, wherein compiling the Gradle configuration files to generate the plurality of packaging tasks based on the preset template rules and the depth-first algorithm comprises:
traversing each Gradle configuration file, and if the target parameter conflict exists among the Gradle configuration files, respectively calculating the path depth of the configuration file where each conflict target parameter is located;
covering the rest conflict target parameters by using the target parameters in the configuration file with the maximum path depth until the traversal is finished to obtain traversed Gradle configuration files;
and compiling each traversed Gradle configuration file respectively based on a preset template rule to obtain a plurality of packing tasks, wherein each Gradle configuration file is compiled into one packing task correspondingly.
3. The android application packaging method of claim 1, wherein before compiling the Gradle configuration files to generate the plurality of packaging tasks based on the preset template rules and the depth-first algorithm, the method further comprises:
and receiving a version updating instruction sent by a terminal, and updating the external variable tags in the Gradle sub-configuration files and the Gradle main configuration files according to the version updating instruction.
4. The method for packaging android applications of claim 1, further comprising, before the respectively executing the packaging tasks to obtain the android application packages corresponding to the android projects:
acquiring a task file corresponding to each packaging task, and judging whether each task file is abnormal or not;
acquiring a task file with an exception, and receiving a modification command parameter input by a user;
and modifying the task file with the exception by using the modification command parameters based on the IO stream.
5. The packaging method for the android application program of claim 1, wherein the respectively executing the packaging tasks to obtain the android application program package corresponding to the android project comprises:
and executing each packaging task in batches in a multithreading mode to obtain an android application program package corresponding to the android project.
6. The android application packaging method of claim 1, further comprising:
acquiring a preset encryption and decryption dependent packet, wherein the encryption and decryption dependent packet comprises a Gradle encryption script used for encrypting a resource file and a code file, a decryption entry function and an interception function used for intercepting a Java layer system API;
and encrypting the data in the android application program package according to the Gradle encryption script, and inserting a decryption entry function and an interception function for intercepting a Java layer system API.
7. The packaging method of android applications as claimed in any of claims 1-6, further comprising:
simulating an android running environment, and pre-starting the android project in the simulated android running environment based on the android application program package to obtain a target loading sequence of a plurality of class files contained in the android project in the pre-starting process;
adjusting the arrangement sequence of the plurality of class files according to the target loading sequence;
reconstructing the android application program package based on the plurality of class files after the sequence is adjusted, and starting the android project in the simulated android running environment based on the reconstructed android application program package.
8. An apparatus for packaging android applications, the apparatus for packaging android applications comprising:
the data acquisition module is used for receiving and responding to a packaging instruction input by a user and acquiring an android project to be packaged, wherein a root directory of the android project comprises a main application program and at least one service sub-project, and each service sub-project comprises a service application program;
a sub-item configuration module, configured to add a Gradle sub-configuration file under the root directory of each business sub-item, where an external variable tag is defined in each Gradle primary configuration file, and the external variable tag is used to indicate dependency required by business application program operation and version information thereof;
the main project configuration module is used for adding a Gradle main configuration file under a root directory of the android project and respectively introducing each Gradle sub configuration file into the Gradle main configuration file, wherein an external variable label used for indicating dependence and version information of a main application program required by operation is defined in the Gradle main configuration file;
the compiling module is used for compiling each Gradle configuration file based on preset template rules and a depth priority algorithm to generate a plurality of packing tasks;
and the packaging module is used for respectively executing each packaging task to obtain an android application program package corresponding to the android project.
9. A packaging device for android applications, the packaging device for android applications comprising: a memory and at least one processor, the memory having instructions stored therein;
the at least one processor invokes the instructions in the memory to cause the packaging device of the android application to perform the packaging method of the android application as recited in any of claims 1-7.
10. A computer readable storage medium having instructions stored thereon, wherein the instructions, when executed by a processor, implement the packaging method of an android application as claimed in any of claims 1-7.
CN202210268247.6A 2022-03-18 2022-03-18 Android application packaging method, device, equipment and storage medium Pending CN114610318A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210268247.6A CN114610318A (en) 2022-03-18 2022-03-18 Android application packaging method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210268247.6A CN114610318A (en) 2022-03-18 2022-03-18 Android application packaging method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114610318A true CN114610318A (en) 2022-06-10

Family

ID=81865403

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210268247.6A Pending CN114610318A (en) 2022-03-18 2022-03-18 Android application packaging method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114610318A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115309376A (en) * 2022-08-25 2022-11-08 北京泰迪熊移动科技有限公司 Application creation method and device, electronic equipment and storage medium
CN116069729A (en) * 2023-04-06 2023-05-05 深圳市微克科技有限公司 Intelligent document packaging method, system and medium
CN116149760A (en) * 2023-04-21 2023-05-23 广州三晶电气股份有限公司 Front-end project packaging method and device based on Vue frame

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115309376A (en) * 2022-08-25 2022-11-08 北京泰迪熊移动科技有限公司 Application creation method and device, electronic equipment and storage medium
CN115309376B (en) * 2022-08-25 2023-05-26 北京泰迪熊移动科技有限公司 Application creation method and device, electronic equipment and storage medium
CN116069729A (en) * 2023-04-06 2023-05-05 深圳市微克科技有限公司 Intelligent document packaging method, system and medium
CN116149760A (en) * 2023-04-21 2023-05-23 广州三晶电气股份有限公司 Front-end project packaging method and device based on Vue frame

Similar Documents

Publication Publication Date Title
CN114610318A (en) Android application packaging method, device, equipment and storage medium
US11354144B2 (en) Java native interface and windows universal app hooking
CN107943486B (en) Multi-language code compiling method, multi-language code distributing method, multi-language code compiling device, multi-language code distributing device and multi-language code system
US9760365B2 (en) Systems, methods, and computer program products for a software build and load process using a compilation and deployment service
CN106897609B (en) Method and device for monitoring dynamically loaded application program
CN110941528B (en) Log buried point setting method, device and system based on fault
US10514898B2 (en) Method and system to develop, deploy, test, and manage platform-independent software
US11113050B2 (en) Application architecture generation
CN106648755B (en) Method and device for dynamically loading dex in android art environment
CN113342323B (en) Method and device for online development of software
Maudoux et al. Correct, efficient, and tailored: The future of build systems
CN115080060A (en) Application program distribution method, device, equipment, storage medium and program product
Alonso et al. Embracing IaC through the DevSecOps philosophy: Concepts, challenges, and a reference framework
CN112114896A (en) Plug-in framework and method for service function expansion
CN110333872B (en) Application processing method, device, equipment and medium
US9396239B2 (en) Compiling method, storage medium and compiling apparatus
CN108304230B (en) Implementation method and device for adjusting application attribute and readable storage medium
CN115756424A (en) Method, device and equipment for generating MVP (multifunction vehicle platform) code
CN116034362B (en) Extended integrity monitoring of container images
CN109857447A (en) A kind of automation packaging method of the Android APP application packet batch with security signature
CN106547519B (en) Information processing method and system
CN112543104A (en) Application program packaging method and device, electronic equipment and storage medium
CN111399858A (en) Android application package packaging method, equipment, storage medium and device
CN112445513A (en) Installation package processing method and device
WO2023060525A1 (en) Methods and systems for generating verifiable software releases

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