Technology

What developers should know about porting Android apps to HarmonyOS

2024-10-28 04:22:55


Porting Android applications to HarmonyOS presents a great opportunity for developers to expand their user base to the large ecosystem of Huawei devices. Porting Android apps to HarmonyOS is not difficult, as the systems share similar foundations. However, there are certain requirements to consider to ensure the app functions perfectly and fully utilizes the unique features of HarmonyOS. Here is what developers should know.




Compatibility with Android API

HarmonyOS is compatible with a large number of Android APIs, so most Android apps can run on HarmonyOS without much code modification. Developers can quickly port the existing code developed on Android to HarmonyOS.

Things to consider:

  • Check the use of Google Mobile Services (GMS) APIs, which cannot be used on HarmonyOS. You need to switch to using Huawei Mobile Services (HMS) instead.
  • Features and APIs developed specifically for Android, such as Google Play Services, may need to be switched to HMS Core, which provides similar functionalities.


Use HMS Core instead of GMS.

For apps that require the features of Google Mobile Services (GMS), developers need to consider switching to HMS Core, which offers services and features similar to GMS, such as map services (Huawei Map Kit), notifications (Push Kit), payments (In-App Payment Kit), and other services.

Things to do:

  • Register as a Huawei developer and install the HMS Core SDK.
  • Replace Google's API with HMS Core's API.
  • Customize the code related to services such as login, payment, or maps to support HMS.


Customizing UI/UX to suit HarmonyOS

Although HarmonyOS has a UI design similar to Android, it also includes some unique elements. Developers should consider designing the User Interface (UI) to align with the usage on Huawei devices, such as the Super Device feature or Multi-Screen Collaboration.

UI customization tips:

  • Use ArkUI to create a declarative interface, which HarmonyOS supports both JavaScript and Java for UI development.
  • Consider adjusting the UI design to be suitable for use on various devices, whether they are smartphones, tablets, smartwatches, or IoT devices.


Managing Cloud Services and Push Notifications

If your Android app uses Firebase Cloud Messaging (FCM) for Push Notification, you need to switch to HUAWEI Push Kit instead. Additionally, if your app uses cloud services from Google such as Firebase or Google Cloud, you should consider switching to Huawei's cloud services or other neutral cloud services.

Setting up Push Notification:

  • Install the HUAWEI Push Kit SDK and replace the FCM code with the HMS Push Kit.
  • Check the connection and settings to ensure that notifications work smoothly on HarmonyOS.


Distributed Capabilities of HarmonyOS

HarmonyOS has special features that allow developers to create apps that support cross-device functionality, such as Distributed Data Management and Distributed Task Scheduling, which enable apps to share data and work together seamlessly across devices.

Using the Distributed feature:

  • Consider adapting the app to leverage Distributed Technology, such as sharing data between smartphones, tablets, and other devices.
  • Use the Distributed Data Management API and Distributed Task Scheduling API to enable the app to work seamlessly across devices.


Testing apps on HarmonyOS

After porting the app from Android to HarmonyOS is complete, developers should test the app to ensure it functions properly on HarmonyOS devices using HUAWEI DevEco Studio for debugging and testing the app on an emulator or real device.

App testing:

  • Use DevEco Studio and HarmonyOS Emulator to test the app's functionality.
  • Use Huawei Cloud Debugging to test the app on real devices connected via the cloud.


Publishing an app on HUAWEI AppGallery

After testing the app and finishing all the adjustments, developers can publish the app to HUAWEI AppGallery, which is Huawei's largest platform for downloading and installing applications.

Publishing process:

  • Register as a Huawei developer at Huawei Developer
  • Upload the app and details, and set up user targeting. (Target Audience)
  • Check the publication status and wait for approval from the Huawei team.




Porting an Android app to HarmonyOS is not a very complicated process because HarmonyOS is compatible with Android APIs. However, it is important for developers to switch from Google Mobile Services (GMS) APIs to Huawei Mobile Services (HMS) and customize the app to support HarmonyOS's special features, such as Distributed Capabilities. Testing the app and publishing it on HUAWEI AppGallery are the final steps to increase the app's accessibility to Huawei's user base.

Leave a comment :