# Packing Tool The packing tool packs compiled files for installation and release. You can use DevEco Studio or the JAR package of the packaging 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. ## Constraints The packing tool must run in Java 8 or later. ## HAP Packing Command You can use the JAR package of the packing tool to generate an HAP file for a module by passing in packing options and file paths. - Packing command example in the stage model: ``` java -jar app_packing_tool.jar --mode hap --json-path [--resources-path ] [--ets-path ] [--index-path ] [--pack-info-path ] [--lib-path ] --out-path [--force true] [--compress-level 5] [--pkg-context-path ] [--hnp-path ] ``` - Packing command example in the FA model: ``` java -jar app_packing_tool.jar --mode hap --json-path [--maple-so-path ] [--profile-path ] [--maple-so-dir ] [--dex-path ] [--lib-path ] [--resources-path ] [--index-path ] --out-path [--force true] [--compress-level 5] ``` **Table 1** 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. | 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 | true or false| The default value is **false**. If the value is **true**, an existing target file will be forcibly deleted during packing. | NA | | --an-path | No | NA | Path of the AN file. | This parameter is valid only in the stage model.| | --ap-path | No | NA | Path of 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, ranging from 1 to 9. The default value is **1**. 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 valid only in the stage model. | | --hnp-path | No| NA | Path of the native software package to be packed into the HAP file.| NA | ## HSP Packing Command HSP files enable file sharing among multiple HAPs. You can use the JAR package of the packing tool to generate an HSP file for an application by passing in packing options and file paths. Packing command example: ``` java -jar app_packing_tool.jar --mode hsp --json-path [--resources-path ] [--ets-path ] [--index-path ] [--pack-info-path ] [--lib-path ] --out-path [--force true] [--compress-level 5] [--pkg-context-path ] ``` **Table 2** Parameters of the HSP packing command | Name | Mandatory| Option | Description | | ---------------- | ---------- | ------------- | ------------------------------------------------------------ | | --mode | Yes | hsp | Packing mode. | | --json-path | Yes | NA | Path of the JSON file. The file name must be **module.json**. | | --profile-path | No | NA | Path of the **CAPABILITY.profile** file. | | --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.| | --lib-path | No | NA | Path of the library file. | | --resources-path | No | NA | Path of the resources file. | | --index-path | No | NA | Path of the INDEX file. The file name must be **resources.index**. | | --pack-info-path | No | NA | Path of the **pack.info** file. The file name must be **pack.info**. | | --js-path | No | NA | Path of the JS file. | | --ets-path | No | NA | Path of the ETS file. | | --out-path | Yes | NA | Path of the target file. The file name extension must be .hsp. | | --force | No | true or false| The default value is **false**. If the value is **true**, an existing target file will be forcibly deleted during packing. | | --compress-level | No | number | Compression level, ranging from 1 to 9. The default value is **1**. This parameter is valid only when **compressNativeLibs** is set to **true**. A larger value indicates a higher compression rate and a slower compression speed.| | --pkg-context-path | No | NA | Path of the **pkgContextInfo.json** file, which contains the context information.| ## APP Packing Command 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. **HAP validity check**: When packing the HAP files in a project to generate an APP file, ensure that the values of **bundleName**, **versionCode**, **minCompatibleVersionCode**, **debug**, **minAPIVersion**, and **targetAPIVersion** configured in each JSON file of the HAP are the same, and the value of **moduleName** is unique in all the JSON files. For the FA model, you must also ensure that the value of **package** is unique in all the JSON files. The HAP modules must have the same **apiReleaseType**. The **apiReleaseType** of HSP modules is not checked. **Compression rules**: When packaging the APP files, the HAP and HSP files in release mode are compressed, but the HAP and HSP files in debug mode are not compressed. >**NOTE** > >Since API version 12, **versionName** is not verified during application packing. Packing command example: ``` java -jar app_packing_tool.jar --mode app [--hap-path ] [--hsp-path ] --out-path [--signature-path ] [--certificate-path ] --pack-info-path [--force true] [--encrypt-path ] ``` **Table 3** 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 | true or false| The default value is **false**. If the value is **true**, an existing target file will be forcibly deleted during packing. | | --encrypt-path | No | NA | The file name must be **encrypt.json**. | ## Multi-project Packing Command 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 application market. **HAP validity check**: Ensure that the values of **bundleName**, **versionCode**, **minCompatibleVersionCode**, **debug**, **minAPIVersion**, **targetAPIVersion**, **compileSdkVersion**, and **compileSdkType** configured in each JSON file of the HAP are the same, the value of **moduleName** is unique in all the JSON files, and the value of **entry** is unique for the same device. For the FA model, you must also ensure that the value of **package** is unique in all the JSON files. The HAP modules must have the same **apiReleaseType**. The **apiReleaseType** of HSP modules is not checked. >**NOTE** > >Since API version 12, **versionName** is not verified during multi-project packing. Packing command example: ``` java -jar app_packing_tool.jar --mode multiApp [--hap-list ] [--hsp-list ] [--app-list ] --out-path