• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Packing Tool
2## Overview
3
4The packing tool packs compiled files for installation and release. The packing tool supports the generation of HAP (an application package), APP (application set to launch to the application market), HQF (quick fix package), APPQF (quick fix package to launch to the application market), HAR (statically shared library), and HSP (dynamically shared library) files. The unpacking tool is used to unpack the HAP, APP, HQF, APPQF, HAR, and HSP files and parse the HAP, HSP, APP, and APPQF files. Generally, the packing process is automatically carried out in DevEco Studio. However, you can also use the JAR package of the packing tool to pack files. The JAR package is stored in the **toolchains** directory in the SDK path.
5
6## Packing Commands
7
8### Packing Commands for HAP Files
9
10You can use the JAR package of the packing tool to generate an HAP file by importing packing options and file paths.
11
12#### Example
13
14- A packing command example in the stage model:
15
16
17  ```
18  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
19  ```
20
21- A packing command example in the FA model:
22
23
24  ```
25  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]
26  ```
27
28#### Parameters
29
30| Name              | Mandatory| Option                  | Description                                                       | Remarks        |
31|------------------|-------|----------------------|-----------------------------------------------------------|------------|
32| --mode           | Yes    | hap                  | Packing mode.                                                    | NA         |
33| --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         |
34| --profile-path   | No    | NA                   | Path of the **CAPABILITY.profile** file.                                  | NA         |
35| --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         |
36| --maple-so-dir   | No    | NA                   | Path of the maple SO directory.                                          | NA         |
37| --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         |
38| --lib-path       | No    | NA                   | Path of the library file.                                                | NA         |
39| --resources-path | No    | NA                   | Path of the resource file.                                          | NA         |
40| --index-path     | No    | NA                   | Path of the INDEX file. The file name must be **resources.index**.                        | NA         |
41| --pack-info-path | No    | NA                   | Path of the **pack.info** file. The file name must be **pack.info**.                           | NA         |
42| --rpcid-path     | No    | NA                   | Path of the **rpcid.sc** file. The file name must be **rpcid.sc**.                             | NA         |
43| --js-path        | No    | NA                   | Path of the JS file.                                              | This parameter is valid only in the stage model.|
44| --ets-path       | No    | NA                   | Path of the ETS file.                                             | This parameter is valid only in the stage model.|
45| --out-path       | Yes    | NA                   | Path of the target file. The file name extension must be .hap.                                    | NA         |
46| --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         |
47| --an-path        | No    | NA                   | Path of the AN file.                                               | This parameter is valid only in the stage model.|
48| --ap-path        | No    | NA                   | Path of the AP file.                                               | This parameter is valid only in the stage model.|
49| --dir-list       | No    | NA                   | List of directories (folders) to be packed into the HAP file.                             | NA         |
50
51### Packing Commands for HAR Files
52
53You can use the JAR package of the packing tool to generate an HAR file by importing packing options and file paths.
54
55#### Example
56
57```
58java -jar app_packing_tool.jar --mode har --json-path [option] --jar-path [option]--lib-path [option] --resources-path [option] --out-path [option] --force [option]
59```
60
61#### Parameters
62
63| Name             | Mandatory| Option         | Description                                                       |
64|-----------------|-------|-------------|-----------------------------------------------------------|
65| --mode          | Yes    | har         | Packing mode.                                                    |
66| --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.|
67| --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.|
68| --lib-path      | No    | NA          | Path of the library file.                                                |
69| --resource-path | Yes    | NA          | Path of the resource file.                                          |
70| --out-path      | Yes    | NA          | Path of the target file. The file name extension must be .har.                                    |
71| --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.                       |
72
73### Packing Commands for APP Files
74
75You can use the JAR package of the packing tool to generate an APP file by importing packing options and file paths. The APP file is used to release the application to the application market.
76
77
78#### Example
79
80```
81java -jar app_packing_tool.jar --mode app --hap-path <option> --hsp-path <option> --out-path <option> --signature-path [option] --certificate-path [option] --pack-info [option]--force [option]
82```
83
84#### Parameters
85
86| Name                | Mandatory| Option         | Description                                                          |
87|--------------------|-------|-------------|--------------------------------------------------------------|
88| --mode             | Yes    | app         | Packing mode. Each HAP file to pack into the APP file must pass the validity check.                                          |
89| --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.|
90| --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.|
91| --pack-info-path   | Yes    | NA          | Path of the **pack.info** file. The file name must be **pack.info**.                                            |
92| --out-path         | Yes    | NA          | Path of the target file. The file name extension must be .app.                                       |
93| --signature-path   | No    | NA          | Path of the signature file.                                                       |
94| --certificate-path | No    | NA          | Path of the certificate file.                                                       |
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#### HAP Validity Check During APP Packing
98
99When 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.
100
101### Multi-project Packing
102
103If 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.
104
105#### Example
106
107```
108java -jar app_packing_tool.jar --mode multiApp --hap-list [option] --hsp-list [option] --app-list [option] --out-path <option>
109```
110
111#### Parameters
112
113| Name        | Mandatory| Option       | Description                                                                                                 |
114|------------|-------|-----------|-----------------------------------------------------------------------------------------------------|
115| --mode     | Yes    | multiApp  | Packing mode. Each HAP file to pack into the APP file must pass the validity check.                                                           |
116| --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 file is stored.                                         |
117| --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 file is stored.                                         |
118| --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 file is stored.<br>You must specify **--hap-list**, **--hsp-list**, or **--app-list**, or any of their combinations.|
119| --out-path | Yes    | NA | Path of the target file. The file name extension must be .hqf.|
120| --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.                                                                 |
121
122#### HAP Validity Check During Multi-project Packing
123
124Ensure 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.
125
126### Packing Commands for HQF Files
127
128If 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 by importing packing options and file paths.
129
130#### Example
131
132```
133java -jar app_packing_tool.jar --mode hqf --json-path <option> --lib-path <option> --ets-path <option> --out-path <option>
134```
135
136#### Parameters
137
138| Name         | Mandatory| Option         | Description                                |
139|-------------|-------|-------------|------------------------------------|
140| --mode      | Yes    | hqf         | Packing mode.                             |
141| --json-path | Yes    | NA          | Path of the JSON file. The file name must be **patch.json**.       |
142| --lib-path  | No    | NA          | Path of the library file.                        |
143| --ets-path  | Yes    | NA          | Path of the ETS file.                      |
144| --out-path  | Yes    | NA          | Path of the target file. The file name extension must be .hqf.             |
145| --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.|
146
147### Packing Commands for APPQF Files
148
149An 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 by importing packing options and file paths.
150
151#### Example
152
153```
154java -jar app_packing_tool.jar --mode appqf --hqf-list <option> --out-path <option>
155```
156
157#### Parameters
158
159| Name        | Mandatory| Option         | Description                                |
160|------------|-------|-------------|------------------------------------|
161| --mode     | Yes    | appqf       | Packing mode.                             |
162| --hqf-list | Yes    | NA          | Path of the HQF files. If there are multiple HQF files, separate them with commas (,).             |
163| --out-path | Yes    | NA          | Path of the target file. The file name extension must be .appqf.           |
164| --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.|
165
166
167### Packing Commands for HSP Files
168
169HSP files enable multiple HAPs to share files. You can use the JAR package of the packing tool to generate an HSP file by importing packing options and file paths.
170
171#### Example
172```
173java -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
174```
175
176#### Parameters
177
178| Name              | Mandatory| Option         | Description                                                       |
179|------------------|-------|-------------|-----------------------------------------------------------|
180| --mode           | Yes    | hsp         | Packing mode.                                                    |
181| --json-path      | Yes    | NA          | Path of the JSON file. The file name must be **module.json**.                             |
182| --profile-path   | No    | NA          | Path of the **CAPABILITY.profile** file.                                  |
183| --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.|
184| --lib-path       | No    | NA          | Path of the library file.                                                |
185| --resources-path | No    | NA          | Path of the resource file.                                          |
186| --index-path     | No    | NA          | Path of the INDEX file. The file name must be **resources.index**.                        |
187| --pack-info-path | No    | NA          | Path of the **pack.info** file. The file name must be **pack.info**.                           |
188| --js-path        | No    | NA          | Path of the JS file.                                              |
189| --ets-path       | No    | NA          | Path of the ETS file.                                             |
190| --out-path       | Yes    | NA          | Path of the target file. The file name extension must be .hsp.                                    |
191| --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.                       |
192