App (file format)

From HandWiki
Short description: File format for HarmonyOS software

| name = APP | icon = HMOS Logo Icon.svg | icon_size = 64px | extension = .app,.hap | type code = | uniform type = | owner = Huawei | genre = Package format

| container for =

| contained by = | extended from = JAR | extended to = | standard = | url = }}

The HarmonyOS App Pack or the App file, identified with the file extension ".app", serves as the file format used by the HarmonyOS operating system. It functions as a native HarmonyOS app for distribution and installation through Huawei AppGallery,[1] or for distribution through Huawei Ability Gallery in respect of installation-free apps. The App file is also used by a number of other open source HarmonyOS-based operating systems such as OpenHarmony and Oniro OS-based operating systems for distribution and installation of applications, video games and middleware. Including non OpenHarmony-based operating systems, such as GNU Linux-based Unity Operating System that supports the app file format.[2] [3][4][5][6]

Each HarmonyOS app contains one or more HarmonyOS Ability Package (HAP) files with the file extension ".hap",[7] and the pack.info file that describes the attributes of the App file.[8]

Most HarmonyOS apps contain at least one HAP file of the entry type, which is the main module of the app, and additional HAP files of the feature type, which is used to implement a specific app feature.[8]

Overview

App Pack and HAP files

HarmonyOS apps are distributed as a software package file known as the App Pack or the App file, suffixed with .app, which is analogous to other software packages such as apk used by the Android operating system, appx in Microsoft Windows, or a Debian package in Debian-based operating systems.

To make a HarmonyOS app, a software development tool such as DevEco Studio is required to code and pack HarmonyOS Ability Package (HAP) and associated files into an app package.[9]

The HAP files may consist of resources, third-party libraries and configuration files. They are classified into two types of modules, i.e., entry and feature. The entry type of the HAP files is the main module and must be included into an app package, while the feature type of the HAP files is additional modules for implementing the features of the apps.

Moreover, an App file that contains different builds and specifications optimized for the various devices may contain more than one HAP file of the entry type.[3]

Prior to packing into an App Pack, HAP files are allowed to run directly on a real device or an emulator for developers to debug and verify the apps during the development phase.[10]

After development, the apps containing signature information can be distributed to different devices with AppGallery Connect, a tool kit of services for creation, development, distribution and maintenance of an app.[11]

Shared packages

HarmonyOS Shared Packages

For sharing code and resources in an App Pack, the operating system offers two kinds of shared packages: Harmony Archive (HAR), which is a static shared package, and Harmony Shared Package (HSP), which is a dynamic shared package.[12]

Both HAR and HSP enable sharing of code, C++ libraries, resources, and configuration files. In HAR, the code and resources are compiled together with invoking modules, possibly resulting in multiple copies of the same code and resources. In contrast, HSP allows independent compilation, leading to only one copy of code and resources in the build product.[12]

When multiple HAPs reference the same HAR, the HSP can be used instead to share some state variables and reduce the size of an App Pack. However, the HSP has some restrictions; for example, it does not support the declaration of abilities in its configuration file and its invoking modules must be in the same stage model as with the HSP.[12]

App file structure

The structure of the App file after built and packaged in a stage model usually contains the following files and folders.[8]

  • entry.hap and feature.hap: the basic modules of both entry and feature types for installing an app, containing the following folders and files.
    • ets: a folder storing bytecode files generated after the code build.
    • libs: a folder storing the dependency files of the main module.
    • resources: a folder containing resource files such as graphics, multimedia, character strings, and layouts.
    • resources.index: a file providing a resource index table generated when an app is built.
    • app.json5 and module.json5: JSON files with configuration information for build tools, operating system and application markets.[13]
  • pack.info: a file describing the attributes of the App Pack.

See also

References

  1. "HarmonyOS Project Overview". https://developer.harmonyos.com/en/docs/documentation/doc-guides/project_overview-0000001053822398. 
  2. "UOS could support HarmonyOS hap app format". https://www.huaweicentral.com/uos-could-support-harmonyos-hap-app-format/. 
  3. 3.0 3.1 "Application Fundamentals". https://developer.harmonyos.com/en/docs/documentation/doc-guides/basic-fundamentals-0000000000041611. 
  4. "What Is an Atomic Service". https://developer.harmonyos.com/en/docs/documentation/doc-guides/atomic-service-definition-0000001090840664. 
  5. Li, Deng (2022-11-28). "Orange Pi OS launched, based on Huawei HarmonyOS" (in en-US). https://www.huaweicentral.com/orange-pi-os-launched-based-on-huawei-harmonyos/. 
  6. Anand, Abhinav (2023-11-13). "Huawei ditches Android with HarmonyOS Next" (in en-US). https://www.androidheadlines.com/2023/11/huawei-android-harmonyos-next.html. 
  7. "HAP File - What is a .hap file and how do I open it?". https://fileinfo.com/extension/hap. 
  8. 8.0 8.1 8.2 "Application Package Structure in Stage Model". https://developer.harmonyos.com/en/docs/documentation/doc-guides-V3/application-package-structure-stage-0000001478061425-V3. 
  9. "HUAWEI DevEco Studio - HUAWEI HarmonyOS APP". https://developer.harmonyos.com/en/develop/deveco-studio/. 
  10. "Overview - Building Your App". https://developer.harmonyos.com/en/docs/documentation/doc-guides/build_overview-0000001055075201. 
  11. "Overview - AppGallery Connect". https://developer.huawei.com/consumer/en/doc/distribution/app/agc-help-overview-0000001100246618. 
  12. 12.0 12.1 12.2 "Shared Package Overview". https://developer.harmonyos.com/en/docs/documentation/doc-guides-V3/shared-guide-0000001523444052-V3?catalogVersion=V3. 
  13. "Application Configuration File Overview (Stage Model)". https://developer.harmonyos.com/en/docs/documentation/doc-guides-V3/application-configuration-file-overview-stage-0000001428061460-V3.