Symptom
During compilation and build, memory or CPU usage is too high, resulting in issues such as slow response in DevEco Studio.
Solution
You can add configurations to hvigor-config.json5.
"properties": {
// Setting to 0 means no memory cache configuration is enabled; the default value is 4; the smaller the value, the less data cached in the memory.
"hvigor.pool.cache.capacity": 0,
// The default value is the number of CPU cores minus 1, including ohos.arkCompile.maxSize; the smaller the value, the less memory used.
"hvigor.pool.maxSize" : 5,
// The default value is 5; the smaller the value, the less memory used.
"ohos.arkCompile.maxSize": 3,
// The default value true enables memory cache, which results in more memory used; the value false means the opposite.
"hvigor.enableMemoryCache": false
},
After the values of hvigor.pool.maxSize and ohos.arkCompile.maxSize are set to smaller numbers and hvigor.enableMemoryCache is set to false, the compilation time may increase.

hvigorw assembleHap --no-parallel
Using the non-parallel mode for compilation will reduce memory usage, but it may also lead to an increase in compilation time.
Rectify the fault based on the value of XXX. If the fault persists, refer to the final solution.
Symptom
During the compilation and build process, the error "Cannot read properties of undefined(reading 'setEnabled')" occurs.
Cause Analysis
The hvigorfile.ts file contains the following code:
import { hvigor, getHvigorNode } from "@ohos/hvigor"
import { hapTasks} from '@ohos/hvigor-ohos-plugin';
// Problematic code
getHvigorNode(__filename).getTaskByName('XXX').setEnabled(false);
export default {
system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins: [] /* Custom plugin to extend the functionality of Hvigor. */
} Solution
For example, if the error occurs in hvigorfile.ts of the entry module, valid task names include the following: default@SignHap, default@CollectDebugSymbol, and assembleHap, as shown in the following figure.

Symptom
During the compilation and build process, the error "Cannot read properties of undefined(reading 'isSO')" occurs.
Solution
Upgrade DevEco Studio to 5.1.0.840 or later.
Symptom
During the compilation and build process, an error "Cannot read properties of undefined(reading 'getPluginId')" occurs.
Solution
Set system in the export default object in hvigorfile.ts to appTasks, hapTasks, hspTasks, or harTasks.
import { appTasks } from '@ohos/hvigor-ohos-plugin';
export default {
system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
} Symptom
During the compilation and build process, the error "Cannot read properties of undefined(reading 'getNeedExecTargetServiceList')" occurs.
Solution
Set the type field in module.json5 of the module to match the system field of the export default object in hvigorfile.ts. For the corresponding mappings between type and system, refer to the table below.
type in module.json5 | system of the export default object in hvigorfile.ts |
|---|---|
entry | hapTasks |
feature | hapTasks |
shared | hspTasks |
har | harTasks |
Symptom
During the compilation and build process, the error "Cannot read properties of undefined(reading 'app')" occurs.
Solution
Ensure that the AppScope/app.json5 file exists in the project directory.
Symptom
When a unit test is performed in the Linux environment, the error "Cannot read properties of undefined(reading 'toString')" occurs.
Solution
Currently, unit tests are not supported in the Linux environment.
Symptom
During the compilation and build process, the error "Cannot read properties of undefined(reading 'kind')" occurs.
Solution
Refer to the following code examples:
// Negative example: empty array
class w {
public a: [][] = []
test() {
console.log("1", this.a[0])
}
}
// Positive example
class w {
public a: string[][] = []
test() {
console.log("1", this.a[0])
}
} Symptom
During the compilation and build process, the error "Cannot read properties of undefined(reading 'clear')" occurs.
Cause Analysis
Configure the following content in the hvigor/hvigor-config.json5 file in the project root directory to open the stack.
"debugging": {
"stacktrace": true /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
}, Check whether the stack content is as follows:

Solution
If your DevEco Studio is using third-party plugins, such as security hardening plugins, disable them and check whether the issue persists. If the issue persists, refer to the final solution.
If none of the preceding solutions work, open the stack and check the code based on the stack information.
To open the stack, add the following content to the hvigor/hvigor-config.json5 file in the project root directory:
"debugging": {
"stacktrace": true /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
}, Check the hvigorconfig.ts and hvigorfile.ts files first, and then check other files.
If no problem is found in the preceding files, submit a ticket online.
Symptom
During the compilation and build process, an error occurs: "Duplicated files found in module xxx. This may cause unexpected errors at runtime".
The error occurs when there are different versions of an .so file with the same name. For example, if you copy the .so file from the har module's product to the libs directory of the entry module, then there is a libhar.so file in both the har module and the entry module. In this case, if you configure the entry module to depend on the har module, the build of the entry module will result in an error.

