CN115543440A - Method for migrating android project to android-like system, electronic equipment and storage medium - Google Patents
Method for migrating android project to android-like system, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN115543440A CN115543440A CN202110735657.2A CN202110735657A CN115543440A CN 115543440 A CN115543440 A CN 115543440A CN 202110735657 A CN202110735657 A CN 202110735657A CN 115543440 A CN115543440 A CN 115543440A
- Authority
- CN
- China
- Prior art keywords
- android
- migrating
- file
- migration
- project
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 62
- 238000013508 migration Methods 0.000 claims abstract description 91
- 230000005012 migration Effects 0.000 claims abstract description 91
- 230000008676 import Effects 0.000 claims description 23
- 230000003068 static effect Effects 0.000 claims description 19
- 238000004590 computer program Methods 0.000 claims description 10
- 239000000126 substance Substances 0.000 claims 1
- 230000006870 function Effects 0.000 abstract description 25
- 238000011161 development Methods 0.000 abstract description 21
- 230000008569 process Effects 0.000 abstract description 19
- 230000002829 reductive effect Effects 0.000 abstract description 14
- 238000010586 diagram Methods 0.000 description 13
- 238000004891 communication Methods 0.000 description 5
- 238000013461 design Methods 0.000 description 4
- 238000012545 processing Methods 0.000 description 4
- 238000003491 array Methods 0.000 description 2
- 238000006243 chemical reaction Methods 0.000 description 2
- 239000003086 colorant Substances 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 238000001914 filtration Methods 0.000 description 2
- 238000004458 analytical method Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 230000001419 dependent effect Effects 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 230000000670 limiting effect Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000011160 research Methods 0.000 description 1
- 230000000717 retained effect Effects 0.000 description 1
- 230000002441 reversible effect Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/76—Adapting program code to run in a different environment; Porting
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/36—Software reuse
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The embodiment of the disclosure discloses a method for migrating an android project to a similar android system, electronic equipment and a storage medium, wherein the method for migrating the android project to the similar android system comprises the following steps: determining a difference project between the android system and the android-like system; determining a migration mode for migrating the difference project from the android system to the android-like system; the difference project is migrated from the android system to the android-like system according to the migration mode, so that the android project can normally run in the android-like system after migration and achieve originally designed functions, the number of codes needing to be processed in the migration process is reduced as much as possible, the code reuse rate is high, the mode of migrating the android project to the android-like system is simple, and the development efficiency is high.
Description
Technical Field
The disclosure relates to the technical field of computers, and in particular relates to a method for migrating an android project to an android-like system, electronic equipment and a storage medium.
Background
With the development of mobile devices and mobile device operating systems, people may need to migrate one system project to another when different operating systems are adopted. For example, the advent of Android-like systems, such as the hong meng system, has made the need to migrate the project of the Android (Android) system to the hong meng system urgent. However, the current mode of migrating the project of the android system to the android-like system is complex, the development efficiency is low, and the code reuse rate of the android system is not high. Therefore, how to efficiently and conveniently complete the migration of the project of the android system to the android-like system is an increasingly urgent problem to be solved.
Disclosure of Invention
To solve the problems in the related art, embodiments of the present disclosure provide a method, an electronic device, a readable storage medium, and a computer program product for migrating an android project to an android-like system.
In a first aspect, an embodiment of the present disclosure provides a method for migrating an android project to an android-like system, including:
determining a difference project between the android system and the android-like system;
determining a migration mode for migrating the difference project from the android system to the android-like system;
and migrating the difference item from the android system to the android-like system according to the migration mode.
With reference to the first aspect, in a first implementation manner of the first aspect, the android-like system is a damming system, and the difference items include at least a part of a build.
With reference to the first implementation manner of the first aspect, in a second implementation manner of the first aspect, the migration manner for migrating the build. And modifying the import of the build.gradle file through the first preset script to remove the specific attribute of the android system, so that the build.gradle file is modified into the format of the hongmeng system.
With reference to the first implementation manner of the first aspect, in a third implementation manner of the first aspect, the migration manner for migrating the android main xml file from the android system to the android-like system is as follows: and converting the android Mainfest.
With reference to the first implementation manner of the first aspect, in a fourth implementation manner of the first aspect, the migration manner for migrating the Asset folder from the android system to the android-like system is as follows: files in Asset folder are copied to corresponding folders in hong meng system through a third preset script, and the storage location and the file name of the copied files are set in hong meng system.
With reference to the first implementation manner of the first aspect, in a fifth implementation manner of the first aspect, the migration manner for migrating the xml file from the android system to the android-like system is as follows:
reading an xml file, and analyzing the control name and the corresponding attribute;
searching a control name corresponding to the Hongmon system through the control name, and searching corresponding attributes;
and replacing the corresponding control name and the corresponding attribute in the Hongming system with the analyzed control name and the analyzed attribute.
With reference to the first implementation manner of the first aspect, in a sixth implementation manner of the first aspect, the migration manner for migrating the code from the android system to the android-like system is:
reading a java file, and retrieving all introduced packages of the java file according to a keyword import, wherein a prefix android is added to a package name;
acquiring all Android packages used by java files;
analyzing the quoted Android according to the acquired package;
searching corresponding objects, static parameters and static interfaces through the classes;
searching an interface and parameters according to the searched object;
creating a new hongmeng class, inheriting the analyzed referenced Android class, and rewriting the searched interface and parameters in the created hongmeng class;
modifying the package in the java file to point to the created Hongmong package name;
the class in this java file is modified to point to the created grandma class.
In a second aspect, an embodiment of the present disclosure provides an electronic device, including a memory and a processor; wherein, the first and the second end of the pipe are connected with each other,
the memory is configured to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the method as the first aspect, any one of the first implementation manner to the sixth implementation manner of the first aspect.
In a third aspect, an embodiment of the present disclosure provides a readable storage medium, on which computer instructions are stored, and when executed by a processor, the computer instructions implement the method according to the first aspect, or any one of the first to sixth implementation manners of the first aspect.
In a fourth aspect, a computer program product is provided in an embodiment of the present disclosure, which includes computer instructions that, when executed by a processor, implement the method according to the first aspect, or any one of the first to sixth implementation manners of the first aspect.
The technical scheme provided by the embodiment of the disclosure can have the following beneficial effects:
according to the technical scheme provided by the embodiment of the disclosure, the migration mode of migrating the difference item from the android system to the similar android system is determined by determining the difference item between the android system and the similar android system, and the difference item is migrated from the android system to the similar android system according to the migration mode, so that the android item can normally run in the similar android system after migration and realize the originally designed function of the android item, the number of codes needing to be processed in the migration process is reduced as much as possible, the code reuse rate is high, the mode of migrating the android item to the similar android system is simple, and the development efficiency is high.
According to the technical scheme provided by the embodiment of the disclosure, the android-like system is a hong meng system, and the difference items comprise at least one part of a build. When at least one part of a build.gradle file, an android main original.xml file, an Asset folder, a resource, an xml file and a code in an android project is not migrated, if the android project directly runs in a Hongmon system, a running error occurs or the running project cannot achieve the design purpose. By determining at least one part of the build.gradle file, the android main file.xml file, the Asset folder, the resource, the xml file and the code as a difference item, determining a migration mode for migrating the difference item from the android system to the hong meng system, and migrating the difference item from the android system to the hong meng system according to the migration mode, the android item can normally run in the hong meng system after being migrated and realize the originally designed function, so that the number of the codes needing to be processed in the migration process is reduced as much as possible, the code reuse rate is higher, the mode for migrating the android item to the hong meng system is simpler, and the development efficiency is higher.
According to the technical scheme provided by the embodiment of the disclosure, the migration mode of migrating the build.gradle file from the android system to the android-like system is as follows: modify the import of build.gradle file through first preset script to remove the peculiar attribute of android system, thereby modify build.gradle file into the format of hong meng system, can make build.gradle file can be used normally under hong meng system as the configuration file of gradle, can normally operate and realize its original designed function in hong meng system after making the android project migrate, thereby the code quantity that needs to be handled among the migration process has been reduced as far as possible, make the reusability of code higher, the mode of migrating android project to hong meng system is also simpler, the development efficiency is higher.
According to the technical scheme provided by the embodiment of the disclosure, the migration mode of migrating the android mainframes from the android system to the android-like system is as follows: xml file is converted into the json file through the second preset script, the json file after conversion can be used as an entry file of a migrated item and can be normally used, and an android item can normally run in a hong meng system after being migrated and realize the originally designed function, so that the number of codes needing to be processed in the migration process is reduced as much as possible, the code reuse rate is high, the mode of migrating the android item to the hong meng system is simple, and the development efficiency is high.
According to the technical scheme provided by the embodiment of the disclosure, the migration mode of migrating the Asset folder from the android system to the android-like system is as follows: files in the Asset folder are copied to corresponding folders in the hong meng system through a third preset script, the storage positions and the file names of the copied files are set in the hong meng system, the files originally stored in the Asset folder of the android system can be read from the corresponding folders in the hong meng system, the android item can normally run in the hong meng system after being migrated, and the originally designed functions of the android item are realized, so that the number of codes needing to be processed in the migration process is reduced as much as possible, the code reuse rate is higher, the mode of migrating the android item to the hong meng system is simpler, and the development efficiency is higher.
According to the technical scheme provided by the embodiment of the disclosure, the migration mode of migrating the xml file from the android system to the android-like system is as follows: reading an xml file, and analyzing the control name and the corresponding attribute; searching a control name corresponding to the Hongmon system through the control name, and searching corresponding attributes; the method has the advantages that the corresponding control names and the corresponding attributes in the Hongming system are replaced by the analyzed control names and the analyzed attributes, the controls in the xml files after migration can be normally called by the Hongming system, the android items can normally run in the Hongming system after migration, and the originally designed functions can be realized, so that the number of codes needing to be processed in the migration process is reduced as much as possible, the code reuse rate is high, the mode of migrating the android items to the Hongming system is simple, and the development efficiency is high.
According to the technical scheme provided by the embodiment of the disclosure, the migration mode of migrating the code from the android system to the android-like system is as follows: reading a java file, and retrieving all introduced packages of the java file according to a keyword import, wherein a prefix android is added to a package name; acquiring all Android packages used by java files; analyzing the quoted Android according to the acquired package; searching corresponding objects, static parameters and static interfaces through the classes; searching an interface and parameters according to the searched object; creating a new hongmeng class, inheriting the analyzed referenced Android class, and rewriting the searched interface and parameters in the created hongmeng class; modifying the package in the java file to point to the created Hongmong package name; modifying the class in the java file, pointing to the created grand Monte class, enabling the migrated code to normally call the class in the grand Monte system, ensuring that the function of the called class is the same as the class called by the code before migration, enabling the android project to normally run in the grand Monte system after migration and realizing the originally designed function, reducing the number of codes to be processed in the migration process as much as possible, enabling the code reuse rate to be higher, enabling the mode of migrating the android project to the grand Monte system to be simpler, and enabling the development efficiency to be higher.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
Other features, objects, and advantages of the present disclosure will become more apparent from the following detailed description of non-limiting embodiments when taken in conjunction with the accompanying drawings. In the drawings:
FIG. 1 is a schematic diagram illustrating an application scenario of a method for migrating an android Zhuo Xiangmu to an android-like system according to an embodiment of the present disclosure;
FIG. 2 illustrates a flow diagram of a method for migrating an android Zhuo Xiangmu to an android-like system, in accordance with an embodiment of the present disclosure;
FIG. 3 shows a flow diagram of a migration method for migrating code from an android system to an android-like system, according to an embodiment of the present disclosure;
FIG. 4 shows a block diagram of an electronic device according to an embodiment of the present disclosure;
FIG. 5 is a schematic block diagram of a computer system suitable for use in implementing methods according to embodiments of the present disclosure.
Detailed Description
Hereinafter, exemplary embodiments of the present disclosure will be described in detail with reference to the accompanying drawings so that those skilled in the art can easily implement them. Furthermore, parts that are not relevant to the description of the exemplary embodiments have been omitted from the drawings for the sake of clarity.
In the present disclosure, it is to be understood that terms such as "including" or "having," etc., are intended to indicate the presence of labels, numbers, steps, actions, components, parts, or combinations thereof disclosed in the present specification, and are not intended to exclude the possibility that one or more other labels, numbers, steps, actions, components, parts, or combinations thereof are present or added.
It should be further noted that the embodiments and labels in the embodiments of the present disclosure may be combined with each other without conflict. The present disclosure will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
In considering the application scenario of the embodiments of the present disclosure, the inventors conducted research in a migration scenario of an android project. The inventors have studied the following related technical solutions for migrating android projects to android-like systems.
In one scheme, codes of an Android (Android) project can be divided into different functional modules according to logic, the codes of the different functional modules are manually modified, so that the modified codes can run in an Android-like system, logic corresponding to the functional modules is realized, and then the switched codes are compiled again to obtain a migrated project.
According to the scheme, the codes of each functional module in the android project need to be manually modified, the reusability of the codes of the android system is not high, the number of the codes needing to be manually modified in the scheme is large, and therefore the mode of migrating the android project in the scheme is complex, and the development efficiency is low.
To address the above issues, the present disclosure proposes a method and an electronic device, a readable storage medium, and a computer program product for migration of an android project to an android-like system.
The scheme of the embodiment of the disclosure can overcome the defects that the mode of migrating the android project to the android-like system in the related technology is complex, the development efficiency is low, and the code reuse rate of the android system is not high. The method comprises the steps of determining a difference project between an android system and a similar android system, determining a migration mode for migrating the difference project from the android system to the similar android system, migrating the difference project from the android system to the similar android system according to the migration mode, enabling the android project to normally run in the similar android system after migration and achieve originally designed functions of the android project, and therefore the number of codes needing to be processed in the migration process is reduced as much as possible, the code reuse rate is high, the mode for migrating the android project to the similar android system is simple, and the development efficiency is high.
Fig. 1 shows a schematic diagram of an application scenario according to an embodiment of the present disclosure. It is to be understood that the application scenario illustrated in fig. 1 is merely for illustrating the concepts and principles of the present disclosure, and is not meant to imply that the present disclosure is only applicable to such application scenario.
As shown in fig. 1, in an embodiment of the present disclosure, the android project that needs to be migrated may be an android project stored on the server 101 or an android project acquired by the server 101 from the terminal device 102, and the method for migrating the android project to the android-like system may be performed by the server 101. The android project to be migrated may also be an android project stored on the terminal device 102 or an android project acquired by the terminal device 102 from the server 101, and the method for migrating the android project to the android-like system may be performed by the terminal device 102. The terminal device 102 may be a mobile phone, a computer, a tablet computer, or the like. Wherein the terminal device 102 communicates with the server 101 over a communication network. The terminal device 102 may be, but is not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. The server 101 may be implemented as a stand-alone server.
FIG. 2 illustrates a flow diagram of a method for migrating an android Zhuo Xiangmu to an android-like system in accordance with an embodiment of the present disclosure. As shown in fig. 2, the method for migrating the android project to the android-like system includes steps S101, S102, and S103.
In step S101, a difference item between the android system and the android-like system is determined.
In step S102, a migration manner for migrating the difference item from the android system to the android-like system is determined.
In step S103, the difference item is migrated from the android system to the android-like system according to the migration manner.
If the difference item exists in the android item, when the android item is migrated to the android-like system, the difference item is not migrated in the migration manner, and then an error occurs when the migrated item runs in the android-like system, or the migrated item cannot realize a function designed in advance.
According to the technical scheme provided by the embodiment of the disclosure, the migration mode of migrating the difference item from the android system to the similar android system is determined by determining the difference item between the android system and the similar android system, and the difference item is migrated from the android system to the similar android system according to the migration mode, so that the android item can normally run in the similar android system after migration and realize the originally designed function of the android item, the number of codes needing to be processed in the migration process is reduced as much as possible, the code reuse rate is high, the mode of migrating the android item to the similar android system is simple, and the development efficiency is high.
In one embodiment of the present disclosure, the android-like system is a hong meng system, and the difference items include at least a part of a build.
The method includes the steps that the gradle is a building tool kit in an android system, manages dependent items and allows a developer to customize building logic, the build is a configuration file of the gradle, and the build provides basic configuration for an item, such as a statement warehouse source, version number description of the gradle and the like.
Xml is an entry file of an android application, which describes various components (e.g., activities, services, etc.) of the android application, implementation classes of the components of the android application, data that can be processed by the components of the android application, start conditions of the components of the android application, and the like.
The Asset folder is used for storing static resources (such as image files, css files, js files and the like) written by a developer in the development process of the android application.
Extensible Markup Language (xml) files are used in the android system to transfer and store data, such as arrays. Xml files for defining arrays, colors. Xml files for defining colors, medias. Xml files for defining sizes, rowables. Xml files for defining canvas, strings.xml files for defining strings, and the like.
According to the technical scheme provided by the embodiment of the disclosure, the android-like system is a hong meng system, and the difference items comprise at least one part of a build. When at least one part of a build file, an android main file, an Asset folder, a resource, an xml file and a code in an android project is not migrated, if the android project directly runs in a Hongmon system, a running error occurs or the running project cannot achieve the design purpose. By determining at least one part of the build.gradle file, the android main file.xml file, the Asset folder, the resource, the xml file and the code as a difference item, determining a migration mode for migrating the difference item from the android system to the hong meng system, and migrating the difference item from the android system to the hong meng system according to the migration mode, the android item can normally run in the hong meng system after being migrated and realize the originally designed function, so that the number of the codes needing to be processed in the migration process is reduced as much as possible, the code reuse rate is higher, the mode for migrating the android item to the hong meng system is simpler, and the development efficiency is higher.
In an embodiment of the present disclosure, a migration manner for migrating a build. And modifying the import of the build.gradle file through the first preset script to remove the specific attribute of the android system, so that the build.gradle file is modified into the format of the hongmeng system.
For example, in an android system, import (import) can be used in a build
apply plugin:'com.android.application'
When the build.gradle file is migrated from the android system to the android-like system, the import of the build.gradle file is modified through the first preset script, and the build.gradle file is migrated
apply plugin:'com.android.application'
Instead, it is changed into
apply plugin:'com.huawei.harmony.hap'
To remove the unique attributes of the android system and modify the build.
According to the technical scheme provided by the embodiment of the disclosure, the migration mode of migrating the build.gradle file from the android system to the android-like system is as follows: modify the import of build.gradle file through first preset script to remove the peculiar attribute of tall and erect system, thereby modify the format of the build.gradle file into the hong meng system, can make the build.gradle file can be used normally under the hong meng system as the configuration file of gradle, can normally operate and realize its function of original design in the hong meng system after making the tall and erect project migrate, thereby the code quantity that needs to be handled among the migration process has been reduced as far as possible, make the reusability of code higher, it is also simpler to migrate the mode of tall and erect project to the hong meng system, development efficiency is higher.
In one embodiment of the present disclosure, a migration manner for migrating an android mainlist. And converting the android Mainfest.
A JavaScript Object Notation (json) file is a lightweight format, and in an android system, the json file can be used for storing and representing data.
According to the technical scheme provided by the embodiment of the disclosure, the migration mode of migrating the android mainframes from the android system to the android-like system is as follows: xml file is converted into the json file through the second preset script, the json file after conversion can be used as an entry file of a migrated item and can be normally used, and an android item can normally run in a hong meng system after being migrated and realize the originally designed function, so that the number of codes needing to be processed in the migration process is reduced as much as possible, the code reuse rate is high, the mode of migrating the android item to the hong meng system is simple, and the development efficiency is high.
In one embodiment of the disclosure, the migration manner for migrating the Asset folder from the android system to the android-like system is as follows: files in Asset folder are copied to corresponding folders in hong meng system through a third preset script, and the storage location and the file name of the copied files are set in hong meng system.
In the android system, the storage address of the Asset folder is/app/src/main/assets, files in the Asset folder are copied to corresponding folders in the hongmeng system through a third preset script, and the address of the corresponding folders in the hongmeng system is/app/src/resources/rawfile.
According to the technical scheme provided by the embodiment of the disclosure, the migration mode of migrating the Asset folder from the android system to the android-like system is as follows: files in the Asset folder are copied to corresponding folders in the hong meng system through a third preset script, the storage positions and the file names of the copied files are set in the hong meng system, the files originally stored in the Asset folder of the android system can be read from the corresponding folders in the hong meng system, the android item can normally run in the hong meng system after being migrated, and the originally designed functions of the android item are realized, so that the number of codes needing to be processed in the migration process is reduced as much as possible, the code reuse rate is higher, the mode of migrating the android item to the hong meng system is simpler, and the development efficiency is higher.
In some cases, the xml file of the android system defines many controls necessary for the android project, such as a textbox (TextView) control, a date and time (DatePicker, timePicker) control, a Button (Button) control, a Menu (Menu, subMenu, menuItem) control, a Dialog (Dialog) control, a progress bar (progress bar) control, and so on. If the xml file is not migrated from the android system to the hong meng system, the android project cannot call the control in the xml file when directly running in the hong meng system, so that the android project has running errors or the android project cannot achieve the design purpose. In one embodiment of the present disclosure, a particular xml file may also be migrated in a manner different from the general xml file migration described herein.
In an embodiment of the present disclosure, a migration manner for migrating an xml file from an android system to a android-like system is as follows: reading an xml file, and analyzing the control name and the corresponding attribute; searching a control name corresponding to the Hongmon system through the control name, and searching corresponding attributes; and replacing the corresponding control name and the corresponding attribute in the Hongming system with the analyzed control name and the analyzed attribute.
For example, the example that the xml file includes a TextView control, in the android system, the code corresponding to the TextView control is:
when the xml file is migrated from the android system to the Hongmon system, the xml file is read, and the control name and the corresponding attribute of the xml file are analyzed. And determining the control name of the xml file as follows according to the analysis result:
android:id="@+id/address"
the corresponding attributes are:
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="find_device_ticker"
searching a control name corresponding to the Hongming system through the control name, searching corresponding attributes, and determining the control name corresponding to the Hongming system as follows according to a searching result:
harmoonyos:id="$+id/address"
and determining the corresponding attributes as follows according to the search result:
harmoonyos:width="wrap_content"
harmoonyos:height="wrap_content"
harmoonyos:text="find_device_ticker"
replacing the corresponding control name and the corresponding attribute in the Hongmong system with the analyzed control name and the analyzed attribute to obtain an xml file transferred to the Hongmong system, wherein the code corresponding to the text control TextView control in the xml file transferred to the Hongmong system is
According to the technical scheme provided by the embodiment of the disclosure, the migration mode of migrating the xml file from the android system to the android-like system is as follows: reading an xml file, and analyzing the control name and the corresponding attribute; searching a control name corresponding to the Hongmon system through the control name, and searching corresponding attributes; the method has the advantages that the corresponding control names and the corresponding attributes in the Hongming system are replaced by the analyzed control names and the analyzed attributes, the controls in the xml files after migration can be normally called by the Hongming system, the android items can normally run in the Hongming system after migration, and the originally designed functions can be realized, so that the number of codes needing to be processed in the migration process is reduced as much as possible, the code reuse rate is high, the mode of migrating the android items to the Hongming system is simple, and the development efficiency is high.
In one embodiment of the present disclosure, the migration manner for migrating the code from the android system to the android-like system is as follows: reading a java file, and retrieving all introduced packages of the java file according to a keyword import, wherein a prefix android is added to a package name; acquiring all Android packages used by java files; analyzing the quoted Android according to the acquired package; searching corresponding objects, static parameters and static interfaces through the classes; searching an interface and parameters according to the searched object; creating a new hongmeng class, inheriting the analyzed referenced Android class, and rewriting the searched interface and parameters in the created hongmeng class; modifying the package in the java file to point to the created Hongmong package name; the class in this java file is modified to point to the created grandma class.
A migration method of migrating code from an android system to an android-like system according to an embodiment of the present disclosure is described below with reference to fig. 3. Fig. 3 shows a flowchart of a migration method for migrating code from an android system to an android-like system according to an embodiment of the present disclosure. As shown in FIG. 3, the migration method for migrating code from an android system to an android-like system includes steps S201-S211.
In step S201, a java file is read;
in step S202, according to the keyword import, all the imported packets of the java file are retrieved, and a prefix android is added to the packet name;
in step S203, all the packages of java files used to Android are acquired.
In step S204, the referenced Android class is parsed according to the acquired package.
In step S205, the corresponding object is searched for by class.
In step S206, a static parameter is searched for according to the searched object.
In step S207, a static interface is searched for according to the searched object.
In step S208, the interface is searched according to the searched object.
In step S209, the parameter is searched for according to the searched object.
In step S210, a new hongmeng class is created, the resolved referenced Android class is inherited, and the found interface and parameter are rewritten in the created hongmeng class.
Wherein the hong meng class refers to a class that can be normally called in the hong meng system to implement a corresponding function.
In step S211, the package in this java file is modified to point to the package name of the created Hongmon class.
In the hong meng system, a packet containing the created hong meng class may be searched according to the packet name in the java file, so as to access the created hong meng class in the packet.
In step S212, the class in this java file is modified to point to the created Mongolian class.
In the hongmeng system, the created hongmeng class may be called according to the class in the java file to implement the function corresponding to the created hongmeng class.
For example, the example is described in the case that the java file in the android system includes the following code:
import android.content.Context;
import android.util.Log;
import java.io.DataOutputStream;
reading the java file, and searching all introduced packages of the java file according to the keyword import, wherein the package name is added with a prefix android; and acquiring all the Android-used packages of the java file, wherein because the character string after import comprises ' Android ', in the first line of code and the second line of code, two Android packages can be filtered out, namely ' Android. Analyzing the referenced Android classes according to the obtained two Android packages, namely "Android. And searching corresponding objects, static parameters and static interfaces through classes with class names of 'Context' and 'Log'. Wherein, by looking up the code containing "Context", it is possible to filter out where the class with the class name "Context" is used, for example:
Context context=null;
and then filtering out an object with a class name of 'Context' corresponding to the class and static parameters and static interfaces corresponding to the class with the class name of 'Context' according to the java code object reasonable rule. Similarly, by looking up code containing "Log", one can filter out where classes with class name "Log" are used, such as:
Log.d(Global.TAG,"getJson IOException="+jsonObject.toString());
then according to the rule "Log". The "finding method" d ". According to the found object" context ", find:
context.unregisterReceiver(mBroadcastReceiver);
and then filtering out the interface of the unregisterReceiver through the object 'context'. Creating a new hongmeng class, inheriting the analyzed classes with the Android class names of 'Context' and 'Log', and rewriting the found interfaces and parameters in the created hongmeng class. Modifying the package in the java file to point to the created Hongmon package name and converting the package name in the java file to the package name in the Java file
import android.content.Context;
Is modified into
import com.autonavi.amapauto.customContext;
And modifying the class in the java file, and replacing Context Context = null with customContext Context = null so as to point to the created Hongmontext class.
According to the technical scheme provided by the embodiment of the disclosure, the migration mode of migrating the code from the android system to the android-like system is as follows: reading a java file, and retrieving all introduced packages of the java file according to a keyword import, wherein a prefix android is added to a package name; obtaining all Android packages used by java files; analyzing the quoted Android according to the acquired package; searching corresponding objects, static parameters and static interfaces through the classes; searching an interface and parameters according to the searched object; creating a new hongmeng class, inheriting the analyzed referenced Android class, and rewriting the searched interface and parameters in the created hongmeng class; modifying the package in the java file to point to the created Hongmong package name; modifying the class in the java file to point to the created Hongmong class, so that the code after migration can normally call the class in the Hongmong system, ensuring that the function of the called class is the same as the class called by the code before migration, and enabling the android project to normally run in the Hongmong system and realize the originally designed function after migration, thereby reducing the number of codes needing to be processed in the migration process as much as possible, ensuring that the code reuse rate is higher, and ensuring that the mode of migrating the android project to the Hongmong system is simpler and the development efficiency is higher.
In an embodiment of the disclosure, various migration modes for different android projects can be integrated, so that the android projects can be quickly migrated to similar android projects by one key, and the investment of a large amount of human resources in the migration process is saved. Moreover, according to the scheme of the embodiment of the disclosure, java codes of the original Android project can be reserved to the greatest extent, and Android related interfaces are stripped out in a componentization mode to form independent components. The original architecture can be retained to the maximum extent.
Fig. 4 shows a block diagram of an electronic device according to an embodiment of the present disclosure.
The disclosed embodiment also provides an electronic device, as shown in fig. 4, the electronic device 200 includes at least one processor 201; and a memory 202 communicatively coupled to the at least one processor 201; wherein the memory 202 stores instructions executable by the at least one processor 201, the instructions being executable by the at least one processor 201 to implement the steps of:
determining a difference project between the android system and the android-like system;
determining a migration mode for migrating the difference project from the android system to the android-like system;
and migrating the difference item from the android system to the android-like system according to the migration mode.
In one embodiment of the present disclosure, the android-like system is a hong meng system, and the difference items include at least a part of a build.
In an embodiment of the present disclosure, a migration manner for migrating a build. And modifying the import of the build.gradle file through the first preset script to remove the specific attribute of the android system, so that the build.gradle file is modified into the format of the hongmeng system.
In one embodiment of the present disclosure, a migration manner for migrating an android maincast.xml file from an android system to an android-like system is as follows: and converting the android Mainfest.
In one embodiment of the disclosure, the migration manner for migrating the Asset folder from the android system to the android-like system is as follows: files in Asset folder are copied to corresponding folders in hong meng system through a third preset script, and the storage location and the file name of the copied files are set in hong meng system.
In one embodiment of the present disclosure, a migration manner for migrating an xml file from an android system to a android-like system is as follows:
reading an xml file, and analyzing the control name and the corresponding attribute;
searching a control name corresponding to the Hongmon system through the control name, and searching corresponding attributes;
and replacing the corresponding control name and the corresponding attribute in the Hongming system with the analyzed control name and the analyzed attribute.
In an embodiment of the present disclosure, a migration manner for migrating a code from an android system to a android-like system is:
reading a java file, and retrieving all introduced packages of the java file according to a keyword import, wherein a prefix android is added to a package name;
acquiring all Android packages used by java files;
analyzing the quoted Android according to the acquired package;
searching corresponding objects, static parameters and static interfaces through the classes;
searching an interface and parameters according to the searched object;
creating a new Hongmon class, inheriting the analyzed Android class for reference, and rewriting the searched interface and parameters in the created Hongmon class;
modifying the package in the java file to point to the created Hongmong package name;
the class in this java file is modified to point to the created grandma class.
FIG. 5 is a schematic block diagram of a computer system suitable for use in implementing methods according to embodiments of the present disclosure. As shown in fig. 5, the computer system 300 includes a processing unit 301 that can execute various processes in the embodiments shown in the above-described figures according to a program stored in a Read Only Memory (ROM) 302 or a program loaded from a storage section 308 into a Random Access Memory (RAM) 303. In the RAM303, various programs and data necessary for the operation of the system 300 are also stored. The CPU301, ROM302, and RAM303 are connected to each other via a bus 304. An input/output (I/O) interface 305 is also connected to bus 304.
The following components are connected to the I/O interface 305: an input portion 306 including a keyboard, a mouse, and the like; an output section 307 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 308 including a hard disk and the like; and a communication section 309 including a network interface card such as a LAN card, a modem, or the like. The communication section 309 performs communication processing via a network such as the internet. A drive 310 is also connected to the I/O interface 305 as needed. A removable medium 311 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 310 as necessary, so that a computer program read out therefrom is mounted into the storage section 308 as necessary. The processing unit 301 may be implemented as a CPU, a GPU, a TPU, an FPGA, an NPU, or other processing units.
In particular, according to embodiments of the present disclosure, the methods described above with reference to the figures may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program tangibly embodied on a medium readable thereby, the computer program comprising program code for performing the methods of the figures. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 309, and/or installed from the removable medium 311. For example, embodiments of the present disclosure include a readable storage medium having stored thereon computer instructions which, when executed by a processor, implement program code for performing the methods in the figures.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowcharts or block diagrams may represent a module, a program segment, or a portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units or modules described in the embodiments of the present disclosure may be implemented by software or hardware. The units or modules described may also be provided in a processor, and the names of the units or modules do not in some cases constitute a limitation of the units or modules themselves.
As another aspect, the present disclosure also provides a computer-readable storage medium, which may be the computer-readable storage medium contained in the above-described embodiments; or it may be a separate computer readable storage medium not incorporated into the device. The computer readable storage medium stores one or more programs for use by one or more processors in performing the methods described in the present disclosure.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention in the present disclosure is not limited to the specific combination of the above-mentioned features, but also encompasses other embodiments in which any combination of the above-mentioned features or their equivalents is made without departing from the inventive concept. For example, the above features and the technical features disclosed in the present disclosure (but not limited to) having similar functions are replaced with each other to form the technical solution.
Claims (10)
1. A method of android project migration to an android-like system, comprising:
determining a difference project between the android system and the android-like system;
determining a migration mode for migrating the difference project from the android system to the android-like system;
and migrating the difference project from the android system to the android-like system according to the migration mode.
2. The method of claim 1, the android-like system is a hong meng system, and the difference items include at least a portion of a build.
3. The method according to claim 2, wherein the migration manner for migrating the build. And modifying the import of the build.gradle file through the first preset script to remove the specific attribute of the android system, so that the build.gradle file is modified into the format of the hongmeng system.
4. The method of claim 2, wherein the migration manner for migrating the android maincast xml file from the android system to the android-like system is as follows: and converting the android main file into a json file through a second preset script.
5. The method of claim 2, wherein the migration manner for migrating the Asset folder from the android system to the android-like system is as follows: files in Asset folder are copied to corresponding folders in hong meng system through a third preset script, and the storage location and the file name of the copied files are set in hong meng system.
6. The method according to claim 2, wherein the migration manner for migrating the xml file from the android system to the android-like system is as follows:
reading an xml file, and analyzing the control name and the corresponding attribute;
searching a control name corresponding to the Hongmon system through the control name, and searching corresponding attributes;
and replacing the corresponding control name and the corresponding attribute in the Hongming system with the analyzed control name and the analyzed attribute.
7. The method of claim 2, wherein the migration manner for migrating the code from the android system to the android-like system is as follows:
reading a java file, and retrieving all introduced packages of the java file according to a keyword import, wherein a prefix android is added to a package name;
acquiring all Android packages used by java files;
analyzing the quoted Android according to the acquired package;
searching corresponding objects, static parameters and static interfaces through the classes;
searching an interface and parameters according to the searched object;
creating a new hongmeng class, inheriting the analyzed referenced Android class, and rewriting the searched interface and parameters in the created hongmeng class;
modifying the package in the java file to point to the created packet name of the Hongmon class;
the class in this java file is modified to point to the created grandma class.
8. An electronic device comprising a memory and a processor; wherein the content of the first and second substances,
the memory is to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the method of any of claims 1-7.
9. A readable storage medium having stored thereon computer instructions which, when executed by a processor, implement the method of any one of claims 1-7.
10. A computer program product comprising computer instructions which, when executed by a processor, implement the method of any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110735657.2A CN115543440A (en) | 2021-06-30 | 2021-06-30 | Method for migrating android project to android-like system, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110735657.2A CN115543440A (en) | 2021-06-30 | 2021-06-30 | Method for migrating android project to android-like system, electronic equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115543440A true CN115543440A (en) | 2022-12-30 |
Family
ID=84716961
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110735657.2A Pending CN115543440A (en) | 2021-06-30 | 2021-06-30 | Method for migrating android project to android-like system, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115543440A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116483328A (en) * | 2023-06-19 | 2023-07-25 | 广州信位通讯科技有限公司 | System and method for running HongMong APP on ThreadX embedded software platform |
CN117785281A (en) * | 2024-02-28 | 2024-03-29 | 南方电网调峰调频发电有限公司 | Method for transplanting NFC function based on operating system |
-
2021
- 2021-06-30 CN CN202110735657.2A patent/CN115543440A/en active Pending
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116483328A (en) * | 2023-06-19 | 2023-07-25 | 广州信位通讯科技有限公司 | System and method for running HongMong APP on ThreadX embedded software platform |
CN116483328B (en) * | 2023-06-19 | 2023-09-12 | 广州信位通讯科技有限公司 | System and method for running HongMong APP on ThreadX embedded software platform |
CN117785281A (en) * | 2024-02-28 | 2024-03-29 | 南方电网调峰调频发电有限公司 | Method for transplanting NFC function based on operating system |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN105718289B (en) | Component relation establishing method and equipment | |
CN107402746B (en) | Method and device for automatically generating code file | |
CN111381852A (en) | Application dynamic updating method and device based on Flutter, storage medium and electronic equipment | |
JP2021111368A (en) | API-based software development platform | |
CN112817657B (en) | Application program starting item loading method, device, system and storage medium | |
CN113126990B (en) | Page development method, device, equipment and storage medium | |
CN115543440A (en) | Method for migrating android project to android-like system, electronic equipment and storage medium | |
CN113031946A (en) | Method and device for rendering page component | |
CN111694613A (en) | Decoupling method between application program modules, electronic device and storage medium | |
CN114996619A (en) | Page display method and device, computer equipment and storage medium | |
CN112835568A (en) | Project construction method and device | |
CN110489162B (en) | Method, device, medium and equipment for simplifying installation package SO (storage and retrieval) file | |
CN113760276A (en) | Method and device for generating page code | |
CN116028028A (en) | Request function generation method, device, equipment and storage medium | |
US11604662B2 (en) | System and method for accelerating modernization of user interfaces in a computing environment | |
CN112328241B (en) | Method and device for creating Android library module dependency relationship in application program development | |
CN111158777B (en) | Component calling method, device and computer readable storage medium | |
CN113296752A (en) | Method, system, device and storage medium for generating API document | |
CN112926008A (en) | Method and device for generating form page, electronic equipment and storage medium | |
CN115809056B (en) | Component multiplexing implementation method and device, terminal equipment and readable storage medium | |
CN110599112B (en) | Network page development and maintenance method and device | |
CN114115855A (en) | Code multiplexing method and device, computer readable storage medium and electronic equipment | |
CN111273913B (en) | Method and device for outputting application program interface data represented by specifications | |
CN116431137A (en) | Cross-development-framework component conversion method, processing system and component conversion device | |
CN113761871A (en) | Rich text rendering method and device, electronic equipment and storage medium |
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 | ||
TA01 | Transfer of patent application right | ||
TA01 | Transfer of patent application right |
Effective date of registration: 20240301 Address after: # 03-06, Lai Zan Da Building 1, 51 Belarusian Road, Singapore Applicant after: Alibaba Innovation Co. Country or region after: Singapore Address before: Room 01, 45th Floor, AXA Building, 8 Shanton Road, Singapore Applicant before: Alibaba Singapore Holdings Ltd. Country or region before: Singapore |