laitimes

Huawei Official: Teach you to use Hongmeng HarmonyOS local emulator

IT Home February 26 news, 2021 Huawei Developer Conference (HDC2021), Huawei with the DevEco Studio 3.0 Beta1 release for the first time launched a local emulator (also known as Local Emulator), supporting analog mobile phone category. Use the video below to review the use of the phone's local emulator.

In this issue, Huawei will introduce the version evolution of the HarmonyOS local simulator and teach you to use the HarmonyOS local emulator by hand.

First, the version evolution of the local simulator

On December 31, 2021, after an iterative optimization of a version, the local simulator released with devEco Studio 3.0 Beta2 version added a smartwatch and smart screen simulator category.

The local simulator has customized its unique features for the characteristics of the smart watch and the smart screen, respectively.

Smart watch: Supports analog data injection of heart rate and step count, and supports simulation of rotating crown buttons.

Huawei Official: Teach you to use Hongmeng HarmonyOS local emulator

Figure 1 Smartwatch

Smart screen: Support remote control simulation.

Huawei Official: Teach you to use Hongmeng HarmonyOS local emulator

Figure 2 Smart Screen

Below, through a video to see the use of smart watches and smart screen category local simulators.

Through the above introduction to the local simulator, it is not difficult to see that the local simulator has the following advantages:

Run directly on the user's local computer, no login authorization required, zero latency, no time limit, and the same performance as the real machine.

Provides audio, battery, location and other general device simulations, providing developers with a running environment similar to the real machine.

Huawei equipment provides product-specific simulations, such as the rotary press function key of smart watches and the remote control simulation of smart screens.

Supports Java, JS, C/C++ single-language debugging and JS+Java cross-language debugging capabilities to help developers debug applications more conveniently and efficiently.

Second, the preparation before use

After understanding the local simulator, the following is to focus on how to use the local simulator. Before you use the local emulator, you need to make the following preparations:

1. The local emulator is created and run on the local computer, and you need to ensure that the local computer meets the following resource requirements:

Windows systems: 8GB and above

MacOS: 8GB and above

Description: Running a local emulator on a virtual machine system is not supported, for example on an Ubuntu system by installing a Windows virtual machine and then using a Windows system to install and run the emulator.

2. Check the version of DevEco Studio:

DevEco Studio V3.0 Beta1 and later only supports local emulators, and DevEco Studio V3.0 Beta2 is currently recommended.

3. Before using the local emulator, you need to install the corresponding image package, as follows:

(1) Open DevEco Studio and select "Files> Settings" (for macOS systems, select DevEco Studio > Preferences).

(2) As shown in Figure 3, on the "SDK Manager> HarmonyOS Legacy SDK" tab, check the image package under "Platforms". Different image packages correspond to different device types, System-image-phone image packages correspond to mobile phones, System-image-tv mirror packages correspond to smart screens, and System-image-wearable mirror packages correspond to smart watches.

Huawei Official: Teach you to use Hongmeng HarmonyOS local emulator

Figure 3 Downloading the image package

(3) Click "Apply" to install.

4. Install the local emulator.

Select "Tools> Device Manager" in the menu bar, enter the interface shown in Figure 4, and click "Install" to install the local emulator.

Huawei Official: Teach you to use Hongmeng HarmonyOS local emulator

Figure 4 Installing the Local Emulator

Create and use a local emulator

After completing the above preparations, the next step is the focus of this article, teaching you how to create and use a local simulator.

1. (Optional) Customize the local emulator file storage path.

The default path to local emulator files is:

C:\Users\Username\AppData\Local\Huawei\HarmonyOSEmulator\deployed。 If the C drive is tight, you can add a system environment variable HarmonyOS_HVD_HOME custom storage path to a directory with sufficient space.

2. Create a local emulator.

(1) Open DevEco Studio and select Tools> Device Manager. As figure 3 shows, on the Local Emulator tab, click the New Emulator button in the lower-right corner to start creating the local emulator.

Huawei Official: Teach you to use Hongmeng HarmonyOS local emulator

Figure 5 Creating a Local Emulator

(2) Select a device to create a local emulator.

As shown in Figure 4, DevEco Studio provides three devices by default: Huawei_Phone, Huawei_TV, and Huawei_Wearable, corresponding to mobile phones, smart screens, and smartwatches. In view of the characteristics of Huawei's equipment, DevEco Studio preset parameters such as size and resolution for these three devices.

Huawei Official: Teach you to use Hongmeng HarmonyOS local emulator

Figure 6 Selecting a Device

Developers can create new mobile devices by clicking on the clone icon after New Hardware or Huawei_Phone and customize the device's name, size, resolution, memory, and other parameters (Figure 7).

Huawei Official: Teach you to use Hongmeng HarmonyOS local emulator

Figure 7 Custom phone parameters

Developers select one of the three default devices or the created mobile device to create a local emulator.

(3) After selecting the device, click Next to see the image information of the local emulator.

(4) Click Next again to check the configuration information of the local emulator, and modify the configuration information if necessary. After confirming that there is no error, click Finish to finish creating the local emulator.

After the creation is successful, you can see the newly created local emulator on the Local Emulator tab, as shown in Figure 8.

Huawei Official: Teach you to use Hongmeng HarmonyOS local emulator

Figure 8 The local simulator is created successfully

3. Run the local emulator.

(1) On the Local Emulator tab (Figure 8), click to start the local emulator.

(2) Click the button in the DevEco Studio toolbar to run the project, or use the default shortcut key Shift+F10 (Control+R for Mac) to run the project.

Huawei Official: Teach you to use Hongmeng HarmonyOS local emulator

Figure 9 Running the project

(3) DevEco Studio will start the compilation and construction of the application, and the application can be run on the local emulator after completion. Taking the mobile phone device as an example, the operation effect is shown in Figure 10.

Huawei Official: Teach you to use Hongmeng HarmonyOS local emulator

Figure 10 Running the local emulator

The mobile phone local simulator shown in Figure 8, in addition to being able to operate directly on the mobile phone screen like a real machine, the toolbar on the right provides easy operation and rich data injection capabilities, including: adjusting the volume, battery simulation, GPS simulation, network simulation, virtual sensor simulation, etc.

Local emulators currently support three device types: mobile phones, smart watches, and smart screens. Figure 11 shows how the same set of code works simultaneously on smartwatches, phones, and smart screens.

Huawei Official: Teach you to use Hongmeng HarmonyOS local emulator

Figure 11 The local emulator runs

IV. Concluding Remarks

This issue introduces the use of the local emulator, have you mastered it? Everyone is welcome to use and explore more features of the local simulator

If you encounter problems with the local emulator, you can refer to the FAQ: Local Emulator >>

If the problem is still not resolved, you can give feedback through the Huawei Developer Forum.

Read on