Application program compilation method, device, electronic device and storage medium
Patent Information
- Application Number
- CN201910903271.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-09-24
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2039-09-24
AI Technical Summary
When developing applications under different operating system environments, the lack of a convenient integrated development environment (IDE) leads to a lack of necessary dependencies in the code compilation process and an error is reported.
By obtaining the target application source code and obfuscating configuration files, generating a compilation package and compiling it with preset compilation tools under the second operating system, replacing the system in the source code with the source code to resolve compilation errors.
It solves the problem that the code compilation process lacks necessary dependencies and reports errors, so that the source code can be compiled under the appropriate compilation tools, and improves the development efficiency of the application.
Smart Images

Figure CN110659031B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of software technology, and in particular to a method, device, electronic device and storage medium for compiling an application. Background Art
[0002] Microsoft's Windows, Apple's MacOS, and open source Linux are the most popular operating systems on the market today, with a large number of application software and users. Each operating system has its own characteristics and an independent development and usage environment. Especially for developer users, when developing application software for different platforms, it is necessary to use multiple software operating systems at the same time. For example, the Linux-based Android operating system is currently the most important operating system used by smart terminal devices such as mobile phones, and developer users have developed a large number of applications on the Android system.
[0003] In the prior art, developers generally develop applications directly in a source code system environment with complete resources. Since the resource library in the source code system environment is complete, it is convenient to call and compile the application source code and compilation errors are less likely to occur.
[0004] However, at the same time, in some operating system environments, there is a lack of a convenient integrated development environment (IDE). When developer users load the application source code into an IDE in other operating system environments for development, there is a problem of errors reported due to the lack of necessary dependencies in the code compilation process due to the strong coupling between the source code and the operating system environment. Summary of the invention
[0005] The present invention provides a method, device, electronic device and storage medium for compiling an application program, which are used to solve the problem of error reporting due to lack of necessary dependencies in the code compilation process.
[0006] According to a first aspect of an embodiment of the present disclosure, the present invention provides a method for compiling an application program, which is applied to an electronic device, wherein the electronic device is equipped with a first operating system and a second operating system, and the second operating system is loaded with a preset compilation tool, and the method includes:
[0007] Obtaining target application source code and an obfuscation configuration file, wherein the obfuscation configuration file includes identification information of system-dependent source code and identification information of non-system-dependent source code;
[0008] generating a compilation package under the first operating system;
[0009] Generate a target compilation package under the second operating system.
[0010] Optionally, generating a compilation package under the first operating system includes:
[0011] The target application source code is compiled according to the obfuscation configuration file under the first operating system to generate a compiled package.
[0012] Optionally, generating a target compilation package under the second operating system includes:
[0013] The non-system-dependent class files correspond to the non-system-dependent source code of the target application; the non-system-dependent class files are deleted to form a system-dependent compilation package;
[0014] The preset compilation tool is used under the second operating system to compile the target application source code according to the system-dependent compilation package and the non-system-dependent source code to generate a target compilation package.
[0015] Optionally, compiling the target application source code according to the obfuscation configuration file to generate a compilation package includes:
[0016] Generate a system-dependent class file from the source code corresponding to the identification information of the system-dependent source code in the obfuscation configuration file;
[0017] Generate a non-system-dependent class file from the source code corresponding to the identification information of the non-system-dependent source code in the obfuscation configuration file;
[0018] A compilation package is generated by using the system-dependent class files and the non-system-dependent class files.
[0019] Optionally, the method of using the preset compilation tool under the second operating system to compile the target application source code according to the system-dependent compilation package and the non-system-dependent source code to generate the target compilation package further includes:
[0020] Using the preset compilation tool to create a target application project under the second operating system;
[0021] The system-dependent compilation package and the non-system-dependent source code are loaded into the target application project.
[0022] Optionally, the step of loading the system-dependent compilation package and the non-system-dependent source code into the target application project includes:
[0023] Determine corresponding positions of the system-dependent compilation package and the non-system-dependent source code in the target application source code;
[0024] The system-dependent compilation package and the non-system-dependent source code are loaded into the target application project according to the corresponding positions.
[0025] Optionally, deleting the non-system-dependent class files to form a system-dependent compilation package includes:
[0026] Decompiling the compiled package to obtain system-dependent class files and non-system-dependent class files;
[0027] Deleting the non-system dependent class files;
[0028] The system-dependent class file is compiled to generate the system-dependent compiled package.
[0029] Optionally, the first operating system or the second operating system is one of Google Android operating system, Microsoft Windows operating system, Apple iOS operating system, Apple WatchOS operating system, Apple iPadOS operating system, Apple MacOS operating system, Linux operating system, and Huawei Hongmeng operating system, and / or the preset compilation tool is an IDE tool.
[0030] According to a second aspect of an embodiment of the present disclosure, the present invention provides a compiling device for an application program, applied to an electronic device, wherein the electronic device is equipped with a first operating system and a second operating system, and the second operating system is loaded with a preset compiling tool, wherein the device comprises:
[0031] An acquisition module, in which a user acquires the target application source code and an obfuscation configuration file, wherein the obfuscation configuration file includes identification information of system-dependent source code and identification information of non-system-dependent source code;
[0032] A first generating module, used to generate a compilation package under the first operating system;
[0033] The second generating module is used to generate a target compilation package under a second operating system.
[0034] Optionally, the first generating module is specifically configured to:
[0035] The target application source code is compiled according to the obfuscation configuration file under the first operating system to generate a compiled package.
[0036] Optionally, the second generating module is specifically used to:
[0037] The non-system-dependent class files correspond to the non-system-dependent source code of the target application; the non-system-dependent class files are deleted to form a system-dependent compilation package;
[0038] The preset compilation tool is used under the second operating system to compile the target application source code according to the system-dependent compilation package and the non-system-dependent source code to generate a target compilation package.
[0039] Optionally, when the generation module compiles the target application source code according to the obfuscation configuration file to generate a compilation package, it is specifically used to:
[0040] Generate a system-dependent class file from the source code corresponding to the identification information of the system-dependent source code in the obfuscation configuration file;
[0041] Generate a non-system-dependent class file from the source code corresponding to the identification information of the non-system-dependent source code in the obfuscation configuration file;
[0042] A compilation package is generated by using the system-dependent class files and the non-system-dependent class files.
[0043] Optionally, the application program compiling device further includes:
[0044] A creation module, used to create a target application project using the preset compilation tool under a second operating system;
[0045] The loading module is used to load the system-dependent compilation package and the non-system-dependent source code into the target application project.
[0046] Optionally, the loading module is specifically used to:
[0047] Determine corresponding positions of the system-dependent compilation package and the non-system-dependent source code in the target application source code;
[0048] The system-dependent compilation package and the non-system-dependent source code are loaded into the target application project according to the corresponding positions.
[0049] Optionally, when deleting the non-system-dependent class files to form a system-dependent compilation package, the generating module is specifically used to:
[0050] Decompiling the compiled package to obtain system-dependent class files and non-system-dependent class files;
[0051] Deleting the non-system dependent class files;
[0052] The system-dependent class file is compiled to generate the system-dependent compiled package.
[0053] Optionally, in the compilation device of the application, the first operating system or the second operating system is one of Google Android operating system, Microsoft Windows operating system, Apple iOS operating system, Apple WatchOS operating system, Apple iPadOS operating system, Apple MacOS operating system, Linux operating system, and Huawei Hongmeng operating system, and / or the preset compilation tool is an IDE tool.
[0054] According to a third aspect of the embodiments of the present disclosure, the present invention provides an electronic device, including: a memory, a processor, and a computer program;
[0055] The computer program is stored in the memory and is configured to be executed by the processor to implement the method for compiling an application program as described in any one of the first aspects of the embodiments of the present disclosure.
[0056] According to the fourth aspect of the embodiments of the present disclosure, the present invention provides a computer-readable storage medium, in which computer execution instructions are stored. When the computer execution instructions are executed by a processor, they are used to implement the compilation method of the application as described in any one of the first aspect of the embodiments of the present disclosure.
[0057] The application compilation method, device, electronic device and storage medium provided by the present invention obtain the target application source code and an obfuscation configuration file, wherein the obfuscation configuration file includes identification information of the system-dependent source code and identification information of the non-system-dependent source code; compile the target application source code according to the obfuscation configuration file under the first operating system to generate a compilation package, wherein the compilation package includes system-dependent class files and non-system-dependent class files, and the non-system-dependent class files correspond to the non-system-dependent source code of the target application; delete the non-system-dependent class files to form a system-dependent compilation package; and compile the target application source code according to the system-dependent compilation package and the non-system-dependent source code using the preset compilation tool under the second operating system to generate a target compilation package. Since the system-dependent source code in the source code is replaced by the system-dependent compilation package, the problem of error reporting due to lack of necessary dependencies in the code compilation process is solved, so that the source code can be compiled under a suitable compilation tool, thereby improving the development efficiency of the application. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0059] Figure 1 A flowchart of a method for compiling an application provided by an embodiment of the present invention;
[0060] Figure 2 A flowchart of a method for compiling an application provided by another embodiment of the present invention;
[0061] Figure 3 for Figure 2 The flowchart of step S209 in the embodiment shown;
[0062] Figure 4A schematic diagram of the structure of a compiling device for an application provided by an embodiment of the present invention;
[0063] Figure 5 A schematic diagram of the structure of a compiling device for an application provided by another embodiment of the present invention;
[0064] Figure 6 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention.
[0065] The above drawings show clear embodiments of the present disclosure, which will be described in more detail below. These drawings and text descriptions are not intended to limit the scope of the present disclosure in any way, but to illustrate the concepts of the present disclosure to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0066] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0067] First, the terms involved in the present invention are explained:
[0068] Operating system: An operating system (OS) is a program that manages the hardware and software resources of electronic devices. An operating system can handle basic tasks such as managing and configuring memory, determining the priority of system resource supply and demand, controlling input and output devices, operating networks, and managing file systems. The operating system also provides an operating interface for users to interact with the system. The applications used by users run on a specific operating system and are developed based on a specific operating system. Applications on different operating systems are independent of each other and cannot be used interchangeably. Therefore, developers need to develop applications based on different operating systems for different operating systems.
[0069] Compilation tools: In the field of software development technology, compilation refers to the translation process from source code (usually a high-level language) to target code (usually a low-level language or machine language) that can be directly executed by a computer compiler or virtual machine. The tools used to complete this translation process can be collectively referred to as compilation tools. When developers develop applications, they generally use high-level languages such as JAVA and C++ to develop source code, and then use compilation tools to compile it into target code that can be recognized and run by the computer, such as an executable file. Compilation tools include direct tools for "translating" high-level codes, as well as indirect tools for implementing code marking, debugging, management, as well as auxiliary functions such as graphical interface display and auxiliary editing.
[0070] The application scenarios of the embodiments of the present invention are explained below:
[0071] The electronic device provided in an embodiment of the present invention may be a computer, which is equipped with a first operating system and a second operating system. The first operating system may be an Android operating system running through a virtual machine, and the second operating system may be a Windows operating system. The second operating system is loaded with a compilation tool preset for compiling Android system applications.
[0072] In a specific application scenario provided by an embodiment of the present invention, a developer user needs to develop an application that runs in an Android operating system environment. Due to the lack of suitable compilation tools in the Android operating system environment, the compilation efficiency of the application is low, and the corresponding auxiliary functions are lacking, which affects the development efficiency of the application. Therefore, using the compilation method of the application provided by the embodiment of the present invention, firstly, the target application source code is compiled in the Android operating system environment. Since the Android operating system environment contains complete application dependencies, the target application can be compiled smoothly to generate a compilation package, which includes system-dependent class files and non-system-dependent class files, and then the non-system-dependent files in the compilation package are deleted to form a system-dependent compilation package; the system-dependent compilation package is loaded into the compilation tool in the second operating system. Since the second operating system is a Windows operating system, there are more suitable compilation tools in the Windows operating system environment. Therefore, the compilation tool under the Windows operating system is used to load the system-dependent compilation package, and then the non-system-dependent source code is loaded. The two are compiled together to achieve the compilation of the target application source code.
[0073] In an application scenario of the application compilation method provided by an embodiment of the present invention, the target application source code is compiled according to an obfuscation configuration file under a first operating system to generate a compilation package, and non-system-dependent class files in the compilation package are deleted to form a system-dependent compilation package; and a preset compilation tool is used to compile the target application source code according to the system-dependent compilation package and the non-system-dependent source code under a second operating system to generate a target compilation package. Since the system-dependent source code in the source code is replaced by the system-dependent compilation package, the problem of errors reported due to lack of necessary dependencies in the code compilation process is solved, so that the source code can be compiled under a suitable compilation tool, thereby improving the development efficiency of the application.
[0074] The following specific embodiments are used to describe in detail the technical solutions of the present invention and how the technical solutions of the present application solve the above-mentioned technical problems. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present invention will be described below in conjunction with the accompanying drawings.
[0075] Figure 1 The flowchart of the method for compiling an application provided by one embodiment of the present invention is a method for compiling an application provided by this embodiment. The execution subject of the method for compiling an application provided by this embodiment is a compiling device for the application. The compiling device for the application is located in an electronic device. Therefore, the method for compiling an application provided by this embodiment is applied to the electronic device. The electronic device is equipped with a first operating system and a second operating system. The second operating system is loaded with a preset compiling tool, such as Figure 1 As shown, the application compilation method provided in this embodiment includes the following steps:
[0076] Step S101, obtaining the target application source code and an obfuscation configuration file, wherein the obfuscation configuration file includes identification information of the system-dependent source code and identification information of the non-system-dependent source code.
[0077] The target application source code includes system-dependent source code and non-system-dependent source code. System-dependent source code is code items that need to rely on the operating system environment to compile; non-system-dependent source code is code items that can be compiled without relying on the operating system environment. Due to the differences between different operating systems, applications in different operating system environments can only be compiled in the operating system environment, otherwise the compilation may fail due to the presence of system-dependent source code in the source code.
[0078] For example, in the target application source code, function A of the Android operating system is called, and the code item corresponding to function A is the system-dependent source code. At this time, when the application source code is compiled under the Android operating system, since there is a complete function resource library in the Android operating system environment, the system-dependent source code can obtain the support of the function resource library in the Android operating system environment. Therefore, the source code of the application can be successfully compiled; if the source code of the application is compiled under other operating system environments, since the operating system environment does not have the function resource library in the Android operating system environment, function A in the source code cannot be supported by the function resource library. During the compilation process of the application, compilation failure will occur due to reference to a non-existent function resource library.
[0079] The obfuscation configuration file includes identification information of system-dependent source code and non-system-dependent source code. For example, the identification information can be the code line identification, which is used to locate a specific code line, or the file name of a referenced file in the source code. Based on the identification information in the obfuscation configuration file, it is possible to determine which system-dependent source code and which non-system-dependent source code are in the target application source code.
[0080] Step S102: Generate a compilation package under the first operating system.
[0081] Optionally, the first operating system environment is the native environment of the target application. Under the first operating system environment, the target application can obtain the support of a complete functional resource library and can also complete the normal compilation process. Under the first operating system environment, the obfuscation configuration file is first used to determine the identification of the system-dependent source code and the non-system-dependent source code in the source code of the target application. Then, the system-dependent source code and the non-system-dependent source code are compiled using code compilation technology to generate a compilation package. In the compilation package, the corresponding system-dependent source code and the non-system-dependent source code include system-dependent class files and non-system-dependent class files, respectively, that is, the system-dependent source code is compiled to generate system-dependent class files; the non-system-dependent source code is compiled to generate non-system-dependent class files.
[0082] Optionally, the system-dependent class file includes the system-dependent source code in the target application source code and the corresponding functional resource library interface, which is used to implement the functions corresponding to the system-dependent source code. In the non-system-dependent file, there is no content that needs to be called, and it occupies the corresponding space and generates redundancy. Therefore, after obtaining the compilation package, the system-dependent class file in the compilation package can be deleted, which can reduce the capacity of the compilation package and improve the compilation efficiency of the target application.
[0083] After deleting the non-system-dependent class files in the compilation package, a system-dependent compilation package is formed. The system-dependent compilation package can implement the functions corresponding to the system-dependent source code.
[0084] Step S103: Generate a target compilation package under the second operating system.
[0085] Optionally, after obtaining the system-dependent compilation package, the system-dependent compilation package and the non-system-dependent source code are compiled using a compilation tool under the second operating system to generate a target compilation package. Normally, if the source code is directly compiled using a compilation tool under the second operating system, the compiler in the compilation tool will find during the compilation process that the system-dependent source code references a functional resource library in the first operating system environment, while the functional resource library does not exist in the second operating system environment. Therefore, the compiler will report an error, resulting in a compilation failure. After the system-dependent source code generates the corresponding system-dependent compilation package, the compiler can only access the functional interface of the system-dependent class file in the system-dependent compilation package, and will no longer check the internal code of the system-dependent class file, thereby avoiding compilation failures caused by the system-dependent source code referencing a non-existent functional resource library. Since the system-dependent compilation package contains all the contents of the system-dependent source code, compiling the system-dependent compilation package and the non-system-dependent source code can generate a target compilation package with the same function as the target application source code.
[0086] Optionally, the first operating system or the second operating system is one of Google Android operating system, Microsoft Windows operating system, Apple iOS operating system, Apple WatchOS operating system, Apple iPadOS operating system, Apple MacOS operating system, Linux operating system, and Huawei Hongmeng operating system, and / or the preset compilation tool is an IDE tool.
[0087] In this embodiment, by obtaining the target application source code and the obfuscation configuration file, the obfuscation configuration file includes identification information of the system-dependent source code and identification information of the non-system-dependent source code; compiling the target application source code according to the obfuscation configuration file under the first operating system to generate a compilation package, the compilation package includes system-dependent class files and non-system-dependent class files, and the non-system-dependent class files correspond to the non-system-dependent source code of the target application; deleting the non-system-dependent class files to form a system-dependent compilation package; using a preset compilation tool under the second operating system to compile the target application source code according to the system-dependent compilation package and the non-system-dependent source code to generate a target compilation package. Since the system-dependent source code in the source code is replaced by the system-dependent compilation package, the problem of errors reported due to lack of necessary dependencies in the code compilation process is solved, so that the source code can be compiled under a suitable compilation tool, thereby improving the development efficiency of the application.
[0088] Figure 2 A flowchart of a method for compiling an application program provided by another embodiment of the present invention is shown in FIG. Figure 2As shown, the compiling method of the application provided in this embodiment is Figure 1 On the basis of the application compilation method provided in the illustrated embodiment, step S102 is further refined, and the process of creating and loading the target application project before step S103 is also included. The application compilation method provided in this embodiment includes the following steps:
[0089] Step S201, obtaining the target application source code and an obfuscation configuration file, wherein the obfuscation configuration file includes identification information of the system-dependent source code and identification information of the non-system-dependent source code.
[0090] Step S202, generating a system-dependent class file from the source code corresponding to the identification information of the system-dependent source code in the obfuscation configuration file.
[0091] The obfuscation configuration file includes the identification information of the system-dependent source code and the identification information of the non-system-dependent source code, which is used to identify which code items in the target application source code need to rely on the operating system environment to compile and which do not. By using the identification information in the obfuscation configuration file, the system-dependent source code is compiled to generate the corresponding system-dependent class file, which can realize the function of the system-dependent source code.
[0092] Specifically, the code compilation obfuscation technology is used to compile the system-dependent source code to generate a system-dependent class file. Optionally, the code compilation obfuscation technology includes Java obfuscation technology, through which the source code of the application can be compiled into a class file. The internal source code of the class file compiled by Java obfuscation technology is obfuscated to prevent the application source code from being viewed and parsed, thereby ensuring the security of the application source code. At the same time, the class file retains the corresponding functional interface, and the functions of the source code are implemented through the functional interface.
[0093] Since system-dependent class files are compiled using obfuscation compilation technology, the source code inside them cannot be viewed or parsed, and the functions corresponding to the system-dependent source code can only be implemented through corresponding functional interfaces. Therefore, the code execution process inside the system-dependent class files is isolated from the outside world. When compiling the target application through the system-dependent file, it can avoid the compilation failure of the target application due to problems inside the dependent class file.
[0094] Step S203, generating a non-system dependent class file from the source code corresponding to the identification information of the non-system dependent source code in the obfuscation configuration file.
[0095] Accordingly, by obfuscating the identification information in the configuration file, the non-system dependent source code is compiled using code compilation obfuscation technology to generate corresponding non-system dependent class files, which can implement the functions of the non-system dependent source code.
[0096] In this embodiment, step S202 and step S203 are independent of each other and have no coupling relationship. Therefore, step S202 and step S203 can be executed successively, and the order of the two can be interchanged; they can also be executed simultaneously, and the execution order of step S202 and step S203 is not specifically limited here.
[0097] Step S204: Generate a compilation package using the system-dependent class files and the non-system-dependent class files.
[0098] After compiling and generating system-dependent class files and non-system-dependent class files, in order to facilitate the management of compiled files, the system-dependent class files and non-system-dependent class files are automatically packaged into a compiled package. Optionally, the compiled package packages the system-dependent class files and non-system-dependent class files into a compressed package by compression packaging, and optionally, the type of the compressed package is jar.
[0099] Step S205 , decompile the compiled package to obtain system-dependent class files and non-system-dependent class files.
[0100] Specifically, since the system-dependent class files and non-system-dependent class files cannot be added, modified, deleted, etc. in the compiled package, the compiled package is decompiled to obtain the system-dependent class files and non-system-dependent class files in the compiled package, so that the system-dependent class files and non-system-dependent class files are in a state where they can be added, modified, deleted, etc. Optionally, decompilation includes decompression, and the class files compressed in the compiled package are released by decompression to obtain the system-dependent class files and non-system-dependent class files.
[0101] Step S206, deleting non-system dependent class files.
[0102] In the non-system dependent files, since there are no system dependencies of the first operating system, the source code can be directly used for compilation, modification, debugging, etc. in the non-first operating system environment, which is more convenient and reliable. At the same time, the existence of non-system dependent files occupies corresponding space, generates redundancy, and reduces the efficiency of compiling the target application. Therefore, after obtaining the compilation package, the system dependent class files in the compilation package can be deleted, which can reduce the capacity of the compilation package and improve the compilation efficiency of the target application.
[0103] Step S207, compile the system-dependent class files to generate a system-dependent compiled package.
[0104] After deleting the non-system dependent class files, recompile the system dependent class files to generate a system dependent compiled package for use in subsequent compilation of the target application. Optionally, the method for recompiling the system dependent class files includes: packaging and compressing the system dependent classes into a compressed package as a compiled package. Optionally, the type of the compressed package is jar.
[0105] Step S208: Using a preset compilation tool to create a target application project under the second operating system.
[0106] Optionally, the second operating system is one of Google Android operating system, Microsoft Windows operating system, Apple iOS operating system, Apple WatchOS operating system, Apple iPadOS operating system, Apple MacOS operating system, Linux operating system, and Huawei Hongmeng operating system. Optionally, the preset compilation tool is an IDE tool. In the IDE tool, in order to better manage the compilation process of the target application, a target application project is first created. The target application project includes the configuration information required to generate the target compilation package, such as: the target compilation package generation location, the source code location, and the library file location.
[0107] Step S209: Load the system-dependent compilation package and the non-system-dependent source code into the target application project.
[0108] Loading the system-dependent compilation package and non-system-dependent source code into the target application project is equivalent to loading the target application source code into the target application project. Afterwards, you can use the features of the IDE tool to edit, debug, and display the non-system-dependent source code. Due to the rich functions of the IDE tool, it is more efficient and convenient than debugging and compiling in the native operating system environment of the target application, such as the Android operating system. This achieves the purpose of quickly debugging and compiling the target application and generating the target compilation package.
[0109] like Figure 3 As shown, step S209 specifically includes the following specific execution steps:
[0110] Step S2091, determining corresponding positions of the system-dependent compilation package and the non-system-dependent source code in the target application source code.
[0111] Specifically, the obfuscation configuration file includes marking information of system-dependent source code and non-system-dependent source code. According to the obfuscation configuration file, the corresponding positions of the system-dependent compilation package and the non-system-dependent source code in the target application source code are determined, which is equivalent to using the system-dependent compilation package and the non-system-dependent source code to restore the content of the target application source code, so as to implement the functions corresponding to the target application source code.
[0112] Step S2092: Load the system-dependent compilation package and the non-system-dependent source code into the target application project according to the corresponding positions.
[0113] According to the corresponding positions of the system-dependent compilation package and the non-system-dependent source code in the target application source code, the system-dependent compilation package and the non-system-dependent source code are recombined and loaded into the target application project, so that the target application project can realize the functions of the target application and avoid compilation errors caused by the system-dependent source code.
[0114] Step S210 , using a preset compilation tool under the second operating system to compile the target application source code according to the system-dependent compilation package and the non-system-dependent source code to generate a target compilation package.
[0115] In this embodiment, the implementation of step 201 and step 210 is the same as that of the present invention. Figure 2 The implementation methods of step 101 and step 103 in the illustrated embodiment are the same and will not be described in detail here.
[0116] Figure 4 A schematic diagram of a compiling device for an application provided by an embodiment of the present invention is shown in FIG. Figure 4 As shown, the application compilation device 4 provided in this embodiment is applied to an electronic device, the electronic device is equipped with a first operating system and a second operating system, the second operating system is loaded with a preset compilation tool, and the device includes:
[0117] The acquisition module 41 is used to acquire the target application source code and an obfuscation configuration file, wherein the obfuscation configuration file includes identification information of the system-dependent source code and identification information of the non-system-dependent source code.
[0118] A first generating module 42, used to generate a compilation package under a first operating system;
[0119] The second generating module 43 is used to generate a target compilation package under the second operating system.
[0120] The acquisition module 41, the first generation module 42, and the second generation module 43 are connected in sequence. The application compilation method provided in this embodiment can be executed as follows: Figure 1 The technical solution of the method embodiment shown has similar implementation principles and technical effects, which will not be repeated here.
[0121] Figure 5 A schematic diagram of the structure of a compiling device for an application program provided by another embodiment of the present invention is shown in FIG. Figure 5 As shown, the application compilation device 5 provided in this embodiment is applied to an electronic device, the electronic device is equipped with a first operating system and a second operating system, the second operating system is loaded with a preset compilation tool, and the application compilation device 5 provided in this embodiment is Figure 4 The application compilation device provided in the illustrated embodiment further includes a creation module 51 and a loading module 52 .
[0122] Furthermore, when the first generating module 42 compiles the target application source code according to the obfuscation configuration file to generate a compiled package, it is specifically used to:
[0123] Generate system-dependent class files from the source code corresponding to the identification information of the system-dependent source code in the obfuscation configuration file. Generate non-system-dependent class files from the source code corresponding to the identification information of the non-system-dependent source code in the obfuscation configuration file. Generate a compilation package using system-dependent class files and non-system-dependent class files.
[0124] Furthermore, when deleting the non-system dependent class files to form a system dependent compiled package, the first generating module 42 is specifically used to: decompile the compiled package to obtain system dependent class files and non-system dependent class files, delete the non-system dependent class files, and compile the system dependent class files to generate a system dependent compiled package.
[0125] Furthermore, the creation module 51 is used to create a target application project using a preset compilation tool under the second operating system. The loading module 52 is used to load the system-dependent compilation package and the non-system-dependent source code into the target application project.
[0126] Furthermore, the loading module 52 is specifically used to determine the corresponding positions of the system-dependent compiled package and the non-system-dependent source code in the target application source code, and load the system-dependent compiled package and the non-system-dependent source code into the target application project according to the corresponding positions.
[0127] Furthermore, in this embodiment, the first operating system or the second operating system is one of Google Android operating system, Microsoft Windows operating system, Apple iOS operating system, Apple WatchOS operating system, Apple iPadOS operating system, Apple MacOS operating system, Linux operating system, and Huawei Hongmeng operating system, and / or the preset compilation tool is an IDE tool.
[0128] The application compilation method provided in this embodiment can be executed as follows: Figure 2 and Figure 3 The technical solution of the method embodiment shown has similar implementation principles and technical effects, which will not be repeated here.
[0129] Figure 6 A schematic diagram of an electronic device provided by an embodiment of the present invention is shown in FIG. Figure 6 As shown, the electronic device provided in this embodiment includes: a memory 601, a processor 602 and a computer program.
[0130] The computer program is stored in the memory 601 and is configured to be executed by the processor 602 to implement the present invention. Figure 1-Figure 2 A method for compiling an application provided in any one of the corresponding embodiments.
[0131] The memory 601 and the processor 602 are connected via a bus 603 .
[0132] For related instructions, please refer to Figure 1-Figure 2 The relevant descriptions and effects corresponding to the steps are understood, and no further elaboration is given here.
[0133] One embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, which is executed by a processor to implement the present invention. Figure 1-Figure 2 A method for compiling an application provided in any one of the corresponding embodiments.
[0134] Among them, the computer-readable storage medium may be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
[0135] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules is only a logical function division, and there may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.
[0136] Those skilled in the art will readily appreciate other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses or adaptations of the present invention that follow the general principles of the present invention and include common knowledge or customary techniques in the art that are not disclosed by the present invention. The description and examples are to be considered exemplary only, and the true scope and spirit of the present invention is indicated by the following claims.
[0137] It should be understood that the present invention is not limited to the exact construction that has been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.
Claims
1. A method for compiling an application, characterized in that: The method is applied to an electronic device, the electronic device is equipped with a first operating system and a second operating system, the second operating system is loaded with a preset compilation tool, and the method includes: Obtaining target application source code and an obfuscation configuration file, wherein the obfuscation configuration file includes identification information of system-dependent source code and identification information of non-system-dependent source code; generating a compilation package under the first operating system; Generate a target compilation package under the second operating system; Generating a compilation package under the first operating system includes: Compiling the target application source code according to the obfuscation configuration file under the first operating system to generate a compilation package; Generate a target compilation package under the second operating system, including: The non-system-dependent class files correspond to the non-system-dependent source code of the target application; the non-system-dependent class files are deleted to form a system-dependent compilation package; The preset compilation tool is used under the second operating system to compile the target application source code according to the system-dependent compilation package and the non-system-dependent source code to generate a target compilation package.
2. The method according to claim 1, characterized in that The step of compiling the target application source code according to the obfuscation configuration file to generate a compilation package includes: Generate a system-dependent class file from the source code corresponding to the identification information of the system-dependent source code in the obfuscation configuration file; Generate a non-system-dependent class file from the source code corresponding to the identification information of the non-system-dependent source code in the obfuscation configuration file; A compilation package is generated by using the system-dependent class files and the non-system-dependent class files.
3. The method according to claim 1, characterized in that Before the target compilation package is generated by using the preset compilation tool to compile the target application source code according to the system-dependent compilation package and the non-system-dependent source code under the second operating system, the method further includes: Using the preset compilation tool to create a target application project under the second operating system; The system-dependent compilation package and the non-system-dependent source code are loaded into the target application project.
4. The method according to claim 3, characterized in that The step of loading the system-dependent compilation package and the non-system-dependent source code into the target application project includes: Determine corresponding positions of the system-dependent compilation package and the non-system-dependent source code in the target application source code; The system-dependent compilation package and the non-system-dependent source code are loaded into the target application project according to the corresponding positions.
5. The method according to claim 1, characterized in that The deleting the non-system dependent class files to form a system dependent compilation package includes: Decompiling the compiled package to obtain system-dependent class files and non-system-dependent class files; Deleting the non-system dependent class files; The system-dependent class file is compiled to generate the system-dependent compiled package.
6. The method according to any one of claims 1 to 5, characterized in that: The first operating system or the second operating system is one of Google Android operating system, Microsoft Windows operating system, Apple iOS operating system, Apple WatchOS operating system, Apple iPadOS operating system, Apple MacOS operating system, Linux operating system, and Huawei Hongmeng operating system, and / or the preset compilation tool is an IDE tool.
7. An application compilation device, characterized in that: The device is applied to an electronic device, the electronic device is equipped with a first operating system and a second operating system, the second operating system is loaded with a preset compilation tool, and the device includes: An acquisition module, in which a user acquires the target application source code and an obfuscation configuration file, wherein the obfuscation configuration file includes identification information of system-dependent source code and identification information of non-system-dependent source code; A first generating module, used to generate a compilation package under the first operating system; A second generation module, used for generating a target compilation package under a second operating system; The first generating module is specifically used to: compile the target application source code according to the obfuscation configuration file under the first operating system to generate a compilation package; The second generating module is specifically used to: correspond the non-system dependent class file to the non-system dependent source code of the target application; delete the non-system dependent class file to form a system dependent compiled package; The preset compilation tool is used under the second operating system to compile the target application source code according to the system-dependent compilation package and the non-system-dependent source code to generate a target compilation package.
8. An electronic device, characterized in that: include: Memory, processor and computer program; The computer program is stored in the memory and is configured to be executed by the processor to implement the method for compiling an application program according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method for compiling an application program according to any one of claims 1 to 6.
Citation Information
Patent Citations
Generation method and device of native application program and mobile terminal
CN109976728A
Compiling method and device
CN110134399A