Solution
Use configurations such as select, pickFirsts, and pickLasts to choose the .so files to be used. select provides precise selection capabilities for native products, with a higher priority than excludes, pickFirsts, and other configuration items. pickFirsts and pickLasts pack the .so file with the highest priority. The priority order refers to the order of dependency collection, and the later it is collected, the higher the priority.
For details, see Configuring for C++ Builds.
Based on the preceding example, you can add a select configuration in the entry module's build-profile.json5 file to choose the .so file from the har module, set package to the "har", and include to "libhar.so".

Symptom
When an App Pack is packaged, the message "input module releaseType is different" is displayed.

Solution
According to the module names indicated in the error message, check whether the apiReleaseType fields are consistent between the modules.
The apiReleaseType field is automatically generated by the compilation and build tool and is saved in the module.json file of the HAP/HSP. As shown in the figure below, first confirm whether this field is consistent between the modules. If there is an inconsistency, you need to repackage each module of the app with the same version of the SDK, and then package the App Pack.

Symptom
When an App Pack is packaged, the message "debug is different" is displayed.

Solution
Based on the module names indicated in the error message, check whether the debug fields are consistent between modules, especially between local modules and externally referenced modules.
1. The debug field is automatically generated by the compilation and build tool and saved in the module.json file of the HAP/HSP, as shown in the figure below. First, confirm whether the fields are consistent across all modules.

2. Set Build Mode, based on which the compilation and build tool generates the debug flag.

Symptom
When an App Pack is packaged, the message "uri datashareproxy://bundleName/** in proxy data is duplicated" is displayed.

Solution
The proxyData field lists the data proxies provided by the module and is only allowed to be configured in entry and feature modules. The URIs configured in different proxyData configurations must not be duplicated. In light of this, if the preceding issue occurs, check whether the proxyData configurations with the same URI is configured between modules.

Symptom
During compilation and build, an error occurs: "Init keystore failed: parseAlgParameters failed: ObjectIdentifier()".
hap-sign-tool: error: ACCESS_ERROR, code: 109. Details: Init keystore failed: parseAlgParameters failed: ObjectIdentifier() -- data isn't an object ID (tag = 48) Detail: Please check the message from tools
Analysis
Using a higher version of JDK to generate a key pair (.p12), and then using a lower version of JDK to execute the signing command, can lead to incompatibility, causing the .p12 file to fail to parse, and the signing to fail.
Scenarios
Solution
Check the JDK version currently in use and the version used to generate the key pair, and use a JDK version that matches for executing the signing command.
Symptom
During compilation and build, an error occurs: message: generate SignerBlock failed.
hap-sign-tool: error: {errorcode:0,message:generate SignerBlock failed} Analysis
The public and private key pair used for signing does not match. In this case, if you sign with the private key, verification with the public key will fail. Ensure that the private key (keyalias) and public key (appCertPath) are used in pairs.
Scenarios
Solution
Select the correct, paired keyalias and appCertPath files.
Symptom
During the compilation and build process, the error message "java.io.IOException: DerValue.getOID, not an OID 49" is displayed.
hap-sign-tool: error: ACCESS_ERROR, code: 109. Details: java.io.IOException: DerValue.getOID, not an OID 49 Detail: Please check the message from tools
Possible Cause
The certificate file fails to parse, and the certificate's OID could not be found.
Scenarios
Solution
Make sure the certificate is correct.
Symptom
The error message "JS heap out of memory" is displayed during compilation and build.

Solution
The memory for running Hvigor is insufficient. When Hvigor of version 3.1.0 or later is used, modify the maximum memory for running Hvigor. Do as follows:
Select Enable the Daemon for tasks.

Set the value of maxOldSpaceSize in hvigor-config.json5 to a larger value (for example, 8192) based on the project size.
"nodeOptions": {
"maxOldSpaceSize": 8192
} Symptom
In a Linux environment, the system has 64 GB of memory. The hvigorw script is configured with --max-old-space-size=40960. During the compilation and build process, an error "JS heap out of memory" occurs even though the actual memory usage has not reached the configured limit (for example, only around 20 GB is used).
FATAL ERROR: NewSpace::Rebalance Allocation failed - JavaScript heap out of memory Writing Node.js report to file: report.20200512.172528.47517.24.011.json Node.js report completed 1: 0xa295e0 node::Abort() [node] 2: 0x9782df node::FatalError(char const*, char const*) [node] 3: 0xb99c2e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node] 4: 0xb99fa7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node] 5: 0xd3a3b5 [node] 6: 0xd74f27 [node] 7: 0xd84707 v8::internal::MarkCompactCollector::CollectGarbage() [node] 8: 0xd481b9 v8::internal::Heap::MarkCompact() [node] 9: 0xd48f0b v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node] 10: 0xd499a5 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node] 11: 0xd4aebf v8::internal::Heap::HandleGCRequest() [node] 12: 0xcf5f97 v8::internal::StackGuard::HandleInterrupts() [node] 13: 0x104b803 v8::internal::Runtime_StackGuard(int, unsigned long*, v8::internal::Isolate*) [node] 14: 0x13a5a99 [node] Aborted (core dumped)
Possible Causes
As a parameter related to the kernel's virtual memory subsystem, vm.max_map_count controls the maximum number of memory mapping areas that a process can have. It is commonly used to limit the number of files a process can open, especially in cases where a large number of memory-mapped files are used.
On Linux, the default value of vm.max_map_count is usually a relatively small number, such as 65530. However, for some apps that require a large number of memory mappings or for specific use cases, you may need to increase the value of this parameter to allow for more memory mapping areas.
Solution
Change the value of vm.max_map_count.
sysctl -w vm.max_map_count=new_value
Vm.max_map_count=new_value
Save the file and run the following command to apply the changes:
sysctl -p
Symptom
When the native file (.so) is referenced during stage model project compilation, the error message "Cannot find module XXX or its corresponding type declarations." is displayed.
Solution
During compilation and build of the current stage model project, the syntax of the symbols exported from the native file (.so) is verified. If a native file (.so) without the corresponding declaration file (.d.ts) is referenced, the syntax verification tool reports an error message indicating that the corresponding declaration file cannot be found.
If a similar problem occurs, perform the following to troubleshoot:



