Harmony OS: Prepare your Lite Wearable project for integration

Sabrina Cara
Huawei Developers
Published in
7 min readAug 10, 2021

--

Source: https://consumer.huawei.com/ph/community/details/HUAWEI-HARMONYOS-BETA-3-0-IS-OUT-SEE-ALL-THE-NEW-UPGRADES/topicId_125590/

Hello again friends, long time no text. I am back again, this time with Huawei’s newest project, a brand new operating system named Harmony OS. According to Huawei’s official site, Harmony OS is considered a next generation operating system that empowers interconnection and collaboration between smart devices. This OS is designed to offer a smooth interaction throughout all devices in all scenarios. In this article, I will be explaining to you all the necessary preparations needed before starting the integration on Harmony OS Lite Wearables, in an attempt to ease the tedious job for you.

Introduction

We will start this section by giving some thorough insights on Harmony OS, its main features and goals and continue with the steps on how to prepare your Lite Wearable project for development.

Harmony OS Introduction

Harmony OS is a future proof distributed system, and it is a big step forward towards the main goal of an all scenario strategy, adaptable to offices, health applications, homes, social medias and communications etc. One of the main features of this operating system is the adaptability to different types of devices including phones, tablets, TVs, smart watches and so on.

  • As an end user, this operating system is useful in the sense that it integrates your various devices offering resource sharing and fast connection among them.
  • As an app developer, Harmony OS offers the opportunity to easily and efficiently develop your apps in different programming languages such as Java, JavaScript, HML, CSS, C/C++ etc.
  • Finally, as a device developer you can profit from the component-based software design of the OS allowing it to adapt itself to different devices based on their resource capabilities.

Lite Wearable Integration Preparation Steps

Now lets get to the main topic of this article, the preparation steps needed before we start the integration of a project in Harmony OS on Lite Wearables.

We can present these steps as follows:

  1. Create a project, an Android app and apply for a Wear Engine permission
  2. Download DevEco Studio and perform the necessary proxy arrangements
  3. Create a Lite JavaScript project in DevEco Studio
  4. Generate Key and CSR
  5. Create a Harmony app under your project in App Gallery Connect Console
  6. Register your wearable device
  7. Create a certificate in the Console
  8. Create an HAP Provision Profile
  9. Register the Signing Configurations
  10. Build HAP and run your project

Let’s explain them in detail one by one.

Create a project, an Android app and apply for a Wear Engine permission

The very first thing we need to do before developing a lite wearable project in Harmony OS is to apply for a Wear Engine permission, so as to provide wearable device distributed capabilities. In order to do this, we have to go to the official Huawei developers site, open the Console, then in the Development section we open the Wear Engine card.

In here we apply for a Wear Engine, and follow the steps. We have to have created a project before this step and an Android app within it, so we can apply our Wear Engine to that project. It takes a couple of days for it to be approved, afterwards we can move on to the next steps.

Download DevEco Studio and perform the necessary proxy arrangements

The next thing for us to do would be to download the DevEco Studio IDE which we find in Huawei’s Harmony OS official site. After downloading the IDE, we will need to set up the development environment for which we can follow this document to get detailed insights.

Create a Lite JavaScript Empty Ability in DevEco Studio

Now that the IDE is ready to go, we create an JavaScript Lite Empty Ability, which we will need for our wearable development. The reason we have chosen a Lite project, is that currently this option is the only one that offers the emulators needed to test our project. Once we have created our project, we must move on to the more tedious part. Hang in there, I will try to make it as easy as possible for you.

Generate Key and CSR

The next step would be to generate a Key Store and a CSR in DevEco Studio by going to Build > Generate Key and CSR

We follow the steps to create the files after which both will appear under our project folder as shown in the red box in the picture above.

Create a Harmony app under your project in App Gallery Connect Console

Now we have to create a Harmony app under the project we created in the first step when we applied for the Wear Engine.

After adding the app according to the necessary parameters, we move on to our next stop.

Register your wearable device

Registering your wearable device in your App Gallery Connect Console would be the next step in this tutorial, which can be done by visiting the Users and Permissions > Device Management > Add Device section. Now you might have noticed that it will ask you for a name, type and UUID of the device, or else an ID needed for device debugging. In our case, since we have used a GT2 Pro, the type goes under Sports Watch. In order to find the UUID you have to follow another small procedure.

Download the DevEco Studio Assistant on your phone and connect it to your smart watch. The moment it is connected, a UUID or the wearable device will appear on the screen, you can copy paste it onto the needed field in the console. When you have entered all the fields and clicked Add, your device will now be registered.

Create a certificate in the Console

Following up the previous step, now we have to create a certificate for our project, in Users and Permissions > Certificate Management > New Certificate section. We will be asked to enter a name, type and upload our CSR file, which we generated in Step 4. After the certificate is successfully created, we can download it as we will be needing it later.

Create an HAP Provision Profile

We move on to creating an HAP Provision Profile by visiting My Projects > Harmony OS Services > HAP Provision Profile > Add in App Gallery Connect Console. We choose debug instead of release, select the permissions we need in the last field and click Submit.

Once the debug profile will have been generated, similarly to the previous step, we can go on and download the .p7b file as we will make use of it in the upcoming steps.

Register the Signing Configurations

This is the last preparatory step before you start the integration on Harmony OS. To perform this step we select File > Project Structure > Project > Signing Configs in DevEco Studio IDE. In the debug section you can check the Automatically generate signing checkbox to automatically perform the signing operation. If necessary you can also generate a signing config for Release as well. In this section, you have to upload your .cer and .p7b files you downloaded from the Console previously. Now that you have done all these steps you are ready to start your integration.

Build HAP and run your project

This part is not a preparatory part of your integration, instead it is the part where the integration actually starts. In your DevEco Studio IDE, go to Build > Build Hap(s) App(s) > Build Hap(s). After your Build is successful, in your project folder, under Entry > Build > Outputs > Hap > Debug you will be able to see both signed and unsigned hap files. You will need to take your Hap file and send it to your phone. From your phone, you will send the file to your wearable device and run it. This way you can see your development in your smart watch. These steps will be demonstrated thoroughly in my next article where I explain the whole development of a project on Harmony OS. But for now, that’s all folks (yes Looney Tunes pun).

Source : https://www.dia.org/events/new-year%E2%80%99s-eve-matinee-looney-tunes-classics

Tips and Tricks

  1. Make sure your Harmony app’s bundle name is the same as your package name in the Console.
  2. Make sure you upload all the necessary folders in the right places in the App Gallery since a small confusion might lead to a problem when building Hap file.
  3. When searching for DevEco Studio Assistant in App Gallery, make sure you search it with this name “HUAWEI DevEco Assistant”, otherwise it might not appear.

Conclusion

In conclusion, in this article I have tried to explain the front to end process of preparing for the integration of an app in Harmony OS for a wearable device such as a smart watch. You can see a detailed, step by step explanation of all the tools and actions needed to be undertaken for you to prepare your development environment. In the next article, I will demonstrate a simple Harmony OS project integrated on a smart watch and using some of its sensors. Until then, stay well and stay healthy.

References

--

--

Sabrina Cara
Huawei Developers

Android Developer at Huawei, HMS and Android enthusiast.