目录

Application Package Overview

Before developing an app, you need to understand the basic knowledge such as the app design mechanism and application package structure.

Application and Application Package

A user application, also known as an application or app, runs on the operating system of devices and provides particular services for users. The software package corresponding to an application is called an application package.

The system provides an efficient management mechanism for application packages. With this mechanism, you can easily develop, install, query, update, and uninstall application packages. In addition, to allow an application to run across various chip platforms, such as x86, Arm, and other 32-bit or 64-bit platforms, the system abstracts away the differences between chip platforms for application packages.

Multi-Module Design Mechanism

Module Types

There are two types of modules by usage scenario:

Selecting a Package Type

The following table compares the HAP, HAR, and HSP in terms of their functionality and use scenarios.

Module Type Package Type Description
Ability HAP A functional module of an application, which can be installed and run separately.
Static Library HAR

Static shared package, which is reused in the build phase.

- It can be shared within applications, or it can also be released as a second-party library (SDK) or third-party library (SDK) for other applications to use.

- As a second-party library (SDK), it is released to the OHPM private repository for other internal applications to use.

- As a third-party library (SDK), it is released to the OHPM central repository for other external applications to use.

- When multiple HAPs or HSPs reference the same HAR at the same time, code and resources are repeatedly copied between the packages. As a result, the application package size increases.

- When building a HAR, you are advised to enable code obfuscation to protect code assets.

Shared Library HSP

Dynamic shared package, which is reused in the running phase.

- When multiple HAPs or HSPs reference the same shared package, using an HSP instead of HAR as the shared package can avoid the unnecessary copies of code and resource files, thereby reducing the application package size.

The following table compares the HAP, HSP, and HAR regarding their specifications. The symbol "√" means that the item is supported, and "×" means the opposite.

You can select a package type for development based on application requirements. For details, see HAP, HAR, and HSP.

Specifications HAP HAR HSP
Declaring the UIAbility in the configuration file √ √ √
Declaring the ExtensionAbility in the configuration file √ √ √
Declaring the pages tag in the configuration file √ × √
Including resource files and .so files √ √ √
Depending on other HARs √ √ √
Depending on other HSPs √ √ √
Being installed or run on a device separately √ × √
  • If the HAR supports the declaration of the pages tag, when the HAR is packaged into the HAP or HSP, the relative paths of pages existing in the HAR and HAP/HSP may be duplicated, disabling the specific routing page from being identified. Therefore, the configuration file of a HAR does not support declaration of the pages tag. Still, it can include pages, which can be redirected through navigation.
  • As the HSP supports only intra-application sharing, a HAR that depends on any HSP can be shared only within the same application. Do not release such a HAR to a second-party or third-party library for other applications to use: Using it in other applications will result in build failures.
  • HAR and HSP do not support cyclic dependency or dependency transfer. For details, see the constraints in HAR and HSP.