Symptom
When a third-party package is referenced, the build fails and the error message "Cannot find module 'xxx' or its corresponding type declarations" is displayed.

Solution
Open the oh-package.json5 file of the corresponding module or project to check whether the third-party package has been installed. If the third-party package has not been installed, run ohpm install to install it. If the third-party package has been installed, check whether the main field is correctly configured. If the entry file is not configured or incorrectly configured, configure it correctly.
Symptom
The referenced package path is obfuscated. In the code, the path is directly concatenated to the end of the referenced package. As a result, the module cannot be referenced and an error is reported.
Sample code:

It is referenced in the code as follows:
In this case, the module cannot be found. As a result, an error is reported.
Solution
Change the reference mode to the recommended one.

Symptom
The referenced module oh_package.json5 is incorrectly configured. The ohpm install command is executed and the dependency is successfully installed. However, an error message is displayed, indicating that the module cannot be found.

The types field is incorrectly configured in the oh_package.json5 file of the referenced module.
This field takes precedence over the main field. In other words, if the value configured in the types field does not exist, an error message is displayed, indicating that the module cannot be found.

Solution
If the package does not contain the d.ets declaration, this field can be deleted. If the configured value does not exist or is incorrect, an error is reported.
Symptom
The name of the module referenced in dependencies of oh_package.json5 is different from that imported in actual use.
For example, a module is referenced in oh_package.json5 as follows:
"dependencies": { "har": "file:../har" } The import statement uses HAR or other names instead of har as configured in dependencies. The values must match exactly. (Currently, this issue occurs only on Linux.)
Solution
Change the name of the module referenced in dependencies of oh_package.json5 to the same as that imported in actual use.
Symptom
The value of the main field in oh_package.json5 of the referenced module is inconsistent with the actual file name.
Solution
Change the case of the main field to be the same as that of the actual file name.
Symptom
The stage model project fails to be built, with the message "Cannot find module '@bundle:rollup_plugin_ignore_empty_module_placeholder' or its corresponding type declarations".

Solution
This issue occurs when the project references a .d.ts declaration file that does not have the corresponding implementation file.

Enter rollup_plugin_ignore_empty_module_placeholder in the text box to locate the intermediate file where the error is reported.

export type {T} from './type'; 

Symptom
The stage model project fails to be compiled and built. The error message "Module 'xxx' has no exported member 'yyy'" is displayed, where the yyy symbol is exported from the x.js file using export * from 'x.js'.
Solution
During compilation and build of the stage model project, the syntax of the .js file is not checked. Therefore, when using export * from 'x.js' to export symbols from an x.js file, "Module 'xxx' has no exported member 'yyy'" is reported where the symbol is referenced.
If a similar problem occurs, perform the following to troubleshoot:
export { yyy } from 'x.js' 
Symptom
The stage model project fails to be compiled and built, and the message "ERROR: Could not load ${file1} (imported by ${file2}): Maximum call stack size exceeded" is displayed.

Solution
This problem occurs because file1 is the code outside the current project.

Create a Static Library module, migrate the code outside the project to the Static Library module, and reference HAR using HAP to implement cross-module reference.
Symptom
When the dependency of a third-party package is configured in devDependencies, if the source code references the API in the dependency, the compilation fails. In the following example, the third-party package @hms-security/ucs-appauth depends on @network/gr in devDependencies. When the source code uses the API of @network/grs, the compilation fails and the error message "ArkTS:ERROR Failed to get a resolved OhmUrl by filepath xxx" is displayed.



Symptom
Compilation fails with the error message "ArkTS:ERROR Failed to get a resolved OhmUrl by filepath xxx."

