Beginner: Integration of Huawei HEM Kit in Android

Lokesh Suryan
3 min readJun 11, 2021

--

Introduction

Huawei provides various services for developers to make ease of development and provides best user experience to end users. In this article, we will cover integration of Huawei Enterprise Manager (HEM) Kit in Android.

Huawei Enterprise Manager (HEM) is a mobile device management solution provided for you based on the powerful platform and hardware of Huawei. The device deployment service in HEM helps install a Device Policy Controller (DPC) app automatically on enterprise devices in batches.

Development Overview

You need to install Android studio IDE and I assume that you have prior knowledge about the Android and java.

Hardware Requirements

  • A computer (desktop or laptop) running Windows 10.
  • A Huawei phone (with the USB cable), which is used for debugging.
  • An enterprise-oriented Huawei phone that has not been activated (running EMUI 11.0 or later). The bring your own device (BYOD) mode is not supported

Software Requirements

  • Java JDK installation package.
  • Android studio IDE installed.
  • HMS Core (APK) 5.X or later.

Follows the steps.

1. Create Android Project.

  • Open Android Studio.
  • Click NEW Project, select a Project Templet
  • Enter project and Package Name and click on Finish:

2. Register as Huawei developer and complete identity verification in Huawei developer’s website, refer to register a Huawei ID.

3. To generate SHA-256 certificate fingerprint. On right-upper corner of android project click Gradle, choose Project Name > app > Tasks > android, and then click signing Report, as follows.

4. Create an App in AppGallery Connect.

5. Download the agconnect-services.json file from AGC, copy and paste in android Project under app directory, as follows.dependencies

6. Add the below maven URL in build.gradle(Project level) file under the repositories of buildscript, , for more information refer Add Configuration.

7. Add the below plugin and dependencies in build.gradle(App level)

8. Open AndroidManifest file and add below permissions.

https://gist.github.com/2162711ef0b108255d4e87051d8fc290

9. Development Procedure.

1. Create a java class MainActivity.java inside your package.

2. Create activity_main.xml layout file under app > main > res > layout folder.

10. To build apk and run in device, choose Build > Generate Signed Bundle/APK > Build for apk or Build and Run into connected device follow the steps.

Result

  1. Install application into device and click on app icon you can see below result.

2. If the EMUI device is less than targeted device, then you will get below errors.

Tips and Tricks

  • Always use the latest version of the library.
  • Add agconnect-services.json file without fail.
  • Add SHA-256 fingerprint without fail.
  • Make sure dependenciesadded in build files.
  • Make sure you have EMUI 11.0 and later versions.

Conclusion

In this article, we have learnt integration of Huawei HEM sdk. Also we learnt how to activate and deactivate an MDM license. HEM kit enables you to flexibly adapt your app to a wide range of device deployment scenarios for enterprises, to implement auto-deployment when they enroll a bunch of devices out of the box. This, in turn, dramatically reduces the required manual workload.

References

HEM Kit: https://developer.huawei.com/consumer/en/hms/huawei-hemkit/?ha_source=hms1

Original Source: https://forums.developer.huawei.com/forumPortal/en/topic/0202587659677630107?ha_source=hms1

--

--

No responses yet