The packing tool packs compiled files for installation and release. You can use DevEco Studio or the JAR package of the packing tool to pack files. The JAR package is usually stored in the toolchains directory of the SDK.
The packing tool supports the generation of HAP (module package of the ability type), HSP (dynamically shared package), APP (application program package), HQF (quick fix module package), and APPQF (quick fix package) files.
You can obtain the files in the packing command from DevEco Studio build products by performing the following operations.
In the /hvigor/hvigor-config.json5 file in the root directory of the DevEco Studio project, change the value of level under logging to debug.
On the DevEco Studio menu bar, choose Build > Clear projects.
On the DevEco Studio menu bar, choose Build > Build App(s).
In the Build window at the bottom of DevEco Studio, search for app_packing_tool.jar and check the file path in the packing parameters.
The packaging tool verifies the validity of the attributes in the module.json file. The module.json file is a build product, whose attribute values are automatically generated during building. The mapping between the attribute values and configuration items in the configuration file is as follows.
Table 1 Mapping between attributes of the module.json file and items of the configuration file
| Attributes of module.json | Description | Configuration Items of module.json5 | Configuration Items of app.json5 | Configuration items of Project-level build-profile.json5 File |
|---|---|---|---|---|
| bundleName | Bundle name. | - | bundleName | - |
| bundleType | Bundle type. | - | bundleType | - |
| versionCode | Application version number. | - | versionCode | - |
| debug | Whether the application can be debugged. | - | debug | - |
| module/name | Module name. | module/name | - | - |
| minCompatibleVersionCode | Earliest compatible version number. | - | minCompatibleVersionCode | - |
| minAPIVersion | Minimum API version for running the application. | - | minAPIVersion | compatibleSdkVersion |
| targetAPIVersion | Target API version required for running the application. | - | targetAPIVersion | targetSdkVersion/compileSdkVersion Note: If targetSdkVersion is available, it determines targetAPIVersion. Otherwise, it is determined by compileSdkVersion. |
| querySchemes | URL schemes that allow the application to perform redirection query. | querySchemes | - | - |
| generateBuildHash | Whether the hash value of the HAP or HSP is generated by the packing tool. | generateBuildHash | generateBuildHash | - |
| buildVersion | Build version of an application. | - | buildVersion | - |
You can use the JAR package of the packing tool to generate a HAP file for a module by passing in packing options and file paths.
Validity Verification During HAP Packing
Compressing Rules During HAP Packing
Packing command example:
Stage model:
java -jar app_packing_tool.jar --mode hap --json-path <path> [--resources-path <path>] [--ets-path <path>] [--index-path <path>] [--pack-info-path <path>] [--lib-path <path>] --out-path <path> [--force true] [--compress-level 5] [--pkg-context-path <path>] [--hnp-path <path>] [--pkg-sdk-info-path <path>] [--skills-path <path>]
FA model:
java -jar app_packing_tool.jar --mode hap --json-path <path> [--maple-so-path <path>] [--profile-path <path>] [--maple-so-dir <path>] [--dex-path <path>] [--lib-path <path>] [--resources-path <path>] [--index-path <path>] --out-path <path> [--force true] [--compress-level 5]
Table 2 Parameters of the HAP packing command
| Name | Mandatory | Option | Description | Remarks |
|---|---|---|---|---|
| --mode | Yes | hap | Packing mode. | NA |
| --json-path | Yes | NA | Path of the JSON file. The file name must be config.json in the FA model and module.json in the stage model. | NA |
| --profile-path | No | NA | Path of the CAPABILITY.profile file. | NA |
| --maple-so-path | No | NA | Path of the Maple SO file. The file name extension must be .so. If there are multiple SO files, separate them with commas (,). | NA |
| --maple-so-dir | No | NA | Path of the maple SO directory (folder). | NA |
| --dex-path | No | NA | Path of the DEX file. The file name extension must be .dex. If there are multiple DEX files, separate them with commas (,). The value can also be the directory (folder) where the DEX file is stored. | NA |
| --lib-path | No | NA | Path of the library file. Since API version 22, when --exist-src-path is valid and --lib-path-retain is set to true, the libs directory is incrementally packed. That is, the libs directory in the source HAP file configured by --exist-src-path is directly copied, the --lib-path parameter is invalid and the libs directory configured by --lib-path is not packed. | NA |
| --resources-path | No | NA | Path of the resources file. | NA |
| --index-path | No | NA | Path of the INDEX file. The file name must be resources.index. | NA |
| --pack-info-path | No | NA | Path of the pack.info file. The file name must be pack.info. | NA |
| --rpcid-path | No | NA | Path of the rpcid.sc file. The file name must be rpcid.sc. | NA |
| --js-path | No | NA | Path of the JS file. | This parameter is valid only in the stage model. |
| --ets-path | No | NA | Path of the ETS file. | This parameter is valid only in the stage model. |
| --out-path | Yes | NA | Path of the target file. The file name extension must be .hap. | NA |
| --force | No | boolean | Whether to forcibly overwrite the target file if its path already exists. If the target file specified by --out-path already exists before packing and this parameter is set to true, the file is overwritten. If this parameter is set to false, the packing process is terminated and an error is reported. If the target file specified by --out-path does not exist before packing, the file is packed properly. This parameter is invalid. The default value is false. | NA |
| --an-path | No | NA | Path to the an file. | This parameter is valid only in the stage model. |
| --ap-path | No | NA | Path to the ap file. | This parameter is valid only in the stage model. |
| --dir-list | No | NA | List of directories (folders) to be packed into the HAP file. | NA |
| --compress-level | No | number | Compression level of files in the lib directory. The default value is 1. The value ranges from 1 to 9. This parameter is valid only when compressNativeLibs is set to true. A larger value indicates a higher compression rate and a slower compression speed. | NA |
| --pkg-context-path | No | NA | Path of the pkgContextInfo.json file, which contains the context information. This parameter is mandatory when bundleType in the app.json5 configuration file is not set to appPlugin and requestPermissions in the module.json5 configuration file contains "ohos.permission.kernel.SUPPORT_PLUGIN". | |
| --exist-src-path | No | NA | Path of the source HSP file for incremental packing, which must point to an existing and valid .hsp file. When --lib-path-retain is set to true, the packing tool directly copies the libs directory in the source HSP file, and does not pack the libs directory specified by --lib-path. This feature is called incremental packing. When --lib-path-retain is set to false, the libs directory specified by --lib-path is packed properly, and this parameter is invalid. You can use incremental packing to speed up the compression of .so files in the libs directory. This parameter is supported since API version 22. | |
| --lib-path-retain | No | boolean | Whether to perform incremental packing on the libs directory. The value true means to perform incremental packing on the libs directory, that is, directly copy the libs directory in the source HSP to which --exist-src-path points, and do not pack the libs directory specified by --lib-path. The value false means the opposite. The default value is false. This parameter must be used together with --exist-src-path. Otherwise, it does not take effect. This parameter is supported since API version 22. | |
| --pkg-sdk-info-path | No | NA | Path of the pkgSdkInfo.json file, which contains the basic information about the HARs on which the build product depends, including the module name and version. The file name must be pkgSdkInfo.json. This parameter is supported since API version 23. | |
| --skills-path | No | NA | Path of the directory for storing skills. During packaging, the skill content in the --skills-path directory is packed into the HSP based on the skillProfiles configuration item in the module.json5 file. This parameter is available when bundleType is set to app, atomicService, or skill. This parameter is unavailable when bundleType is set to shared, appService, or appPlugin. If this parameter is passed in these cases, the packaging will fail. This parameter is supported starting from API version 26.0.0. |
You can use the JAR package of the packing tool to generate an APP file for an application by passing in packing options and file paths. The APP file is used to release the application to the application market.
Table 4 Validity verification rules during APP packing
| Fields in module.json of HAP or HSP That Are Verified | Verification Rules |
|---|---|
| name field in module | The name field values of all HAPs or HSPs must be unique. |
| bundleName | The bundleName field values of all HAPs or HSPs must be the same. |
| bundleType | The bundleType field values of all HAPs or HSPs must be the same. |
| versionCode | The versionCode field values of all HAPs or HSPs must be the same. |
| debug | Since API version 20, the debug field values of all HAPs must be the same. If the debug field value of HAP is false, the debug field value of HSP must also be false. If the debug field value of HAP is true, there is no requirement for the debug field of HSP. For API version 19 and earlier versions, the debug field values of all HAPs or HSPs must be the same. |
| minAPIVersion | Since API version 20, the minAPIVersion field values of all HAPs must be the same and must be greater than or equal to the maximum value of the minAPIVersion field of all HSPs. For API version 19 and earlier versions, the minAPIVersion field values of all HAPs or HSPs must be the same. |
| minCompatibleVersionCode | Since API version 16, the minCompatibleVersionCode field values of all HAPs must be the same and must be greater than or equal to the maximum value of the minCompatibleVersionCode field of all HSPs. For API version 15 and earlier versions, the minCompatibleVersionCode field values of all HAPs or HSPs must be the same. |
| targetAPIVersion | Since API version 16, the targetAPIVersion field values of all HAPs must be the same and must be greater than or equal to the maximum value of the targetAPIVersion field of all HSPs. For API version 15 and earlier versions, the targetAPIVersion field values of all HAPs or HSPs must be the same. |
| versionName | Since API version 12, the versionName field is no longer verified. |
| buildVersion | Starting from API version 23, the buildVersion field values of all HAPs or HSPs must be consistent. |
Compression rules: During APP packing, the HAP and HSP files in release mode are compressed, while those in debug mode are not.
If the .so files that have been compressed in the HAP or HSP are compressed again during APP packing, the size of these files will not be significantly reduced.
Packing command example:
java -jar app_packing_tool.jar --mode app [--hap-path <path>] [--hsp-path <path>] --out-path <path> [--signature-path <path>] [--certificate-path <path>] --pack-info-path <path> [--pack-res-path <path>] [--force true] [--encrypt-path <path>] [--pac-json-path <path>] [--atomic-service-entry-size-limit <size>] [--atomic-service-non-entry-size-limit <size>] [--replace-pack-info false]
Table 5 Parameters of the APP packing command
| Name | Mandatory | Option | Description |
|---|---|---|---|
| --mode | Yes | app | Packing mode. Each HAP file to pack into the APP file must pass the validity check. |
| --hap-path | No | NA | Path of the HAP files. The file name extension must be .hap. If there are multiple HAP files, separate them with commas (,). The value can also be the directory (folder) where the HAP files are stored. |
| --hsp-path | No | NA | Path of the HSP files. The file name extension must be .hsp. If there are multiple HSP files, separate them with commas (,). The value can also be the directory (folder) where the HSP files are stored. |
| --pack-info-path | Yes | NA | Path of the pack.info file. The file name must be pack.info. |
| --out-path | Yes | NA | Path of the target file. The file name extension must be .app. |
| --signature-path | No | NA | Path of the signature file. |
| --certificate-path | No | NA | Path of the certificate file. |
| --pack-res-path | No | NA | Path of the pack.res file. |
| --force | No | boolean | Whether to forcibly overwrite the target file if its path already exists. If the target file specified by --out-path already exists before packing and this parameter is set to true, the file is overwritten. If this parameter is set to false, the packing process is terminated and an error is reported. If the target file specified by --out-path does not exist before packing, the file is packed properly. This parameter is invalid. The default value is false. |
| --encrypt-path | No | NA | The file name must be encrypt.json. |
| --pac-json-path | No | NA | pac.json file. The file name must be pac.json. This parameter is supported since API version 20. |
| --atomic-service-entry-size-limit | No | NA | Size limit of the entry package (including the size of the dependency package) of the atomic service. This parameter is valid only in the stage model and bundleType is set to atomicService. The value is an integer ranging from 0 to 4194304, in KB. The value 0 indicates that the size is not limited. If this parameter is not set, the default value 2048 KB is used. If the entry package is in release mode (the type field in the module.json5 file is set to entry and the debug field in the app.json5 file is set to false), this limit applies to the compressed entry package size (including the size of the dependency package) during APP packing. |
| --atomic-service-non-entry-size-limit | No | NA | Size limit of the non-entry package (including the size of the dependency package) of the atomic service. This parameter is valid only in the stage model and bundleType is set to atomicService. The value is an integer ranging from 0 to 4194304, in KB. The value 0 indicates that the size is not limited. If this parameter is not set, the default value 2048 KB is used. If the non-entry package is in release mode (the type field in the module.json5 file is not set to entry and the debug field in the app.json5 file is set to false), this limit applies to the compressed non-entry package size (including the size of the dependency package) during APP packing. |
| --replace-pack-info | No | boolean | Whether to use the pack.info file specified by the --pack-info-path parameter to replace the pack.info file in the HAP and HSP files during APP packing. The value true means to replace, and false means the opposite. The default value is true. This parameter is supported since API version 22. |
| --stat-duplicate | No | boolean | Whether to scan for duplicate .so files after the packing is complete. This parameter can be used to identify duplicate .so files to reduce the package size. If this parameter is set to true, the scanning is performed. After the scanning is complete, the scan_report directory is generated in the directory where the output file specified by --out-path is located. The scan_report directory contains the duplicate .so file scanning report whose file name is scan_result, and the scan_report directory path is printed in the warning message. If this parameter is set to false, the scanning is not performed. The default value is false. This parameter is supported since API version 23. |
| --deduplicate-so | No | boolean | Used to deduplicate .so files during packaging to effectively reduce the size of the app package. Default value: false Value: true: Deduplicate .so files. After deduplication is complete, a deduplication report so_dedup_report.json is generated in the directory specified by --out-path, and the deduplication result is printed in logs. false: Do not deduplicate .so files. Deduplication policy: - If the same .so file exists in different modules of the app package and these .so files will be decompressed to the app root directory (that is, compressNativeLibs and extractNativeLibs in the module.json5 file are not both false, and libIsolation is false). - The packaging tool will perform deduplication based on configurations such as deviceTypes, deliveryWithInstall, distributionFilter, and requiredDeviceFeatures to ensure that the app functions remain unchanged on each device where the app can be installed after deduplication. NOTE - If the app code contains operations that directly read .so files from the original installation package, the app behavior will change after deduplication is enabled. In this case, do not enable this function, or modify the code logic to read the decompressed .so file before enabling this function. - If you enable .so file deduplication during packaging, you are advised to carefully check the deduplication result and fully verify the function integrity of the app package after deduplication before releasing it. This parameter is supported starting from API version 26.0.0. |
If multiple teams develop the same application but it is inconvenient to share code, you can use multi-project packing, which packs the packed HAP, HSP, and APP files into a final APP file and releases it to the app market.
Table 6 Validity verification rules for multi-project packing
| Fields in module.json of HAP or HSP That Are Verified | Verification Rules |
|---|---|
| name field in module | The name field values of all HAPs or HSPs must be unique. |
| bundleName | The bundleName field values of all HAPs or HSPs must be the same. |
| bundleType | The bundleType field values of all HAPs or HSPs must be the same. |
| versionCode | The versionCode field values of all HAPs or HSPs must be the same. |
| debug | Since API version 20, the debug field values of all HAPs must be the same. If the debug field value of HAP is false, the debug field value of HSP must also be false. If the debug field value of HAP is true, there is no requirement for the debug field of HSP. For API version 19 and earlier versions, the debug field values of all HAPs or HSPs must be the same. |
| minAPIVersion | Since API version 20, the minAPIVersion field values of all HAPs must be the same and must be greater than or equal to the maximum value of the minAPIVersion field of all HSPs. For API version 19 and earlier versions, the minAPIVersion field values of all HAPs or HSPs must be the same. |
| minCompatibleVersionCode | Since API version 16, the minCompatibleVersionCode field values of all HAPs must be the same and must be greater than or equal to the maximum value of the minCompatibleVersionCode field of all HSPs. For API version 15 and earlier versions, the minCompatibleVersionCode field values of all HAPs or HSPs must be the same. |
| targetAPIVersion | Since API version 16, the targetAPIVersion field values of all HAPs must be the same and must be greater than or equal to the maximum value of the targetAPIVersion field of all HSPs. For API version 15 and earlier versions, the targetAPIVersion field values of all HAPs or HSPs must be the same. |
| versionName | Since API version 12, the versionName field is no longer verified. |
| buildVersion | Since API version 23, the buildVersion field values of all HAPs or HSPs must be the same. |
Packing command example:
java -jar app_packing_tool.jar --mode multiApp [--hap-list <path>] [--hsp-list <path>] [--app-list <path>] --out-path <option> [--force true] [--encrypt-path <path>] [--pac-json-path <path>] [--atomic-service-entry-size-limit <size>] [--atomic-service-non-entry-size-limit <size>]
Table 7 Parameters of the multi-project packing command
| Name | Mandatory | Option | Description |
|---|---|---|---|
| --mode | Yes | multiApp | Packing mode. Each HAP file to pack into the APP file must pass the validity check. |
| --hap-list | No | Path of the HAP files | Path of the HAP files. The file name extension must be .hap. If there are multiple HAP files, separate them with commas (,). The value can also be the directory (folder) where the HAP files are stored. |
| --hsp-list | No | Path of the HSP files | Path of the HSP files. The file name extension must be .hsp. If there are multiple HSP files, separate them with commas (,). The value can also be the directory (folder) where the HSP files are stored. |
| --app-list | No | Path of the APP files | Path of the APP files. The file name extension must be .app. If there are multiple APP files, separate them with commas (,). The value can also be the directory (folder) where the APP files are stored. You must specify --hap-list, --hsp-list, or --app-list, or any of their combinations. |
| --out-path | Yes | NA | Path of the target file. The file name extension must be .app. |
| --force | No | boolean | Whether to forcibly overwrite the target file if its path already exists. If the target file specified by --out-path already exists before packing and this parameter is set to true, the file is overwritten. If this parameter is set to false, the packing process is terminated and an error is reported. If the target file specified by --out-path does not exist before packing, the file is packed properly. This parameter is invalid. The default value is false. |
| --encrypt-path | No | Path of encrypt.json | The file name must be encrypt.json. |
| --pac-json-path | No | NA | pac.json file. The file name must be pac.json. If this parameter is not set, the app product does not contain the pac.json file. The pac.json file in the APP file specified by --app-list is not packed into the final app. This parameter is supported since API version 20. |
| --atomic-service-entry-size-limit | No | NA | Size limit of the entry package (including the size of the dependency package) of the atomic service. This parameter is valid only in the stage model and bundleType is set to atomicService. The value is an integer ranging from 0 to 4194304, in KB. The value 0 indicates that the size is not limited. If this parameter is not set, the default value 2048 KB is used. If the entry package is in release mode (the type field in the module.json5 file is set to entry and the debug field in the app.json5 file is set to false), this limit applies to the compressed entry package size (including the size of the dependency package) during APP packing. |
| --atomic-service-non-entry-size-limit | No | NA | Size limit of the non-entry package (including the size of the dependency package) of the atomic service. This parameter is valid only in the stage model and bundleType is set to atomicService. The value is an integer ranging from 0 to 4194304, in KB. The value 0 indicates that the size is not limited. If this parameter is not set, the default value 2048 KB is used. If the non-entry package is in release mode (the type field in the module.json5 file is not set to entry and the debug field in the app.json5 file is set to false), this limit applies to the compressed non-entry package size (including the size of the dependency package) during APP packing. |
| --stat-duplicate | No | boolean | Whether to scan for duplicate .so files after the packing is complete. This parameter can be used to identify duplicate .so files to reduce the package size. If this parameter is set to true, the scanning is performed. After the scanning is complete, the scan_report directory is generated in the directory where the output file specified by --out-path is located. The scan_report directory contains the duplicate .so file scanning report whose file name is scan_result, and the scan_report directory path is printed in the warning message. If this parameter is set to false, the scanning is not performed. The default value is false. This parameter is supported since API version 23. |
| --deduplicate-so | No | boolean | Used to deduplicate .so files during packaging to effectively reduce the size of the app package. Default value: false Value: <idp:inline displayname="code" id="code136141711112512">true: Deduplicate .so files. After deduplication is complete, a deduplication report so_dedup_report.json is generated in the directory specified by <idp:inline displayname="code" id="code1717253810277">--out-path, and the deduplication result is printed in logs. <idp:inline displayname="code" id="code19446411122719">false: Do not deduplicate .so files. Deduplication policy: - If the same .so file exists in different modules of the app package and these .so files will be decompressed to the app root directory (that is, compressNativeLibs and extractNativeLibs in the module.json5 file are not both false, and libIsolation is false). - The packaging tool will perform deduplication based on configurations such as <idp:inline displayname="code" id="code65591541280">deviceTypes, <idp:inline displayname="code" id="code65595541287">deliveryWithInstall, <idp:inline displayname="code" id="code195591554192819">distributionFilter, and <idp:inline displayname="code" id="code5559105411288">requiredDeviceFeatures to ensure that the app functions remain unchanged on each device where the app can be installed after deduplication. NOTE - If the app code contains operations that directly read .so files from the original installation package, the app behavior will change after deduplication is enabled. In this case, do not enable this function, or modify the code logic to read the decompressed .so file before enabling this function. - If you enable .so file deduplication during packaging, you are advised to carefully check the deduplication result and fully verify the function integrity of the app package after deduplication before releasing it. This parameter is supported starting from API version 26.0.0. |
The HQF file is used for incremental debugging. You can use the JAR package of the packing tool to generate an HQF file for an application by passing in packing options and file paths.
Packing command example:
java -jar app_packing_tool.jar --mode hqf --json-path <path> [--lib-path <path>] [--ets-path <path>] [--resources-path <path>] --out-path <path> [--force true]
Table 8 Parameters of the HQF packing command
| Name | Mandatory | Option | Description |
|---|---|---|---|
| --mode | Yes | hqf | Packing mode. |
| --json-path | Yes | NA | Path of the .json file. The file name must be patch.json. |
| --lib-path | No | NA | Path of the library file. |
| --ets-path | No | NA | Path of the ETS file. |
| --resources-path | No | NA | Path of the resources file. |
| --out-path | Yes | NA | Path of the target file. The file name extension must be .hqf. |
| --force | No | boolean | Whether to forcibly overwrite the target file if its path already exists. If the target file specified by --out-path already exists before packing and this parameter is set to true, the file is overwritten. If this parameter is set to false, the packing process is terminated and an error is reported. If the target file specified by --out-path does not exist before packing, the file is packed properly. This parameter is invalid. The default value is false. |
An APPQF file consists of one or more HQF files. These HQF files are split from an APPQF file in the app market and then distributed to specific devices. You can use the JAR package of the packing tool to generate an APPQF file for an application by passing in packing options and file paths.
APPQF Packing Validity Verification
Packing command example:
java -jar app_packing_tool.jar --mode appqf --hqf-list <path> --out-path <path> [--force true]
Table 9 Parameters of the APPQF packing command
| Name | Mandatory | Option | Description |
|---|---|---|---|
| --mode | Yes | appqf | Packing mode. |
| --hqf-list | Yes | NA | Path of the HQF file. Use commas (,) to separate multiple HQF files. |
| --out-path | Yes | NA | Path of the target file. The file name extension must be .appqf. |
| --force | No | boolean | Whether to forcibly overwrite the target file if its path already exists. If the target file specified by --out-path already exists before packing and this parameter is set to true, the file is overwritten. If this parameter is set to false, the packing process is terminated and an error is reported. If the target file specified by --out-path does not exist before packing, the file is packed properly. This parameter is invalid. The default value is false. |
For the same APP, the values of versionName and versionCode of all the HAP and HSP files must be the same. When only one HAP or HSP needs to be updated, you can run the versionNormalize command to unify the versions of these HAP or HSP files. This command changes the version numbers and names of the HAP and HSP files passed in, and generates in the specified directory new HAP and HSP files with the same names and a version_record.json file to record their original version numbers and names.
Packing command example:
java -jar app_packing_tool.jar --mode versionNormalize --input-list 1.hap,2.hsp --version-code 1000001 --version-name 1.0.1 --out-path out
Table 10 Parameters of the versionNormalize command
| Name | Mandatory | Option | Description |
|---|---|---|---|
| --mode | Yes | versionNormalize | Command type. |
| --input-list | Yes | Path of the HAP or HSP files | 1. Path of the HAP or HSP files. The file name extension must be .hap or .hsp. If there are multiple HAP or HSP files, separate them with commas (,). 2. The value can also be the directory (folder) where the HAP and HSP files are stored. If this is the case, all HAP and HSP files in the directory (folder) are read. |
| --version-code | Yes | Internal version number | New internal version number of the HAP and HSP files. The value must be an integer and cannot be earlier than the version numbers of all the HAP and HSP files passed in. |
| --version-name | Yes | Version name | New version name of the HAP and HSP files. |
| --out-path | Yes | NA | Target file path, which must be a directory (folder). |
The packageNormalize command is used to change the passed-in HSP bundle name and version number and generate an HSP with the same name in the specified directory.
Packing command example:
java -jar app_packing_tool.jar --mode packageNormalize --hsp-list 1.hsp,2.hsp --bundle-name com.example.myapplication --version-code 1000001 --out-path out
Table 11 Parameters of the packageNormalize command
| Name | Mandatory | Option | Description |
|---|---|---|---|
| --mode | Yes | packageNormalize | Command type. |
| --hsp-list | Yes | Path of the HSP files | 1. Path of the HSP files. The file name extension must be .hsp. If there are multiple HSP files, separate them with commas (,). 2. Directory of the HSP files. Only .hsp files in the directory are processed. |
| --bundle-name | Yes | Bundle name | New bundle name, to which the passed-in bundle name will be changed. |
| --version-code | Yes | Internal version number | New version number, to which the passed-in version number will be changed. The value must be an integer greater than 0. |
| --out-path | Yes | NA | Target file path, which must be a directory (folder). |
This command is used to modify the following parameters of the HAP or HSP file: deviceType, bundleName, versionName, versionCode, minCompatibleVersionCode, minAPIVersion, targetAPIVersion,
apiReleaseType, bundleTypes, installationFree, and deliveryWithInstall. It can also generate a modified HAP or HSP file with the same name and a general_record.json file in the specified directory to record the original parameter names and module names of all HAPs or HSPs. The parameters set above must comply with the correct packing specifications. Otherwise, the HAP or HSP file fails to be generated in the specified directory, and no file is generated in the specified directory.
Packing command example:
java -jar app_packing_tool.jar --mode generalNormalize --input-list 1.hsp,2.hsp --bundle-name com.example.myapplication --version-code 1000001 --version-name 1.0.1 --min-compatible-version-code 14 --min-api-version 14 --target-api-version 14 --api-release-type Release1 --bundle-type app --installation-free false --delivery-with-install true --device-types default,tablet --out-path out
Table 12 Parameters of the generalNormalize command
| Name | Mandatory | Option | Description |
|---|---|---|---|
| --mode | Yes | generalNormalize | Command type. |
| --input-list | Yes | Path of the HAP or HSP files | 1. Path of the HAP or HSP files. The file name extension must be .hap or .hsp. Use commas (,) to separate the paths of multiple HAP or HSP files. 2. The value can also be the directory (folder) where the HAP and HSP files are stored. If this is the case, all HAP and HSP files in the directory (folder) are read. |
| --bundle-name | No | Bundle name | New bundle name, to which the passed-in bundle name will be changed. The value cannot be empty. For details about the definition and specifications of this field, see the bundleName field in app.json5. |
| --version-code | No | Internal version number | New version number, to which the passed-in version number will be changed. The value is an integer ranging from 0 to 2147483647. The value cannot be empty. For details about the definition and specifications of this field, see the versionCode field in app.json5. |
| --version-name | No | Version name | Version name. The version name of the input package will be changed to this version name. The value cannot be empty. For details about the definition and specifications of this field, see the versionName field in app.json5. |
| --min-compatible-version-code | No | Earliest compatible version number | New earliest compatible version number, to which the passed-in earliest compatible version number will be changed. The value is an integer ranging from 0 to 2147483647 and cannot be empty. For details about the definition and specifications of this field, see the minCompatibleVersionCode field in app.json5. |
| --min-api-version | No | Minimum SDK API version | New minimum SDK API version, to which the passed-in minimum SDK API version will be changed. The value is an integer ranging from 0 to 2147483647 and cannot be empty. For details about the definition and specifications of this field, see the minAPIVersion field in app.json5. |
| --target-api-version | No | Target API version | New target API version, to which the passed-in target API version will be changed. The value is an integer ranging from 0 to 2147483647 and cannot be empty. For details about the definition and specifications of this field, see the targetAPIVersion field in app.json5. |
| --api-release-type | No | Target API version type | New target API version type, to which the passed-in target API version type will be changed. The value cannot be empty. For details about the definition and specifications of this field, see the apiReleaseType field in app.json5. |
| --bundle-type | No | Bundle type | New bundle type, to which the passed-in bundle type will be changed. The value cannot be empty. For details about the definition and specifications of this field, see the bundleType field in app.json5. |
| --installation-free | No | Installation-free feature | New installation-free feature, to which the passed-in installation-free feature will be changed. The value cannot be empty. For details about the definition and specifications of this field, see the installationFree field in module.json5 of the stage model or config.json of the FA model. |
| --delivery-with-install | No | Whether the HAP file will be installed when the user installs the application | New value indicating whether the specified HAP file will be installed when the user installs the application, to which the passed-in deliveryWithInstall will be changed. The value cannot be empty. For details about the definition and specifications of this field, see the deliveryWithInstall field in module.json5 of the stage model or config.json of the FA model. |
| --device-types | No | Type of device on which the ability can run | New device type, to which the passed-in device type will be changed. The value cannot be empty. For details about the definition and specifications of this field, see the deviceTypes field in the module.json5 of the stage model or config.json of the FA model. The value is a string, and multiple device types are separated by commas (,). |
| --out-path | Yes | NA | Target file path, which must be a directory (folder) with read and write permissions. |
| --build-version | No | Build number. | Build number, to which the passed-in build number will be changed. The value cannot be empty. For details about the definition and specifications of this field, see the buildVersion field in app.json5. |
This command is used to pack snapshot resources of atomic services.
Packing command example:
java -jar app_packing_tool.jar --mode res --entrycard-path <path> --pack-info-path <path> --out-path <path> [--force true]
Table 13 Parameters of the RES packing command
| Name | Mandatory | Option | Description |
|---|---|---|---|
| --mode | Yes | res | Command type. |
| --entrycard-path | Yes | NA | Path of the pack.res file. |
| --pack-info-path | Yes | NA | Path of the pack.info file. |
| --out-path | Yes | NA | Path of the target file. The file name extension must be .res. |
| --force | No | boolean | Whether to forcibly overwrite the target file if its path already exists. If the target file specified by --out-path already exists before packing and this parameter is set to true, the file is overwritten. If this parameter is set to false, the packing process is terminated and an error is reported. If the target file specified by --out-path does not exist before packing, the file is packed properly. This parameter is invalid. The default value is false. |
You can use the JAR package of the packing tool to generate an APP file for a fast application by passing in packing options and path of the HAP or HSP files. The APP file is used to release the application to the app market.
Table 14 Validity verification rules for fastApp file packing
| Fields in module.json of HAP or HSP That Are Verified | Verification Rules |
|---|---|
| name field in module | The name field values of all HAPs or HSPs must be unique. |
| bundleName | The bundleName field values of all HAPs or HSPs must be the same. |
| bundleType | The bundleType field values of all HAPs or HSPs must be the same. |
| versionCode | The versionCode field values of all HAPs or HSPs must be the same. |
| debug | Since API version 20, the debug field values of all HAPs must be the same. If the debug field value of HAP is false, the debug field value of HSP must also be false. If the debug field value of HAP is true, there is no requirement for the debug field of HSP. For API version 19 and earlier versions, the debug field values of all HAPs or HSPs must be the same. |
| minAPIVersion | Since API version 20, the minAPIVersion field values of all HAPs must be the same and must be greater than or equal to the maximum value of the minAPIVersion field of all HSPs. For API version 19 and earlier versions, the minAPIVersion field values of all HAPs or HSPs must be the same. |
| minCompatibleVersionCode | Since API version 16, the minCompatibleVersionCode field values of all HAPs must be the same and must be greater than or equal to the maximum value of the minCompatibleVersionCode field of all HSPs. For API version 15 and earlier versions, the minCompatibleVersionCode field values of all HAPs or HSPs must be the same. |
| targetAPIVersion | Since API version 16, the targetAPIVersion field values of all HAPs must be the same and must be greater than or equal to the maximum value of the targetAPIVersion field of all HSPs. For API version 15 and earlier versions, the targetAPIVersion field values of all HAPs or HSPs must be the same. |
| buildVersion | Since API version 23, the buildVersion field values of all HAPs or HSPs must be the same. |
Compression rules: During APP file packing, the HAP and HSP files in release mode are compressed, while those in debug mode are not.
If the .so files that have been compressed in the HAP or HSP are compressed again during APP packing, the size of these files will not be significantly reduced.
Packing command example:
java -jar app_packing_tool.jar --mode fastApp [--hap-path <path>] [--hsp-path <path>] --out-path <path> [--signature-path <path>] [--certificate-path <path>] --pack-info-path <path> [--pack-res-path <path>] [--force true] [--encrypt-path <path>] [--pac-json-path <path>] [--atomic-service-entry-size-limit <size>] [--atomic-service-non-entry-size-limit <size>]
Table 15 Parameters of the fastApp packing command
| Name | Mandatory | Option | Description |
|---|---|---|---|
| --mode | Yes | fastApp | Packing mode. Each HAP file to pack into the APP file must pass the validity check. |
| --hap-path | No | NA | Path of the HAP file directory, which contains all files of the HAP. If there are multiple HAP file paths, separate them with commas (,). |
| --hsp-path | No | NA | 1. Path of the HSP files. The file name extension must be .hsp. If there are multiple HSP files, separate them with commas (,). 2. Path of the HSP file directory, which contains all files of the HSP. If there are multiple HAP file paths, separate them with commas (,). |
| --pack-info-path | Yes | NA | Path of the pack.info file. The file name must be pack.info. |
| --out-path | Yes | NA | Path of the target file. The file name extension must be .app. |
| --signature-path | No | NA | Path of the signature file. |
| --certificate-path | No | NA | Path of the certificate file. |
| --pack-res-path | No | NA | Path of the pack.res file. |
| --force | No | boolean | Whether to forcibly overwrite the target file if its path already exists. If the target file specified by --out-path already exists before packing and this parameter is set to true, the file is overwritten. If this parameter is set to false, the packing process is terminated and an error is reported. If the target file specified by --out-path does not exist before packing, the file is packed properly. This parameter is invalid. The default value is false. |
| --encrypt-path | No | NA | The file name must be encrypt.json. |
| --pac-json-path | No | NA | pac.json file. The file name must be pac.json. This parameter is supported since API version 20. |
| --atomic-service-entry-size-limit | No | NA | Size limit of the entry package (including the size of the dependency package) of the atomic service. This parameter is valid only in the stage model and bundleType is set to atomicService. The value is an integer ranging from 0 to 4194304, in KB. The value 0 indicates that the size is not limited. If this parameter is not set, the default value 2048 KB is used. If the entry package is in release mode (the type field in the module.json5 file is set to entry and the debug field in the app.json5 file is set to false), this limit applies to the compressed entry package size (including the size of the dependency package) during APP packing. |
| --atomic-service-non-entry-size-limit | No | NA | Size limit of the non-entry package (including the size of the dependency package) of the atomic service. This parameter is valid only in the stage model and bundleType is set to atomicService. The value is an integer ranging from 0 to 4194304, in KB. The value 0 indicates that the size is not limited. If this parameter is not set, the default value 2048 KB is used. If the non-entry package is in release mode (the type field in the module.json5 file is not set to entry and the debug field in the app.json5 file is set to false), this limit applies to the compressed non-entry package size (including the size of the dependency package) during APP packing. |
| --stat-duplicate | No | boolean | Whether to scan for duplicate .so files after the packing is complete. This parameter can be used to identify duplicate .so files to reduce the package size. If this parameter is set to true, the scanning is performed. After the scanning is complete, the scan_report directory is generated in the directory where the output file specified by --out-path is located. The scan_report directory contains the duplicate .so file scanning report whose file name is scan_result, and the scan_report directory path is printed in the warning message. If this parameter is set to false, the scanning is not performed. The default value is false. This parameter is supported since API version 23. |
| --deduplicate-so | No | boolean | Used to deduplicate .so files during packaging to effectively reduce the size of the app package. Default value: false Value: <idp:inline displayname="code" id="code461612113257">true: Deduplicate .so files. After deduplication is complete, a deduplication report so_dedup_report.json is generated in the directory specified by <idp:inline displayname="code" id="code12173173814279">--out-path, and the deduplication result is printed in logs. <idp:inline displayname="code" id="code84471711162720">false: Do not deduplicate .so files. Deduplication policy: - If the same .so file exists in different modules of the app package and these .so files will be decompressed to the app root directory (that is, compressNativeLibs and extractNativeLibs in the module.json5 file are not both false, and libIsolation is false). - The packaging tool will perform deduplication based on configurations such as <idp:inline displayname="code" id="code195621548285">deviceTypes, <idp:inline displayname="code" id="code1656217547284">deliveryWithInstall, <idp:inline displayname="code" id="code11562554182816">distributionFilter, and <idp:inline displayname="code" id="code125623548282">requiredDeviceFeatures to ensure that the app functions remain unchanged on each device where the app can be installed after deduplication. NOTE - If the app code contains operations that directly read .so files from the original installation package, the app behavior will change after deduplication is enabled. In this case, do not enable this function, or modify the code logic to read the decompressed .so file before enabling this function. - If you enable .so file deduplication during packaging, you are advised to carefully check the deduplication result and fully verify the function integrity of the app package after deduplication before releasing it. This parameter is supported starting from API version 26.0.0. |
When you use the APP packing command, fastApp packing command, or multi-project packing command to generate an APP file, set --stat-duplicate to true to enable the scanning for duplicate .so files. The system will generate a scanning report after the packing is successful. After duplicate .so files are identified, you can reduce the package size as required. The scanning report is stored in the scan_report directory in the directory where the generated APP file is stored. Table 16 describes the structure of the scanning report, and Table 17 describes the structure of the duplicate .so file feature information. The following is an example of the scanning report:
JSON statistics result:
[{
"result":[{
"md5":"975c41f5727b416b1ffefa5bb0f073b2",
"size":1108880,
"files":[
"/application-entry-default.hap/libs/armeabi-v7a/example.so",
"/entry-default.hap/libs/armeabi-v7a/example.so"
]
}],
"startTime": "2025-11-13 16:02:48.381",
"stopTime": "2025-11-13 16:02:48.381",
"taskDesc": "find the duplicated so"
}] Table 16 Fields in the duplicate .so file scanning report
| Field | Type | Description |
|---|---|---|
| result | Struct | Feature information of duplicate .so files, including the MD5 value, file size, and file path. For details, see Table 17. |
| startTime | String | Start time of the task. |
| stopTime | String | End time of the task. |
| taskDesc | String | Task description, which is "find the duplicated so". |
Table 17 Feature fields of duplicate .so files
| Field | Type | Description |
|---|---|---|
| md5 | String | MD5 value of the duplicate .so file. |
| size | int | Size of the duplicate .so file, in bytes. |
| files | Vector<String> | Path of the duplicate .so file. |
When you use the app packing command, fast app packing command, or multi-project packing command to generate an app package, set --deduplicate-so to true to enable the .so file deduplication function. The system will deduplicate duplicate .so files during packaging and generate a deduplication report after the packaging is successful. The deduplication report is stored in the so_dedup_report.json file in the directory where the generated APP file is stored. The deduplication report records the timestamp of the deduplication operation, the total size of files saved, and the list of .so files retained and removed in each module.
The following is an example of the deduplication report:
{
"timestamp":"2026-07-04T09:24:50Z",
"totalSavedSize":4120,
"modules":{
"feature":{
"kept":[],
"removed":[
"libs/arm64-v8a/libshared.so"
]
},
"entry":{
"kept":[
"libs/arm64-v8a/libshared.so"
],
"removed":[]
}
}
} Table 18 Fields in the .so deduplication report
| Field | Type | Description |
|---|---|---|
| timestamp | String | Timestamp of the .so deduplication operation. The value is in ISO 8601 format, for example, 2026-07-04T09:24:50Z. |
| totalSavedSize | int | Total size of files saved by deduplication, that is, the sum of the size differences between all HAPs/HSPs before and after deduplication (before app compression). The unit is byte. |
| modules | Object | Deduplication details of each module. key is the module name, and value is the deduplication information object of the module. |
Table 19 Fields in the module deduplication information
| Field | Type | Description |
|---|---|---|
| kept | Vector<String> | List of paths of the .so files retained in the module (only for duplicate .so files). |
| removed | Vector<String> | List of paths of the .so files removed from the module. |
Error Message
Execute packing tool failed.
Description
Failed to run the packing tool.
Possible Causes
Solution
Error Message
Command parser failed.
Description
Failed to parse the packing parameters.
Possible Causes
Solution
Check the first error code in the error log to determine the error information.
Error Message
Command verify failed.
Description
--Failed to verify the --force parameter value.
Possible Causes
Solution
Check the parameter value and ensure that the value is true or false.
Error Message
Parse and check args invalid in hap mode.
Description
Failed to verify the parameters during HAP packing.
Possible Causes
The parameter value format is incorrect. For example, the path is empty, the file type does not match, or invalid characters are contained.
Solution
Check the first error code in the error log to determine the error information.
Error Message
Parse and check args invalid in hsp mode.
Description
Failed to verify the parameters during HSP packing.
Possible Causes
The parameter value format is incorrect (for example, the path is empty, the file type does not match, or invalid characters exist).
Solution
Check the first error code in the error log to determine the error information.
Error Message
Parse and check args invalid in app mode.
Description
Failed to verify the parameters during APP packing.
Possible Causes
The parameter value format is incorrect (for example, the path is empty, the file type does not match, or invalid characters exist).
Solution
Check the first error code in the error log to determine the error information.
Error Message
Parse and check args invalid in multiApp mode.
Description
Failed to verify the parameters during multi-project packing.
Possible Causes
The parameter value format is incorrect (for example, the path is empty, the file type does not match, or invalid characters exist).
Solution
Check the first error code in the error log to determine the error information.
Error Message
Parse and check args invalid in res mode.
Description
Failed to verify the parameters during RES packing.
Possible Causes
The parameter value format is incorrect (for example, the path is empty, the file type does not match, or invalid characters exist).
Solution
Check the first error code in the error log to determine the error information.
Error Message
Parse and check args invalid in hqf mode.
Description
Failed to verify the parameters during HQF packing.
Possible Causes
The parameter value format is incorrect (for example, the path is empty, the file type does not match, or invalid characters exist).
Solution
Check the first error code in the error log to determine the error information.
Error Message
Parse and check args invalid in appqf mode.
Description
Failed to verify the parameters during APPQF packing.
Possible Causes
The parameter value format is incorrect (for example, the path is empty, the file type does not match, or invalid characters exist).
Solution
Check the first error code in the error log to determine the error information.
Error Message
Parse and check args invalid in packageNormalize mode.
Description
Failed to verify the parameters during package name normalization.
Possible Causes
The parameter value format is incorrect (for example, the path is empty, the file type does not match, or invalid characters exist).
Solution
Check the first error code in the error log to determine the error information.
Error Message
Parse and check args invalid in versionNormalize mode.
Description
Failed to verify the parameters during version normalization.
Possible Causes
The parameter value format is incorrect (for example, the path is empty, the file type does not match, or invalid characters exist).
Solution
Check the first error code in the error log to determine the error information.
Error Message
Command verify mode is invalid.
Description
--Failed to verify the --mode parameter value.
Possible Causes
Solution
Error Message
Check hsp has entry ability failed.
Description
Failed to check whether the HSP contains the entry UIAbility.
Possible Causes
Failed to parse the module.json file specified by --json-path.
Solution
Error Message
Check hsp has entry extensionAbility failed.
Description
Failed to check whether the HSP contains the entry ExtensionAbility.
Possible Causes
Failed to parse the module.json file specified by --json-path.
Solution
Error Message
Invalid output path.
Description
Failed to check the --out-path parameter.
Possible Causes
Solution
Error Message
Handle hap and hsp input failed.
Description
Failed to verify the --input-list parameter during version normalization.
Possible Causes
--The file specified by the input-list parameter is neither an HAP nor an HSP.
Solution
Ensure that the files specified by the --input-list parameter are valid HAP or HSP files.
Error Message
Parse and check args invalid in generalNormalize mode.
Description
Failed to verify the parameters during general normalization.
Possible Causes
Solution
Check the first error code in the error log to determine the error information.
Error Message
Parse atomicService size limit failed.
Description
Failed to check the atomic service size limit parameter.
Possible Causes
Solution
Error Message
Execute compress process failed.
Description
During packing a HAP or APP file, the file fails to be compressed. As a result, the packing is interrupted.
Possible Causes
Solution
Error Message
Compress Stage Hap failed.
Description
The HAP file in the stage model fails to be compressed when the HAP is packed.
Possible Causes
Solution
Error Message
Verify stage hap info failed.
Description
The configuration information verification fails while packing the HAP file in the stage model.
Possible Causes
Solution
Error Message
Check asanEnabled failed.
Description
During HAP or HSP packing, asanEnabled in app.json5 is incorrectly configured.
Possible Causes
Both asanEnabled and tsanEnabled are set to true.
Solution
Check app.json5 and modify asanEnabled and tsanEnabled to ensure that they are not both set to true.
Error Message
Check hwasanEnabled failed.
Description
During HAP or HSP packing, hwasanEnabled in app.json5 is incorrectly configured.
Possible Causes
Solution
Check the app.json5 file and ensure that hwasanEnabled, and one of asanEnabled, tsanEnabled, and GWPAsanEnabled are not all set to true at the same time.
Error Message
Check atomicService failed.
Description
Failed to check the atomicService configuration during HAP or HSP packing.
Possible Causes
Solution
Error Message
Check continueBundleName invalid.
Description
Failed to check the continueBundleName configuration during HAP or HSP packing.
Possible Causes
The continueBundleName in module.json5 is the same as the bundleName in app.json5.
Solution
Modify continueBundleName to ensure that it is different from bundleName in app.json5.
Error Message
Check whether is an overlay hsp failed.
Description
Failed to check whether the HSP has the overlay feature.
Possible Causes
Both targetModuleName and requestPermissions are configured in module.json5.
targetModuleName is the same as name in module.json5.
targetModuleName is not configured when targetPriority is configured in module.json5.
targetModuleName is not configured in module.json5 when targetBundleName is configured in app.json5.
In app.json5, the value of targetBundleName is the same as that of bundleName.
Solution
Error Message
Process compress exception.
Description
An exception occurs when the HAP, HSP, or APP file is compressed.
Possible Causes
Solution
Error Message
Verify has generate build hash failed.
Description
Failed to verify the generateBuildHash property of the module.
Possible Causes
Failed to parse the module.json file specified by --json-path.
Solution
Check the module.json file specified by --json-path and ensure that the file format complies with the JSON specifications.
Error Message
Set generate build hash failed.
Description
Failed to set the generateBuildHash property.
Possible Causes
Solution
Error Message
Check ubsanEnabled failed.
Description
Failed to check the ubsanEnabled property of the application.
Possible Causes
Solution
Modify the app.json5 configuration to ensure that ubsanEnabled is not set to true together with asanEnabled, tsanEnabled, or hwasanEnabled.
Error Message
Read Stage hap verify info exist exception.
Description
Failed to parse the module.json file.
Possible Causes
Solution
java -Djdk.util.zip.disableZip64ExtraFieldValidation=true -jar app_packing_tool.jar --mode app --hap-path <path> --out-path <path> --pack-info-path <path>
Error Message
Parallel compress exception.
Description
Failed to pack the directory specified by --lib-path.
Possible Causes
Solution
Error Message
Compress app file failed.
Description
Failed to build the APP file.
Possible Causes
Solution
Error Message
Check input hap or hsp file is invalid.
Description
The specified HAP or HSP file is invalid.
Possible Causes
Solution
Error Message
Check bundleType is invalid.
Description
The bundle type of the application is invalid.
Possible Causes
The bundleTypes of the HAP and HSP to be packed are different.
Solution
Check the app.json5 configuration files of all HAPs and HSPs to be packed and ensure that the bundleType configurations are the same.
Error Message
Check app atomicservice compress size failed.
Description
Failed to check the atomic service package size.
Possible Causes
Solution
Error Message
Read FA hap verify info exist exception.
Description
Failed to parse the config.json file of the FA.
Possible Causes
An I/O exception occurs when the config.json file of the HAP or HSP file of the FA is parsed.
Solution
Locate the cause of the I/O or formatting exception based on the Error Message: information in the log.
Error Message
IO exception when compress app.
Description
An I/O exception occurs during APP packing.
Possible Causes
During APP packing, an I/O exception occurs when the pack.info file of the APP overwrites that of the HAP or HSP.
Solution
Locate the cause of the I/O or formatting exception based on the Error Message: information in the log.
Error Message
Verify stage hsp info failed.
Description
Failed to verify the HSP file in the stage model during HSP packing.
Possible Causes
Solution
Error Message
Json special process exist exception.
Description
Failed to format the JSON file.
Possible Causes
An exception is thrown during JSON file formatting.
Solution
Locate the cause of the I/O or formatting exception based on the Error Message: information in the log.
Error Message
Check atomicService size failed.
Description
The size of the atomic service package exceeds the upper limit.
Possible Causes
The size of the atomic service package and the dependent shared library or resource file exceeds the upper limit. For details, see the --atomic-service-entry-size-limit and --atomic-service-non-entry-size-limit parameters in Table 5 Parameters of the APP packing command.
Solution
Optimize and reduce the package size, for example, delete unnecessary resources, simplify code, or reduce dependencies.
Error Message
Compress in app mode for multi project failed.
Description
Failed to pack multiple projects.
Possible Causes
Solution
Error Message
Dispose app failed.
Description
Failed to process the APP file.
Possible Causes
During multi-project packing, the APP specified by --app-list does not contain the pack.info file.
Solution
Ensure that the APP specified by --app-list contains the pack.info file.
Error Message
pack.info does not find in hap or app.
Description
In multi-project packing mode, the APP, HAP, or HSP does not contain the pack.info file.
Possible Causes
In multi-project packing mode, the APP, HAP, or HSP does not contain the pack.info file.
Solution
During multi-project packing, ensure that all APPs, HAPs, and HSPs to be packed contain valid pack.info files.
Error Message
Get module name from line string failed.
Description
Failed to parse moduleName in RES packing mode.
Possible Causes
In RES packing mode, the pack.info file specified by --pack-info-path does not contain the moduleName tag or the moduleName tag is empty.
Solution
Ensure that the pack.info file specified by --pack-info-path contains the moduleName tag and the moduleName tag is not empty.
Error Message
Compress in appqf mode failed.
Description
The APPQF packing fails.
Possible Causes
The --hqf-list parameter fails to be verified in APPQF packing mode.
Solution
Check the first error code in the error log to determine the error information.
Error Message
Check hqf has same app fields failed.
Description
In APPQF packing mode, the packing tool fails to verify the consistency of multiple HQF files specified by the --hqf-list parameter.
Possible Causes
Solution
Error Message
Check hqf module is invalid.
Description
In APPQF packing mode, the moduleNames of multiple HQF files specified by --hqf-list fails to be verified.
Possible Causes
In APPQF packing mode, the moduleNames of two HQFs specified by --hqf-list are the same and the deviceTypes properties intersect.
Solution
Ensure that the **moduleName **s of all HQFs specified by --hqf-list are different and the deviceTypes properties do not intersect.
Error Message
Version normalize failed.
Description
Failed to packing in version normalization mode.
Possible Causes
Solution
Error Message
Verify module version failed.
Description
Failed to verify the module version in version normalization packing mode.
Possible Causes
In version normalization packing mode, the value of --version-code is less than that of versionCode of a HAP or HSP file specified by --input-list.
Solution
Ensure that the value of --version-code is greater than or equal to that of versionCode of the HAP or HSP file specified by --input-list.
Error Message
SHA-256 hash calculation failed.
Description
Failed to calculate the SHA-256 value when packing an HAP or HSP.
Possible Causes
An I/O exception occurs when the SHA-256 value of the HAP or HSP file is calculated.
Solution
Locate the exception cause based on the Error Message: information in the log.
Error Message
Select haps find duplicated hap.
Description
There are two HAPs or HSPs with the same file name.
Possible Causes
In multi-project packing mode, the two HAPs or HSPs specified by --app-list, --hap-list, and --hsp-list have duplicate names.
Solution
Ensure that the HAPs or HSPs specified by --app-list,--hap-list, and**--hsp-list** have different file names.
Error Message
Parse and modify config.json failed.
Description
Failed to parse the config.json file in version normalization mode or general normalization mode.
Possible Causes
Solution
Error Message
Parse and modify module.json failed.
Description
Failed to parse the module.json file in version normalization mode or general normalization mode.
Possible Causes
Solution
Error Message
Check is plugin host failed.
Description
Failed to check the plugin host during HSP packing.
Possible Causes
--The module.json file specified by json-path does not contain the module tag.
Solution
Check the module.json file specified by --json-path and ensure that the file contains the module tag.
Error Message
Check pkg context failed.
Description
Failed to check the --pkg-context-path parameter when packing an HAP or HSP.
Possible Causes
Solution
Error Message
Check app plugin failed.
Description
Failed to check the plugin properties during HSP packing.
Possible Causes
Solution
Error Message
Check deduplicateHar field failed.
Description
Failed to verify the deduplicateHar property during HSP/HAP packaging.
Possible Causes
The value of minAPIVersion in the module.json file of the HSP/HAP module is less than 21, and the value of deduplicateHar is true.
Solution
When the HSP/HAP file is packaged, if the value of deduplicateHar is true, the value of minAPIVersion must be greater than or equal to 21.
Error Message
Binary file decompression configuration verification failed.
Description
The binary file decompression configuration fails to be verified during HSP/HAP packaging.
Possible Causes
The HSP/HAP has the path information executableBinaryPaths of executable binary files in the module.json5, and the binary files exist. However, the HSP/HAP is configured to be installed without decompressing the libs library.
Solution
If executableBinaryPaths is configured in the module.json5 file and binary files exist, ensure that the app is installed in a way that the .libs library is decompressed. That is, at least one of extractNativeLibs and compressNativeLibs in the module.json5 file is set to true.
Error Message
Parse json object exception.
Description
An exception occurs when the module.json or config.json file is parsed.
Possible Causes
The JSON text syntax is incorrect. For example, parentheses are not closed, quotation marks are not properly used, or escape characters are invalid.
Solution
Check that the JSON text syntax is correct.
Error Message
Parse json profile failed.
Description
Failed to parse the JSON configuration.
Possible Causes
Solution
Error Message
Check module atomicService invalid.
Description
The atomicService property is invalid.
Possible Causes
The bundleType of the HAP or HSP is not atomicService, but the atomicService tag is configured in the module.json file.
Solution
The bundleType of the HAP or HSP is not atomicService. Change the atomicService tag configured in the module.json file.
Error Message
Failed to parse module.json for the Stage module.
Description
Failed to parse the module.json file.
Possible Causes
Solution
Error Message
Failed to parse module.json and bundleType.
Description
Failed to check the bundle type of a module.
Possible Causes
The configuration does not meet the requirements. For example:
Solution
Error Message
check entry module at least one ability failed.
Description
The entry module does not contain any ability.
Possible Causes
abilities in module. json5 is not configured or is empty.
Solution
Check module.json5 and ensure that abilities is correctly configured for the entry module.
Error Message
Check module atomicService installationFree invalid.
Description
During HAP or HSP packing, atomicService and installationFree are incorrectly configured.
Possible Causes
Solution
Error Message
Get the bundleName from json file failed.
Description
Failed to obtain the bundleName property.
Possible Causes
The app tag in the module.json file does not contain the bundleName property.
Solution
Check the module.json file and ensure that the app tag contains the bundleName property.
Error Message
Failed to parse module.json and proxyData object.
Description
Failed to parse the proxyData property.
Possible Causes
In the module.json file, an element in the proxyData tag under the module tag does not contain the uri tag.
Solution
Check the module.json file and ensure that each element in the proxyData tag under the module tag contains the uri tag.
Error Message
Failed to check the consistency of bundleType.
Description
Failed to check the bundleType consistency.
Possible Causes
Solution
Error Message
Failed to parse patch module name from patch.json.
Description
Failed to parse the module name in the patch.json file.
Possible Causes
The module tag in the patch.json file does not contain the name property.
Solution
Check the patch.json file and ensure that the module tag contains the name property.
Error Message
Failed to parse FA hap verify info from config.json.
Description
Failed to obtain the config.json file of the FA model module.
Possible Causes
When the FA model app is packed, some HAPs or HSPs do not contain the config.json file.
Solution
When packing the FA model app, ensure that all HAPs or HSPs contain the config.json file.
Error Message
Failed to parse config.json for the FA module.
Description
Failed to parse the config.json file of the FA model module.
Possible Causes
Solution
Error Message
Merge two pack.info into one pack.info file failed.
Description
Failed to merge the pack.info file.
Possible Causes
Solution
Error Message
Verify pack.info file failed.
Description
Failed to verify the pack.info file.
Possible Causes
Solution
Error Message
Verify app in pack.info failed.
Description
Failed to verify the pack.info file during merging.
Possible Causes
Solution
Error Message
Verify bundleType in pack.info file failed.
Description
Failed to verify the bundleType of the pack.info file.
Possible Causes
The bundleType values of the two pack.info files to be merged are different.
Solution
Check the two pack.info files to be merged and ensure that the bundleType values are the same.
Error Message
Parse forms name in pack.info file failed.
Description
Failed to parse the module name corresponding to the forms tag in the pack.info file.
Possible Causes
Solution
Error Message
Failed to merge pack.info objects.
Description
In multi-project packing mode, the pack.info files of the HAP or HSP files fails to be merged.
Possible Causes
Solution
Error Message
Failed to merge two pack.info files into one pack.info file by packagePair.
Description
In multi-project packing mode, the pack.info files of the APPs to be packed fails to be merged.
Possible Causes
Solution
Error Message
Failed to parse pack.info forms.
Description
Failed to parse the forms property in the pack.info file.
Possible Causes
Solution
Error Message
File available not found exception.
Description
The file to be packed is unavailable.
Possible Causes
Solution
Error Message
Close zip output stream exception.
Description
An exception occurs when the .zip archive output stream is closed.
Possible Causes
Solution
Check the error information based on Error Message: in the log. The solutions are as follows:
Error Message
IO exception when closing stream.
Description
An exception occurs when the I/O input stream is closed.
Possible Causes
The underlying file descriptor becomes invalid.
Solution
Error Message
Get file content failed.
Description
Failed to obtain the file content.
Possible Causes
An exception occurs during the file I/O operation.
Solution
Check the error information based on Error Message: in the log.
Error Message
Parse file not exist.
Description
The file does not exist.
Possible Causes
The file does not exist.
Solution
Check Error Message: in the log, and ensure that the file path is correct and the file exists.
Error Message
Get file size failed.
Description
Failed to obtain the file size.
Possible Causes
Solution
Check the file path based on Error Message: in the log. Ensure that the file exists and is of the file type.
Error Message
File IO exception.
Description
The file I/O is abnormal.
Possible Causes
Solution
Check the file path based on Error Message: in the log.
Error Message
Compress file exception.
Description
The compressed file is abnormal.
Possible Causes
An exception occurs when the file is compressed.
Solution
Check the error information based on Error Message: in the log.
Check the system logs and ensure that the file system and disk are normal.
Error Message
File delete failed.
Description
Failed to delete the file.
Possible Causes
The file is occupied by another process.
Solution
Check the file path based on Error Message: in the log.
Ensure that the file is not occupied by another process and manually delete the file.
Error Message
IO exception.
Description
The file I/O is abnormal.
Possible Causes
Solution
Check the file path based on Error Message: in the log.
Error Message
Null pointer exception.
Description
A null pointer exception occurs.
Possible Causes
The program object is not initialized.
Solution
Check the error information based on Error Message: in the log.
Error Message
App fields is invalid.
Description
Failed to verify the application fields during application packing.
Possible Causes
Solution
Check the error information and the name of the problematic HAP or HSP based on Error Message: in the log.
Error Message
Some app variable is different.
Description
The HAP or HSP properties are different during APP packing.
Possible Causes
Solution
Error Message
Check two distroFilter policy disjoint invalid.
Description
The logic for checking HAP uniqueness checks whether the distribution policies intersect. However, the distribution policies are incorrectly configured. As a result, the system cannot determine whether the distribution policies intersect.
Possible Causes
The policy and value tags of the distribution policy are empty or invalid.
Solution
Check the distribution policy configuration and ensure that the value of policy is include or exclude. For details about the value of value, see distributionFilter.
Error Message
Check module name is invalid.
Description
Failed to verify the module name during app packing.
Possible Causes
Solution
Error Message
Check packageName invalid.
Description
Failed to verify the application package name.
Possible Causes
Two or more module.json files in the packed HAPs or HSPs have identical module/package tag values, with intersecting module/deviceType and module/metadata/resource/distributionFilter property values.
Solution
Locate the faulty HAP or HSP based on Error Message: in the log.
Check the module.json file of each HAP or HSP to be packed. Ensure that the values of the module/package tag are unique, and that the values of the module/deviceType and module/metadata/resource/distributionFilter properties do not intersect.
Error Message
Verify hap info is invalid.
Description
Failed to verify the HAP or HSP file used for building the APP file.
Possible Causes
The configurations of multiple HAP or HSP files conflict with each other.
Solution
Check the configuration items in the app.json5 and module.json5 file based on the error information. If multiple error messages are displayed, check the first error message first.
Error Message
Check entry module invalid.
Description
When a project contains multiple HAP files of the entry type during APP file building, the configuration information fails to be checked.
Possible Causes
The uniqueness check for the HAP file failed.
Solution
Adjust the HAP configuration of the entry type in the project by referring to Understanding the Logic for Checking HAP Uniqueness.
Error Message
Check dependency is invalid.
Description
The dependency property is invalid.
Possible Causes
The values of the module/installationFree properties in the module.json files of the HAPs or HSPs to be packed are inconsistent.
Solution
Check the module.json files of the HAPs or HSPs to be packed and ensure that the values of the module/installationFree properties are the same.
Error Message
Check dependency list is invalid.
Description
During the APP file building, the module dependency check fails.
Possible Causes
Solution
Error Message
Check atomicservice is invalid.
Description
The atomic service is invalid during APP file building.
Possible Causes
The moduleName configured in preloads of module.json5 is incorrect.
Solution
Check the moduleName under preloads in module.json5. The moduleName cannot be set to the name in the module.json5 file of the module, and the module corresponding to the moduleName must exist.
Error Message
Atomicservice preloads is invalid.
Description
During the building of an APP file whose bundleType is atomicService, the preloaded modules of the atomic service are invalid.
Possible Causes
Solution
Check the preloads attribute of the atomic service in module.json5 to ensure that no duplicate modules are configured, all modules are configured, and the module name of the atomic service package is not configured.
Error Message
TargetModuleName is not exist.
Description
During the APP file building, the target module is configured in the module, but the module is not found.
Possible Causes
targetModuleName is configured in module.json5, but the value is different from name in module.json5 of other modules.
Solution
Check the targetModuleName configuration item and ensure that it is correctly configured. For details, see Tags in the module.json5 Configuration File and the targetModuleName attribute. If necessary, create a target module.
Error Message
CompileSdkType is different.
Description
The compileSdkType properties are inconsistent.
Possible Causes
The app/compileSdkType properties in the module.json files of the HAPs or HSPs to be packed are inconsistent.
Solution
Check the module.json files of the HAPs or HSPs to be packed and ensure that the values of the app/compileSdkType properties are the same.
Error Message
Proxy data uri is not unique.
Description
The URI of the data proxy is not unique.
Possible Causes
Duplicate URIs are configured for proxyData in module.json5.
Solution
Check module.json5 and delete duplicate URIs from proxyData to ensure that each URI is unique. For details, see proxyData.
Error Message
Check continueType is invalid.
Description
The continueType configuration is incorrect during APP building.
Possible Causes
Solution
Check module.json5 and delete the duplicate configuration items of continueType or deviceType.
Error Message
Check file size failed.
Description
During the building of an atomic service app, the size of a single package exceeds the upper limit.
Possible Causes
The size of a single package exceeds the upper limit. For details, see the --atomic-service-entry-size-limit and --atomic-service-non-entry-size-limit parameters in Table 5 Parameters of the APP packing command.
Solution
Optimize and reduce the size of a single package file, for example, delete unnecessary resources, simplify code, or compress files.
Error Message
The provided list of HapVerifyInfos is empty.
Description
The HapVerifyInfos is empty.
Possible Causes
During APP packing, the values of the --hap-path and --hsp-path parameters are both empty.
Solution
During APP packing, ensure that the values of the --hap-path and --hsp-path parameters are not both empty.
Error Message
Check the atomicService module size failed.
Description
During the building of an atomic service app, the size of a single package and its dependent shared library exceeds the upper limit.
Possible Causes
The total size of the single package and its dependent shared library exceeds the upper limit. For details, see the --atomic-service-entry-size-limit and --atomic-service-non-entry-size-limit parameters in Table 5 Parameters of the APP packing command.
Solution
Optimize and reduce the package size, for example, delete unnecessary resources, simplify code, or reduce dependencies.
Error Message
Check the entry module distributionFilter is invalid.
Description
The distribution policy of the entry module is incorrect.
Possible Causes
The distribution policy of the entry module is incorrect.
Solution
Check whether the distribution policy of the entry module is correctly configured. For example, the value of policy should be exclude or include. For details, see distributionFilter.
Error Message
Normalize HSP bundleName and versionCode failed.
Description
The bundleName and versionCode properties of the HSP file fail to be verified in package name normalization mode.
Possible Causes
Solution
Error Message
Update module.json failed.
Description
Failed to update the module.json file.
Possible Causes
The module.json file does not contain the app tag.
Solution
Ensure that the module.json file contains the app tag.
Error Message
Update pack.info failed.
Description
Failed to update the pack.info file.
Possible Causes
Solution
Error Message
Parse and check args invalid in fast app mode.
Description
Failed to verify the package in fastApp packing mode.
Possible Causes
Failed to verify the packing parameters.
Solution
Check the first error code in the error log to determine the error information.
Error Message
Check bundleType consistency failed.
Description
Failed to check the bundleType consistency in fastApp packing mode.
Possible Causes
Solution
Error Message
Pack.info is invalid.
Description
The pack.info file is invalid in fastApp packing mode.
Possible Causes
Solution
Determine the path of the faulty file based on Error Message: in the log.
Error Message
Add archive entry failed.
Description
Failed to add a file or directory to the compressed package.
Possible Causes
The directory to be packed is empty.
Solution
This is only an alarm and does not need to be handled.
Check the empty file directory to be packed based on Error Message: and ensure that the file directory meets the requirements.
Error Message
Packing with multiple threads exception.
Description
Failed to pack the libs directory.
Possible Causes
Failed to pack the libs directory.
Solution
Check the error information based on Error Message: in the log.
Error Message
Repack hsp exception.
Description
An exception occurs when the HSP is repacked in fastApp mode.
Possible Causes
An exception occurs when the HSP is repacked.
Solution
Check the error information based on Error Message: in the log.
Error Message
Incremental pack hap exception.
Description
An exception occurs when the HAP file is incrementally packed.
Possible Causes
An I/O exception occurs when the HAP file is incrementally packed.
Solution
Check the error information based on Error Message: in the log.
Error Message
Incremental pack hsp exception.
Description
An exception occurs when the HSP file is incrementally packed.
Possible Causes
An I/O exception occurs when the HSP file is incrementally packed.
Solution
Check the error information based on Error Message: in the log.
Error Message
so deduplication failed.
Description
.so file deduplication fails.
Possible Causes
Solution