Cause Analysis
Check whether the srcPath path specified by field modules in the build-profile.json5 file of the project directory is different from the actual path and whether the path uses incorrect letter cases.
Solution
Change the value of srcPath in field modules in the build-profile.json5 file of the project directory to the actual path.
Symptom
Project A references a module of project B using relative paths. This reference causes an error.


Solution
Symptom
Compilation fails with the error message "Error Message: Failed to get a resolved OhmUrl for 'hvigor_ignore_xxxxx' imported by xxx."
Solution
If the module containing hvigor_ignore_xxxxx is a HAR module, check the oh_package.json5 file for the presence of "packageType": "InterfaceHar". If it exists, remove it.
Symptom
Compilation fails with the error message "Failed to get a resolved OhmUrl for 'xxx' imported by 'yyy'."

Cause Analysis
Solution

"buildOption": {
"arkOptions": {
"byteCodeHar": false
}
} Ensure that the current DevEco Studio version matches the SDK version. Choose Help > About DevEco Studio and Help > About HarmonyOS SDK to check the DevEco Studio and SDK versions.

Symptom
The error message "ArkTS:ERROR Failed to get a resolved OhmUrl by filepath xxx" is accompanied with the message "ERROR: ArkTS:ERROR failed to execute es2ab."

Solution
The project references a non-standard module directory (that is, the directory does not contain the module description file module.json5). Create a Static Library module and migrate the code in utils/common to the Static Library module, and reference HAR using HAP to implement cross-module reference.
Symptom 1
The user-defined parameter BuildProfile is used. No exception occurs in the compilation phase, but the compilation fails, with the message "Property xxx does not exist on type 'typeof BuildProfile'."

Solution
Check whether the key values of user-defined parameters configured in targets > buildProfileFields in build-profile.json5 of the current module are the same. If they are different, change them to the same.
The following is an example of incorrect configuration that causes the compilation error:
"targets": [
{
"name": "default",
"config": {
"buildOption": {
"arkOptions": {
"buildProfileFields": {
"targetName": "default"
}
}
}
}
},
{
"name": "default1",
"config": {
"buildOption": {
"arkOptions": {
"buildProfileFields": {
"targetName1": "default1"
}
}
}
}
},
] Change all the key values of buildProfileFields in targets to the same. The following is an example:
"targets": [
{
"name": "default",
"config": {
"buildOption": {
"arkOptions": {
"buildProfileFields": {
"targetName": "default"
}
}
}
}
},
{
"name": "default1",
"config": {
"buildOption": {
"arkOptions": {
"buildProfileFields": {
"targetName": "default1"
}
}
}
}
},
] Symptom 2
The custom parameter BuildProfile used is marked red by the compiler, and the build fails with "Property xxx does not exist on type 'typeof BuildProfile'." reported.

