目录

Developing a Static Shared Package

A HAR is a static shared package that can contain code, C++ libraries, resource files, and configuration files (also called profiles). It enables modules and projects to share code of ArkUI components, resources, and more. Unlike a HAP, a HAR cannot be independently installed on a device. Instead, it can only be referenced as a dependency of a module. This section describes how to create a HAR module and compile a shared package.

The following figure shows the project structure of a HAR module.

The fields specific to the HAR module are as follows. Other fields are the same as those of the entry or feature module. For details, see Project Overview.

Since DevEco Studio 6.0.1 Beta1, you can specify the C++ language standard when creating a HAR module.

Creating a HAR Module

  1. Right-click the top of the project directory and choose New > Module from the shortcut menu.
  2. On the Choose Your Ability Template page, select Static Library and click Next.

  3. On the Configure New Module page, set the following parameters and click Finish to create a HAR module.

    • Module name: name of the new module.
    • Device type: supported device type.
    • Enable native: whether to create a module for invoking C++ code.
    • C++ Standard: C++ standard library. The options are Toolchain Default, C++11, and C++14. This parameter must be set only when Enable native is toggled on. This field is supported since DevEco Studio 6.0.1 Beta1.

    After the creation is complete, the HAR module and related files are generated in the project directory.

Building a HAR Module

When the development of a HAR module is complete, select the module name and choose Build > Make Module ${libraryName} on the menu bar to compile and build the module into a HAR. The HAR can be referenced by other modules of the same project or be uploaded to the ohpm repository for access by other developers. For more details, see Building a HAR.

A HAR is in .har format and is accessible in the build folder of the module directory.

During compilation and build, pay attention to the following: