DEV Community

Cover image for HarmonyOS development: Component-based operation based on DevEco Studio plug-in
程序员一鸣
程序员一鸣

Posted on

HarmonyOS development: Component-based operation based on DevEco Studio plug-in

Foreword

this project API>= 13

in the last article, we realized the effect of running a single component manually, but there are many changes. If we make changes manually every time we run, it will greatly reduce the development efficiency. Moreover, if we don't pay attention to it, it will increase the cost of trial and error. Based on this, we can use automated scripts, hvigo plug-in and DevEco Studio plug-in to assist us in fast switching.

The first two forms have been shared in previous articles. We will summarize the usage after refactoring in the following articles. In this article, we will focus on the use of DevEco Studio plug-in to quickly implement component-based operation.

Plug-in usage

at present, the plug-in package has been uploaded to github, and you can download it on demand. The address is as follows:

https://abnerming888.github.io/vip/load/HarmonyComponent-sign-1.0.jar

I remember that in the json to object article, there was a brief explanation, that is, the current DevEco Studio has its own white list control, and plug-ins in the jetbrains plug-in market cannot be searched in DevEco Studio, so only local installation methods can be provided here.

Image description

Local installation is also very simple, open the Settings, click Plugins on the left, click the Settings icon, click local installation, Install Plugin from Disk..., Find the plug-in you downloaded, confirm to open it, and click the application at the bottom. Generally, you do not need to restart the IDE. If it does not take effect, you can restart the IDE.

Image description

After the plug-in is installed, you can click the Run menu at the top. The first option is the componentization tool. Of course, you can also implement it through shortcut keys. Windows is ctrl + alt + K,MAC is option + command + k, as shown in the following figure.

Image description

After clicking, the following window will pop up, which is very concise:

Image description

select the module that you need to perform componentization, and click OK. It will automatically change the current module to a runnable state and change the previous running module to a shared module.

After you switch modules, please be sure to select the switched modules before running, because the original modules have been changed to shared packages and cannot be run, that is, componentized switching and running modules need to maintain one-to-one correspondence.

Image description

Error type

error 1: 00401021/00401022.

If you switch modules, click Run to report the following error:

Image description

or

Image description

that's because you didn't synchronize and Refresh the Project. You can click Sync and Refresh Project below to solve it.

Image description

Error 2: install entry already exist

the reason is that there are already applications with the same package name installed on the device at present. Click the blue uninstall and reinstall the modules directly to solve the problem.

Image description

Error 3: The operation is correct and the default ability is not started.

If you are running normally, but the default page is not open on the device, it is because your module has not selected the default launch.

Image description

Select Edit Configuration:

Image description

open the module you want to run, and select the default Ability at Launch.

Image description

Related Summary

after switching modules, be sure to execute the following: Sync and Refresh Project, which can be executed only once after switching, and set the default Startup Page, that is, each module can be set once when switching for the first time, usually after the first configuration, the subsequent configuration will not be configured.

If you encounter problems when using the plug-in, you can contact me at the first time and I will solve it in time.

This article label: Hongmeng Development Tools/DevEco Studio

Top comments (0)