Solution
Ensure that the user-defined parameter is added to buildProfileFields in build-profile.json5 of the current module.
Symptom
For a C++ project with a large amount of code, the CPU usage is high during C++ compilation. As a result, the computer may freeze or respond slowly.
Solution
If a similar problem occurs, perform the following to troubleshoot:
"arguments": "-DCMAKE_JOB_POOL_COMPILE:STRING=compile -DCMAKE_JOB_POOL_LINK:STRING=link -DCMAKE_JOB_POOLS:STRING=compile=2;link=2",
It should be noted that if the values of compile and link are changed, the compilation duration may increase.
Symptom
During compilation of a HarmonyOS C++ project, the error message "A 'undefined symbol' error has occurred" is displayed.
Solution
The "undefined symbol" error typically indicates that the linker cannot find the definition of a specific symbol. This issue often occurs when source files are not compiled or linked correctly, or when the necessary library files are missing. To locate and rectify this issue, perform the following steps:
1. Make sure all source files are included in the CMake build.
Check your CMakeLists.txt file to ensure that all relevant source files are included in the project.
cmake_minimum_required(VERSION 3.10)
project(MyProject)
set(CMAKE_CXX_STANDARD 17)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include)
# Add all source files.
add_library(myProgram SHARED main.cpp myLibrary.cpp) 2. Confirm the symbol definitions in the source files.
Make sure symbols are correctly defined in all relevant source files. For example, check whether myLibrary.cpp includes the definition of myFunction.
myLibrary.cpp
#include "myLibrary.h"
void myFunction() {
// Function implementation
} myLibrary.h
#ifndef MY_LIBRARY_H #define MY_LIBRARY_H void myFunction(); #endif
3. Check the compilation and linking order.
Make sure all source files and library files are compiled and linked in the correct order. CMake and Ninja usually handle this order issue, but problems may arise during manual compilation.
4. Clean and regenerate build files.
Sometimes, build files may become corrupted or symbol definitions may be lost. Try cleaning the build directory and regenerating the build files:
hvigorw clean 1
Alternatively, manually delete the .cxx directory from the module.
5. Check library paths and linker flags.
If using third-party libraries, make sure the library paths and linker flags are correctly configured in the CMakeLists.txt file. Sample code:
cmake_minimum_required(VERSION 3.10)
project(MyProject)
set(CMAKE_CXX_STANDARD 17)
# Ensure that the header file of the involved third-party library is added.
include_directories(${PATH_TO_EXTERNAL_LIBRARY}
${PATH_TO_EXTERNAL_LIBRARY}/include)
# Add a source file.
add_library(myProgram SHARED main.cpp myLibrary.cpp)
# Link the third-party library.
target_link_libraries(myProgram PUBLIC /path/to/external/library) 6. Enable verbose compilation and linking output.
To understand the detailed compilation and linking process, you can enable more verbose output. Add the following to the CMakeLists.txt file:
set(CMAKE_VERBOSE_MAKEFILE ON)
7. Check the Ninja output logs.
By default, Ninja generates a .ninja_log file containing detailed information about the build process. You can check this log file to identify issues that occur during the build process.
cat {module}/.cxx/default/default/arm64-v8a/.ninja_log Check the log file for the source file or header file containing the symbols.
8. Use the nm tool to check symbols.
Inspect the symbols in the target file and library file to ensure that the symbol definitions exist.
You can do so with the nm tool in the SDK: sdk/default/openharmony/native/llvm/bin/llvm-nm.
Check the target file.
nm myLibrary.o | grep myFunction
Check the third-party library file.
nm /path/to/external/library | grep myFunction
Conclusion
By following the above steps, you can locate and resolve the "error: undefined symbol" issue. When compiling a C++ project with CMake, Ninja, and LLVM, ensure that all source files and library files are correctly included in the project and that the compilation and linking options are correctly configured. If the issue persists, consult the compilation and linking output logs for clues to help you identify the specific cause.
Symptom
During compilation of a HarmonyOS C++ project, the error message "A 'unknown type name' error has occurred" is displayed.
Solution
This error occurs when the compiler cannot recognize a certain type. This may be due to the type not being defined, the relevant header file not being included, or the path to the included header file being incorrect. To locate and rectify this issue, perform the following steps:
Make sure all necessary header files are correctly included in the source file. For example, if you are using a custom type or a type provided by a library, be sure to include the relevant header file in the file where the type is used.
Example
// main.cpp
#include "myLibrary.h"
int main() {
MyType obj;
// Use a custom type.
return 0;
}
// myLibrary.h
#ifndef MY_LIBRARY_H
#define MY_LIBRARY_H
class MyType {
public:
MyType() {}
void doSomething();
};
#endif Make sure the search paths for header files are correctly set in the CMakeLists.txt file. You can add header file directories using include_directories.
Example CMakeLists.txt:
cmake_minimum_required(VERSION 3.10)
project(MyProject)
set(CMAKE_CXX_STANDARD 17)
# Add a header file directory.
include_directories(${CMAKE_SOURCE_DIR}/include)
# Add a source file.
add_library(myProgram SHARED src/main.cpp src/myLibrary.cpp) Sometimes, build files may become corrupted or symbol definitions may be lost. Try cleaning the build directory and regenerating the build files:
hvigorw clean
Alternatively, manually delete the .cxx directory from the module.
To understand the detailed compilation process, you can enable more verbose output. Add the following to the CMakeLists.txt file:
set(CMAKE_VERBOSE_MAKEFILE ON)
By default, Ninja generates a .ninja_log file containing detailed information about the build process. You can check this log file to identify issues that occur during the build process.
cat .cxx/default/default/arm64-v8a/.ninja_log
Add the message function in the CMakeLists.txt file to print debugging information to ensure that paths and variables are correctly set.
Example
message(STATUS "Source directory: ${CMAKE_SOURCE_DIR}")
message(STATUS "Include directories: ${CMAKE_INCLUDE_PATH}") Conclusion
By following the above steps, you can locate and resolve the "error: unknown type name" issue. When compiling a C++ project with CMake, Ninja, and LLVM, it is crucial to ensure that all header files are correctly included and that the correct header file paths are set. If the issue persists, consult the compilation output logs for clues to help you identify the specific cause.
Symptom
The LABEL_VALUE_ERROR message is displayed during project synchronization or building.

Solution
Set the label field in the config.json file to the resource reference mode.

Symptom
An error occurs during project synchronization or build, and the error message "Schema validate failed" is displayed.

Solution
During app/atomic service development, you can set the icon and background color of the startup window. The startup window settings are automatically configured when you create a project. If you accidentally delete a required field, the system generates an error to alert you and prevent misconfiguration. The following describes how to reset the startup page information. You can customize the icon and background color of the startup page.
To improve the cold start performance of your app/atomic service, you can set the icon and background color on the startup window as follows:


