1# Packing Tool 2 3The 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. 4 5The packing tool supports the generation of HAP (module package of the ability type), HAR (statically shared package), HSP (dynamically shared package), APP (application program package), HQF (quick fix module package), and APPQF (quick fix package) files. 6 7 8## HAP Packing Command 9 10You 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. 11 12- Packing command example in the stage model: 13 14 15 ``` 16 java -jar app_packing_tool.jar --mode hap --json-path <option> --resources-path <option> --ets-path <option> --index-path <option> --pack-info-path <option> --out-path <option> --force true 17 ``` 18 19- Packing command example in the FA model: 20 21 22 ``` 23 java -jar app_packing_tool.jar --mode hap --json-path <option> --maple-so-path [option] --profile-path [option] --maple-so-dir [option] --dex-path [option] --lib-path [option] --resources-path [option] --index-path [option] --out-path <option> --force [option] 24 ``` 25 26**Table 1** Parameters of the HAP packing command 27 28| Name | Mandatory| Option | Description | Remarks | 29| ---------------- | ---------- | ------------- | ------------------------------------------------------------ | --------------- | 30| --mode | Yes | hap | Packing mode. | NA | 31| --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 | 32| --profile-path | No | NA | Path of the **CAPABILITY.profile** file. | NA | 33| --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 | 34| --maple-so-dir | No | NA | Path of the maple SO directory (folder). | NA | 35| --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 (,).<br>The value can also be the directory (folder) where the DEX file is stored.| NA | 36| --lib-path | No | NA | Path of the library file. | NA | 37| --resources-path | No | NA | Path of the resource file. | NA | 38| --index-path | No | NA | Path of the INDEX file. The file name must be **resources.index**. | NA | 39| --pack-info-path | No | NA | Path of the **pack.info** file. The file name must be **pack.info**. | NA | 40| --rpcid-path | No | NA | Path of the **rpcid.sc** file. The file name must be **rpcid.sc**. | NA | 41| --js-path | No | NA | Path of the JS file. | This parameter is valid only in the stage model.| 42| --ets-path | No | NA | Path of the ETS file. | This parameter is valid only in the stage model.| 43| --out-path | Yes | NA | Path of the target file. The file name extension must be .hap. | NA | 44| --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 | 45| --an-path | No | NA | Path of the AN file. | This parameter is valid only in the stage model.| 46| --ap-path | No | NA | Path of the AP file. | This parameter is valid only in the stage model.| 47| --dir-list | No | NA | List of directories (folders) to be packed into the HAP file. | NA | 48 49## HAR Packing Command 50 51You can use the JAR package of the packing tool to generate an HAR file for an application by passing in packing options and file paths. 52 53Packing command example: 54 55``` 56java -jar app_packing_tool.jar --mode har --json-path [option] --jar-path [option] --lib-path [option] --resources-path [option] --out-path [option] --force [option] 57``` 58 59**Table 2** Parameters of the HAR packing command 60 61| Name | Mandatory| Option | Description | 62|-----------------|-------|-------------|-----------------------------------------------------------| 63| --mode | Yes | har | Packing mode. | 64| --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.| 65| --jar-path | No | NA | Path of the JAR file. The file name extension must be .jar. If there are multiple JAR files, separate them with commas (,).<br>The value can also be the directory (folder) where the JAR file is stored.| 66| --lib-path | No | NA | Path of the library file. | 67| --resource-path | Yes | NA | Path of the resource file. | 68| --out-path | Yes | NA | Path of the target file. The file name extension must be .har. | 69| --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. | 70 71## HSP Packing Command 72 73HSP 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. 74 75Packing command example: 76``` 77java -jar path\app_packing_tool.jar --mode hsp --json-path <option> --resources-path <option> --ets-path <option> --index-path <option> --pack-info-path <option> --out-path path\out\library.hsp --force true 78``` 79 80**Table 3** Parameters of the HSP packing command 81 82| Name | Mandatory| Option | Description | 83| ---------------- | ---------- | ------------- | ------------------------------------------------------------ | 84| --mode | Yes | hsp | Packing mode. | 85| --json-path | Yes | NA | Path of the JSON file. The file name must be **module.json**. | 86| --profile-path | No | NA | Path of the **CAPABILITY.profile** file. | 87| --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 (,).<br>The value can also be the directory (folder) where the DEX file is stored.| 88| --lib-path | No | NA | Path of the library file. | 89| --resources-path | No | NA | Path of the resource file. | 90| --index-path | No | NA | Path of the INDEX file. The file name must be **resources.index**. | 91| --pack-info-path | No | NA | Path of the **pack.info** file. The file name must be **pack.info**. | 92| --js-path | No | NA | Path of the JS file. | 93| --ets-path | No | NA | Path of the ETS file. | 94| --out-path | Yes | NA | Path of the target file. The file name extension must be .hsp. | 95| --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. | 96 97## APP Packing Command 98 99You 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. 100 101**HAP validity check**: When packing the HAP files in a project to generate an APP file, ensure that the values of **bundleName**, **versionCode**, **versionName**, **minCompatibleVersionCode**, **debug**, **minAPIVersion**, **targetAPIVersion**, and **apiReleaseType** 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. 102 103 104Packing command example: 105 106``` 107java -jar app_packing_tool.jar --mode app --hap-path <option> --hsp-path <option> --out-path <option> --signature-path [option] --certificate-path [option] --pack-info-path [option] --force [option] 108``` 109 110**Table 4** Parameters of the APP packing command 111 112| Name | Mandatory| Option | Description | 113|--------------------|-------|-------------|--------------------------------------------------------------| 114| --mode | Yes | app | Packing mode. Each HAP file to pack into the APP file must pass the validity check. | 115| --hap-path | Yes | NA | Path of the HAP file. The file name extension must be .hap. If there are multiple HAP files, separate them with commas (,).<br>The value can also be the directory (folder) where the HAP file is stored.| 116| --hsp-path | No | NA | Path of the HSP file. The file name extension must be .hsp. If there are multiple HSP files, separate them with commas (,).<br>The value can also be the directory (folder) where the HSP file is stored.| 117| --pack-info-path | Yes | NA | Path of the **pack.info** file. The file name must be **pack.info**. | 118| --out-path | Yes | NA | Path of the target file. The file name extension must be .app. | 119| --signature-path | No | NA | Path of the signature file. | 120| --certificate-path | No | NA | Path of the certificate file. | 121| --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. | 122 123 124 125## Multi-project Packing Command 126 127If 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. 128 129**HAP validity check**: Ensure that the values of **bundleName**, **versionCode**, **versionName**, **minCompatibleVersionCode**, **debug**, **minAPIVersion**, **targetAPIVersion**, **apiReleaseType**, **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. 130 131Packing command example: 132 133``` 134java -jar app_packing_tool.jar --mode multiApp --hap-list [option] --hsp-list [option] --app-list [option] --out-path <option> 135``` 136 137**Table 5** Parameters of the multi-project packing command 138 139| Name | Mandatory| Option | Description | 140|------------|-------|-----------|-----------------------------------------------------------------------------------------------------| 141| --mode | Yes | multiApp | Packing mode. Each HAP file to pack into the APP file must pass the validity check. | 142| --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 (,).<br>The value can also be the directory (folder) where the HAP files are stored. | 143| --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 (,).<br>The value can also be the directory (folder) where the HSP files are stored. | 144| --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 (,).<br>The value can also be the directory (folder) where the APP files are stored.<br>You must specify **--hap-list**, **--hsp-list**, or **--app-list**, or any of their combinations.| 145| --out-path | Yes | NA | Path of the target file. The file name extension must be .hqf.| 146| --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. | 147 148 149 150## HQF Packing Command 151 152If you find detects in the application and want to rectify the defects quickly, you can use HQF files. 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. 153 154Packing command example: 155 156``` 157java -jar app_packing_tool.jar --mode hqf --json-path <option> --lib-path <option> --ets-path <option> --out-path <option> 158``` 159 160**Table 6** Parameters of the HQF packing command 161 162| Name | Mandatory| Option | Description | 163|-------------|-------|-------------|------------------------------------| 164| --mode | Yes | hqf | Packing mode. | 165| --json-path | Yes | NA | Path of the JSON file. The file name must be **patch.json**. | 166| --lib-path | No | NA | Path of the library file. | 167| --ets-path | No | NA | Path of the ETS file. | 168| --out-path | Yes | NA | Path of the target file. The file name extension must be .hqf. | 169| --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.| 170 171## APPQF Packing Command 172 173An APPQF file consists of one or more HQF files. These HQF files are split from an APPQF file in the application 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. 174 175Packing command example: 176 177``` 178java -jar app_packing_tool.jar --mode appqf --hqf-list <option> --out-path <option> 179``` 180 181**Table 7** Parameters of the APPQF packing command 182 183| Name | Mandatory| Option | Description | 184|------------|-------|-------------|------------------------------------| 185| --mode | Yes | appqf | Packing mode. | 186| --hqf-list | Yes | NA | Path of the HQF file. If there are multiple HQF files, separate them with commas (,). | 187| --out-path | Yes | NA | Path of the target file. The file name extension must be .appqf. | 188| --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.| 189 190## versionNormalize Command 191 192For 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. 193 194Packing command example: 195``` 196java -jar path\app_packing_tool.jar --mode versionNormalize --input-list 1.hap,2.hsp --version-code 1000001 --version-name 1.0.1 --out-path path\out\ 197``` 198 199**Table 8** Parameters of the versionNormalize command 200 201| Name | Mandatory| Option | Description | 202|----------------|-------|------------------|-------------------------------------------------------------------| 203| --mode | Yes | versionNormalize | Command type. | 204| --input-list | Yes | Path of the HAP or HSP files | 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 (,).<br>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.| 205| --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. | 206| --version-name | Yes | Version name | New version name of the HAP and HSP files. | 207| --out-path | Yes | NA | Target file path, which must be a directory (folder). | 208