Harmony OS: A quick troubleshooting article for some frequently asked questions.

Sabrina Cara
Huawei Developers
Published in
6 min readDec 28, 2021

--

Image source: https://www.site24x7.com/blog/troubleshooting-complex-applications-faster

Hello again, first and foremost I hope this article finds you well and healthy. In this article I want to guide you through a short troubleshooting type of article containing some of the most frequently asked questions during my experience as a Harmony developer / aider. Bear with me, this is going to be short and cut to the chase. Let’s start!

Introduction

During the development of Harmony OS apps, as well as while providing help for some other fellow developer friends, I have received these 2 questions a lot:

  1. When I try to debug my application in a physical device instead of an emulator, I try moving my .hap folder from the computer to the phone, however it does not appear in my DevEco Assistant app. What am I doing wrong?
  2. I have released an app for GT2 Pro watches, however when I connect my GT3 watch, I cannot see it in my AppGallery. How can I see it there?
  3. The Harmony OS application I have developed works when I communicate with GT2 Pro watch-Huawei phone, but issues arise when I establish communication between GT2 Pro watch — Non-Huawei, Android phones. What am I missing?

Both of the questions asked above are simple, yet very frequently occurring. However, the answer of both of them are easy to follow and solve the issue. Hence, I have decided to provide a quick guide for these 2 issues developers run into frequently, especially whilst at the beginning of their Harmony OS adventure. Let’s tackle them together.

Moving the .hap folder from computer to phone.

If you are wondering how we get up until this point, I suggest you follow this article about preparing your project for development. Additionally, there are many more articles in Huawei’s official site on how to prepare your project for development, which you can take a look at.

If you have followed all the steps, and you pass the .hap folder from computer to phone, yet you still cannot see the file in your DevEco Assistant app, here is what you can do:

  1. Make sure you have downloaded and installed the Huawei Health app in your phone and connected it to your watch. When you open the DevEco Assistant app, it should show you the connected device as well as its UDID. If it doesn’t show you that, but instead it shows you a Connect button, try pressing it to connect again.
  2. The moment you get connected to Health app through your DevEco Assistant application as well, a haps folder will automatically be created in your phone. Your job would be to find that folder in the internal storage of your device (image 1).
  3. The last step would be moving your debug hap file from your computer to your phone, only in that haps file, otherwise if you move it anywhere else in the phone it will not appear. The moment you move it there, you can then proceed to open your DevEco Assistant application, go to Apps section, refresh the page, and you will be seeing the newly appeared hap file.
Image 1: haps folder inside the internal storage

CAREFUL: Only signed debug haps will be installed successfully in the watch, any other release haps or .app files will give an error when trying to be installed, as you are not permitted to install them in your device.

By doing these steps, you will have solved the issue mentioned above very easily. Now let’s move on to the second question.

Adapt the Harmony OS app developed for GT2 line to the GT3 watches.

This is actually a very simple process which you be able to implement in a very short time, so lets get to it.

  1. Open the Harmony project in DevEco Studio IDE.
  2. Locate the config.json file. In the config.json file, you should locate the distroFilter section, if not available, you should add the section. In the distroFilter section, under the screenWindow > value, you should add the following values: [“454*454” , “466*466”]. These values serve 2 purposes:

2.1 You use them to fix the screen view according to the size of each watch. This is done only so that the UI of the app adapts to each app. 454*454 is used for GT2 Pro, and 466*466 is used for GT3 watches. In order to see how they should be included, you can check image 2.

Image 2: Adding the necessary configurations to config.json

2.2 The second use of these values would be to make the application visible in the AppGallery platform. As you might know (or not), when you release a Harmony OS watch app, you can see the released apps in the AppGallery section in the Huawei Health app (Open Huawei Health > go to Devices section > open AppGallery). The apps visible there, are only apps visible to the type of watch currently connected to your Health app, basically if you connect a GT2 Pro watch to your Health app, only apps released specifically for GT2 Pro are visible, and vice versa, if you have a GT3 watch connected to your Health app, only the respective apps will appear in your AppGallery section. For this reason, to make your app visible in both platforms, you add these values in your config.json file.

CAREFUL: It is recommended that your apk compile version is 6 as distroFilter might not be recognized in older versions.

With this being said, we have solved this issue, and can now move on to the next question.

Communication between sports watch and non-Huawei, Android phones sometimes fails / does not work properly.

This is another issue I came across with during development and could solve the issue with only two lines of code, thus I decided to share my two cents with you in this issue as well. Here we go.

  1. In your android project, you open the app’s AndroidManifest.xml file.
  2. In the file, inside manifest tags, outside the application tasks, you add the following lines.
Image 3: AndroidManifest.xml file queries

By adding these lines, your android project is allowing health app and wear engine services, which are used for the communication between wearables and phones to operate in non Huawei phones as well. Hence adding these two queries (as shown in image 3) would probably solve the issue you are facing right now.

Tips & Tricks

  1. Do not move your debug .hap file anywhere in your computer, move it to the specific haps folder in internal storage.
  2. Adding distroFilter might solve the issues of your app not appearing on AppGallery.
  3. Try keeping the compile sdk level to the highest, so you reduce the chance of facing errors.

Conclusion

And that concludes the first part of the troubleshooting series, I will try to create similar mini articles whenever there are frequently asked questions from your side. This way you can tackle them quickly and easily. As always, thank you for reading my stuff, stay healthy and happy. Until next time…

References

--

--

Sabrina Cara
Huawei Developers

Android Developer at Huawei, HMS and Android enthusiast.