After the creation is complete, the color.json file shown below is displayed.



Symptom
An error occurs during compilation via DevEco Studio, and the error message "Schema validate failed" is displayed.
Solution
The cause is that some fields are missing or spelled incorrectly in the configuration file. Locate the fault based on the error details.
For example, if name in the abilities tag in module.json5 is misspelled to nam, the following error information is displayed:
Detail: Please check the following fields.
{
instancePath: 'module.abilities[0]',
keyword: 'required',
params: { missingProperty: 'name' },
message: "must have required property 'name'",
location: 'D:/MyApplication/entry/src/main/module.json5:15:8'
}
{
instancePath: 'module.abilities[0]',
keyword: 'required',
params: { missingProperty: 'srcEntrance' },
message: "must have required property 'srcEntrance'",
location: 'D:/MyApplication/entry/src/main/module.json5:15:8'
}
{
instancePath: 'module.abilities[0]',
keyword: 'required',
params: { missingProperty: 'name' },
message: "must have required property 'name'",
location: 'D:/MyApplication/entry/src/main/module.json5:15:8'
}
{
instancePath: 'module.abilities[0]',
keyword: 'oneOf',
params: { passingSchemas: null },
message: 'must match exactly one schema in oneOf',
location: 'D:/MyApplication/entry/src/main/module.json5:15:8'
}
{
instancePath: 'module.abilities[0]',
keyword: 'enum',
params: {
allowedValues: [
'priority',
'name',
'srcEntrance',
'srcEntry',
'launchType',
'description',
'icon',
'label',
'permissions',
'metadata',
'visible',
'exported',
'skills',
'backgroundModes',
'continuable',
'startWindowIcon',
'startWindowBackground',
'removeMissionAfterTerminate',
'orientation',
'supportWindowMode',
'maxWindowRatio',
'minWindowRatio',
'maxWindowWidth',
'minWindowWidth',
'maxWindowHeight',
'minWindowHeight',
'excludeFromMissions'
]
},
message: 'must be equal to one of the allowed values',
location: 'D:/MyApplication/entry/src/main/module.json5:15:8'
}
{
instancePath: 'module.abilities[0]',
keyword: 'propertyNames',
params: { propertyName: 'nam' },
message: 'property name must be valid',
location: 'D:/MyApplication/entry/src/main/module.json5:15:8'
} Keywords in the preceding error information:

Symptom
An error occurs during compilation via DevEco Studio, and the error message "No available entry module found" is displayed.
Solution
The dependent entry module needs to be configured in the feature module. During compilation, DevEco Studio checks whether the entry module on which the feature module depends exists. If an error similar to above is reported, the possible causes are as follows:
Symptom
An error occurs during compilation via DevEco Studio, and the error message "keystore password was incorrect" is displayed.

Possible Cause
The password of the keystore (.p12) is incorrect.
storePassword and keyPassword are customized by the developer when the .p12 file is created. Remember the passwords. The build-profile.json5 file of the DevEco Studio project contains the ciphertext of the password. However, the signing tool requires the plaintext of the password. Therefore, the value in the build-profile.json5 file cannot be directly used in the signing tool.
Common Scenarios
Solution
The cause is that the signature password in the signature file is incorrect.

Developers can solve this problem by re-signing.
1. Choose File > Project Structure > Project > Signing Configs.
2. Select Automatically generate signature, wait for re-signing, and click OK.

Symptom
An error occurs during compilation via DevEco Studio. One of the following messages is displayed:




Solution
Modify the project to ensure that it meets the HAP uniqueness verification logic during packaging. For details, see Logic for Checking HAP Uniqueness.
Symptom
During multi-module native build, the error message "Failed to generate test project build system." is displayed.

Solution
Delete the .cxx folder under the module that reports the error, select the module to be built, and run the Make Module ${moduleName} command to build the module separately. Do not build multiple modules at the same time.

Symptom
When a C/C++ project depends on a third-party so. file, the third-party so. file is not packaged into the HAP file after it is generated.
Solution
Currently, DevEco Studio has limited addressing modes for third-party so. files in C/C++ projects. If third-party so. files are not packaged into HAP, modify the so. file import mode.

Symptom
Click Build > Make Module ${libraryName} to compile and build the HAR, files in the cpp directory are not displayed in the build product.

Solution
When Hvigor 2.5.0-s or later is used for HAR compilation and build, only the local dependencies specified in dependencies in the current module are included in the .har file. The dependencies specified in devDependencies are not included.
Move the corresponding local dependency to dependencies and recompile it.

Symptom
During project build, the error message "ArkTS:WARN: For details about ArkTS syntax errors, see FAQs" is displayed.

