app.json5 Configuration File

Configuration File Example

This topic gives an overview of the app.json5 configuration file. To start with, let's go through an example of what this file contains.

{
  "app": {
    "bundleName": "com.application.myapplication",
    "vendor": "example",
    "versionCode": 1000000,
    "versionName": "1.0.0",
    "icon": "$media:app_icon",
    "label": "$string:app_name",
    "description": "$string:description_application",
    "minAPIVersion": 9,
    "targetAPIVersion": 9,
    "apiReleaseType": "Release",
    "debug": false,
    "car": {
      "minAPIVersion": 8,
    },
    "targetBundleName": "com.application.test",
    "targetPriority": 50
  },
}

Tags in the Configuration File

As shown above, the app.json5 file contains several tags.

Table 1 Tags in the app.json5 file

Name Description Data Type Initial Value Allowed
bundleName Bundle name, which uniquely identifies an application. The value must comply with the following rules:
- Starts with a letter and consists of letters, digits, underscores (_), and periods (.).
- Contains 7 to 128 bytes.
You are advised to use the reverse domain name notation, for example, com.example.demo, where the first part is the domain suffix com, the second part is the vendor/individual name, and the third part is the application name, which can be of multiple levels.
If an application is built with the system source code, you are advised to name it in com.ohos.demo notation, where ohos signifies that the application is a system application.
String No
bundleType Bundle type, which is used to distinguish applications and atomic services. The options are as follows:
- app: The bundle is a common application.
- atomicService: The bundle is an atomic service.
- shared: The bundle is a shared library application. This option is reserved.
String Yes (initial value: app)
debug Whether the application can be debugged.
- true: The application can be debugged.
- false: The application cannot be debugged.
Boolean Yes (initial value: false; It is generated during compilation and building in DevEco Studio.)
icon Icon of the application. The value is the index to an icon resource file. String No
label Name of the application. The value is the index to a string resource. String No
description Description of the application. The value is a resource index to the description. It is a string with a maximum of 255 bytes. String Yes (initial value: left empty)
vendor Vendor of the application. The value is a string with a maximum of 255 bytes. String Yes (initial value: left empty)
versionCode Version code of the application. The value is a positive integer less than 2 to the power of 31. It is used only to determine whether a version is later than another version. A larger value indicates a later version.
Ensure that a new version of the application uses a value greater than any of its predecessors.
Number No
versionName Version number of the application displayed to users.
The value contains a maximum of 127 bytes and consists of only digits and dots. The four-part format A.B.C.D is recommended, wherein:
Part 1 (A): major version number, which ranges from 0 to 99. A major version consists of major new features or large changes.
Part 2 (B): minor version number, which ranges from 0 to 99. A minor version consists of some new features and large bug fixes.
Part 3 (C): feature version number, which ranges from 0 to 99. A feature version consists of scheduled new features.
Part 4 (D): maintenance release number or patch number, which ranges from 0 to 999. A maintenance release or patch consists of resolution to security flaws or minor bugs.
String No
minCompatibleVersionCode Minimum compatible version of the application. It is used to check whether the application is compatible with a version on other devices in the cross-device scenario. Number Yes (initial value: value of versionCode)
minAPIVersion Minimum API version required for running the application. Number Yes (initial value: value of compatibleSdkVersion in build-profile.json5)
targetAPIVersion Target API version required for running the application. Number Yes (initial value: value of compileSdkVersion in build-profile.json5)
apiReleaseType Type of the target API version required for running the application. The value can be "CanaryN", "BetaN", or "Release", where N represents a positive integer.
- Canary: indicates a restricted release.
- Beta: indicates a publicly released beta version.
- Release: indicates a publicly released official version.
String Yes (the value is automatically set by DevEco Studio based on the stage of the SDK in use; a manually set value will be overwritten during compilation and building)
multiProjects Whether the application supports joint development of multiple projects.
- true: The application supports joint development of multiple projects.
- false: The application does not support joint development of multiple projects.
Boolean Yes (initial value: false)
asanEnabled Whether to enable AddressSanitizer (ASan) to detect memory corruption issues such as buffer overflows.
- true: ASan is enabled.
- false: ASan is disabled. Note that ASan is not available in the Release version.
Boolean Yes (initial value: false)
tablet Tablet-specific configuration, which includes the minAPIVersion attribute.
When running on tablets, the application applies the attribute settings under this tag and ignores the general counterparts.
Object Yes (initial value: general settings in the app.json5 file)
tv TV-specific configuration, which includes the minAPIVersion attribute.
When running on TVs, the application applies the attribute settings under this tag and ignores the general counterparts.
Object Yes (initial value: general settings in the app.json5 file)
wearable Wearable-specific configuration, which includes the minAPIVersion attribute.
When running on wearables, the application applies the attribute settings under this tag and ignores the general counterparts.
Object Yes (initial value: general settings in the app.json5 file)
car Head unit–specific configuration, which includes the minAPIVersion attribute.
When running on head units, the application applies the attribute settings under this tag and ignores the general counterparts.
Object Yes (initial value: general settings in the app.json5 file)
default Default device–specific configuration, which includes the minAPIVersion attribute.
When running on default devices, the application applies the attribute settings under this tag and ignores the general counterparts.
Object Yes (initial value: general settings in the app.json5 file)
targetBundleName Target application name of the bundle. The value rule and range are the same as those of bundleName. When a value is specified, the target application becomes one with the overlay feature. String Yes (initial value: left empty)
targetPriority Priority of the application. The value ranges from 1 to 100. This tag can be configured only when targetBundleName is configured. Number Yes (initial value: 1)
generateBuildHash Whether the hash values of all HAP and HSP files of the application are generated by the packaging tool.
If this tag is set to true, the packaging tool generates hash values for all HAP and HSP files of the application. The hash values (if any) are used to determine whether the application needs to be updated when the system is updated in OTA mode but the versionCode value of the application remains unchanged.
NOTE

This tag applies only to system applications.
Boolean Yes (initial value: false)
GWPAsanEnabled Whether to enable GWP-ASan to detect memory errors, such as memory overwriting and memory usage after release.
- true: GWP-ASan is enabled.
- false: GWP-ASan is disabled.
Boolean Yes (initial value: false)