Solution
Check the error message for specific ArkTS syntax rule violations, which are enclosed in brackets, such as (arkts-no-var). Then, refer to the TypeScript to ArkTS Cookbook and modify your code to comply with the ArkTS syntax specifications.
Symptom
An error is reported during native project compilation, and the following warning and error message are displayed:
A warning message is generated indicating that the length of the project directory exceeds 250 characters. For example:

The compilation error message "ninja: error: mkdir(xxx): No such file or directory" is displayed, as shown in the following figure.

Solution
The default value of CMAKE_OBJECT_PATH_MAX is 250. If the actual path length of the object file in the project exceeds this limit, a compilation error is reported.
You need to set CMAKE_OBJECT_PATH_MAX in CMakeLists.txt based on the actual path length of the object file. The procedure is as follows:
In the example, the warning message file is TextMeasureCache.cpp.obj, whose name contains 24 characters. Add 24 to the default value 250, that is, configure it to set(CMAKE_OBJECT_PATH_MAX 274).
Calculation formula: CMAKE_OBJECT_PATH_MAX = Total path length – Length of the directory in the object file + Number of characters in the CMake hash value (fixed at 32)

Therefore, in this example, CMAKE_OBJECT_PATH_MAX = 297 - 74 + 32 = 255, that is, set it to set(CMAKE_OBJECT_PATH_MAX 255).
Symptom
An error is reported during native project compilation, and the following warning and error message are displayed:
A warning message is generated indicating that the length of the project directory exceeds 250 characters. For example:

The compilation error message "(is the command line too long?)" is displayed, as shown in the following figure.

Solution
The default value of CMAKE_OBJECT_PATH_MAX is 250. If the actual path length of the object file in the project exceeds this limit, a compilation error is reported.
You need to set CMAKE_OBJECT_PATH_MAX in CMakeLists.txt based on the actual path length of the object file. The procedure is as follows:
In the example, the warning message file is TextMeasureCache.cpp.obj, whose name contains 24 characters. Add 24 to the default value 250, that is, configure it to set(CMAKE_OBJECT_PATH_MAX 274).
Calculation formula: CMAKE_OBJECT_PATH_MAX = Total path length – Length of the directory in the object file + Number of characters in the CMake hash value (fixed at 32)

Therefore, in this example, CMAKE_OBJECT_PATH_MAX = 297 - 74 + 32 = 255, that is, set it to set(CMAKE_OBJECT_PATH_MAX 255).
After CMAKE_OBJECT_PATH_MAX is correctly configured, CMake converts the long path into a 32-character hash value to shorten the path length. If the converted path is still too long, change the project storage path to a shorter directory.
Symptom
When find_path is used in a native project, the following error information is displayed:

Solution
In the CMake cross-compilation configuration file (ohos.toolchain.cmake) provided by the OpenHarmony SDK, the search path is restricted to CMAKE_SYSROOT.
If you need to add a search path, use the list API to add a custom path in CMakeLists.txt. For example, add D:demo to the search path.
list(APPEND CMAKE_FIND_ROOT_PATH_MODE_INCLUDE "D:demo")
After the path is added, you can use find_path to search files in the D:demo directory.
Symptom
In a project, module A references module B. When module A is compiled, an error message "Unknown resource name 'xxxx'" is displayed, indicating that the resources of module B cannot be found.

Solution
Ensure that the following conditions are met:
Symptom
The method of referencing a module is incorrect. If the code of another module is referenced, an error message is displayed, indicating that the resource cannot be found.


Solution
Add the module under dependencies in the oh_package.json5 module.
An example is provided as follows.

Symptom
HSP A applies for a permission that references resources. When all components that depend on HSP A are built, an error message is displayed, indicating that the resources referenced by HSP A cannot be found.
Solution
Manually configure the corresponding resource in the referencing party.
Symptom
When the build command is manually executed on the CLI, the build fails and the error message "Task xxx was not found in the project xxx" is displayed.
Cause Analysis
Solution
Symptom
Compilation via DevEco Studio fails, and the error message "The reason and usedScene attributes are mandatory for user_grant permissions" is displayed.

Possible Causes
In DevEco Studio NEXT Developer Preview2 and later versions, the following rule is added: In an app package, the permission list requestPermissions under the module of all Entry.hap and Feature.hap must be specified. (requestPermissions can be left empty by default. If it is not empty, the name field is mandatory. For the user_grant permission, the reason and usedScene fields are mandatory.)
Solution
Go to the corresponding module.json5 file and supplement the reason and usedScene fields under requestPermissions. The following is an example:
"requestPermissions": [
{
"name": "ohos.permission.READ_IMAGEVIDEO",
"reason": "$string:module_desc",
"usedScene": {
"abilities": [
"EntryAbility"
],
"when": "inuse"
}
}
] Symptom
Compilation via DevEco Studio fails, and the error message "Only one default card can be configured in the form_config.json file" is displayed.

Possible Causes
In DevEco Studio NEXT Developer Preview2 and later versions, the following rule is added: In the widget configuration file, isDefault cannot be left empty. Each UIAbility has only one default widget.
Solution
Go to the corresponding module.json5 file, select the default widget, and set the isDefault field of other widgets to false.
Symptom
Compilation via DevEco Studio fails, and the error message "In the form_config.json file, if the value of the updateEnabled field is true, the updateDuration and scheduleUpdateTime fields cannot be both empty." is displayed.

Possible Causes
In DevEco Studio NEXT Developer Preview2 and later versions, the following rule is added: updateEnabled in the widget configuration file cannot be left empty. If updateEnabled is set to true, you can select either updateDuration or scheduledUpdateTime and configure it. If both updateDuration and scheduledUpdateTime are configured, updateDuration takes effect first.
Solution
Open the module.json5 file and set updateEnabled to false or add updateDuration and scheduledUpdateTime as required.
Symptom
When DevEco Studio is opened directly from a .dmg file on macOS, any attempt to build a project results in the error message "The path XX is not writable. Please choose a new location."

Possible Causes
Opening DevEco Studio from the .dmg file launches it in read-only mode, and the files built into DevEco Studio do not have write permissions.
Solution
Drag DevEco-Studio.app to Applications and install DevEco Studio by following the onscreen instructions.
Symptom
The external interface provided by the local HSP module uses a custom parameter BuildProfileFileds, which is not defined in the HAP, and the HAP references this interface, causing the compilation to fail with the message "Property 'XX' does not exist on type 'typeof BuildProfile'".

Solution
You can resolve this issue in two ways:
Symptom
Error message "The useNormalizedOHMUrl settings of packages xxx and the project useNormalizedOHMUrl: xxx do not match" is displayed during compilation
Solution
When useNormalizedOHMUrl is set to true, the ohmurl uses a new method of concatenation and parsing. As such, it cannot be mixed with the old ohmurl; otherwise, it cannot be recognized at runtime.
You can resolve this issue in two ways:
{
"app": {
"products": [
{
"buildOption": {
"strictMode": {
"useNormalizedOHMUrl": true
}
}
}
]
}
} If the issue persists, the HSP is a local package. In this case, import the HSP by adding it to modules in the project-level build-profile.json5 file. The following is an example:
"modules": [
{
name: "hsp", // HSP dependency
srcPath: "../MyApplication_stageB/hsp", // Absolute or relative path of the HSP dependency
}
] Symptom
The error message "Could not resolve 'xxx' from" is displayed during compilation, but the xxx directory exists and contains an Index file.
Possible Causes
When referencing a directory, the compiler automatically concatenates a lowercase index file, but the directory contains an uppercase Index file. During compilation in a case-sensitive environment, the index file cannot be found, resulting in an error.
Solution
When referencing a directory, explicitly specify the reference to the Index file in the directory, for example, xxx/Index.
Symptom
During an attempt to create a project, the error message "Error: The hvigor depends on the npmrc file. Configure the npmrc file first." is displayed.
Possible Causes
There is no .npmrc file in the user directory.
Solution
Create an .npmrc file in your user directory and configure the following information:
registry=https://repo.huaweicloud.com/repository/npm/ @ohos:registry=https://repo.harmonyos.com/npm/
Symptom
The error message "Error: 'icon' value `$media:icons` invalid value" is displayed during compilation.
ERROR: Failed :entry:default@CompileResource... ERROR: Tools execution failed. Error: ref `$media:icons` don`t be defined. Error: 'icon' value `$media:icons` invalid value. at D:\project\process_profile\default\module.json Detail: Please check the message from tools.
Possible Cause
When a referenced resource does not exist, the file path indicated by the compilation error is the build directory.
Common Scenarios
Solution
Search globally for the resource ID indicated by the error to check whether the erroneous resource exists.
Symptom
The error message "Error: cJSON_Parse failed, please check the JSON file" is displayed during compilation.

Possible Cause
The module.json file format is invalid.
Common Scenarios
1. There is an extra comma (,) at the end of the JSON file.
2. The root element is not enclosed in curly braces ({}).
Solution
Verify the format of the JSON file indicated by the error.
Symptom
The error message "Error: the name 'XXX' can only contain [a-zA-Z0-9_]" is displayed during compilation.

Solution
Verify the file name. The file name can contain only uppercase letters, lowercase letters, digits, and underscores (_).
Symptom
The error message "Cannot add xxxx items to index" is displayed during compilation.
Possible Causes
There is a function within the compiled file that contains a large number of object literals, array literals, and strings, causing the number of items to exceed the limit (65536).
Solution
Check the relevant files and split the functions that have the aforementioned causes.
Symptom
The compilation hangs, with the error message displayed: The modules directory at "xxx/workspace/node_modules" will be removed and reinstalled from scratch. Proceed? (Y/n) > true.

Possible Causes
The pnpm version used for installing the build plugin is different from that used by DevEco Studio.
Solution