DEV Community

HarmonyOS
HarmonyOS

Posted on

Common Errors in Configuring useNormalizedOHMUrl to true Mode

Read the original article:Common Errors in Configuring useNormalizedOHMUrl to true Mode

Problem Description

After defining the strict mode and setting useNormalizedOHMUrl to true, calling system methods will result in an exception.

"buildOption": {
  "strictMode": {
      "useNormalizedOHMUrl": true
  }
}
Enter fullscreen mode Exit fullscreen mode

The error message is as follows:

startLivenessDetectCall init
09-07 16:09:30.577 64714-64714 C01201/com.hotm...EventHandler com.hotma...iness.hm I ~EventHandler enter 35_74526985950083
09-07 16:09:30.577 64714-64714 C03900/com.hot...siness.hm/Ace com.hotma...iness.hm I [page_router_manager.cpp(1201)-(100000:100000:scope)] Page router manager is loading page[2]: @bundle:com.huawei.hmsapp.hiai.hsp/interactivelivenessHsp/ets/pages/InteractivelivenessAbilityPage.
09-07 16:09:30.577 64714-64714 C03F00/com.hot...m/ArkCompiler com.hotma...iness.hm I [ecmascript] Get Pkg Name failed
09-07 16:09:30.578 64714-64714 C03F00/com.hot...m/ArkCompiler com.hotma...iness.hm E [ecmascript] Cannot execute ark file '@bundle:com.huawei.hmsapp.hiai.hsp/interactivelivenessHsp/ets/pages/InteractivelivenessAbilityPage.abc' with entry '_GLOBAL::func_main_0'
09-07 16:09:30.578 64714-64714 C03900/com.hot...siness.hm/Ace com.hotma...iness.hm W [jsi_declarative_engine.cpp(1692)-(100000:100000:scope)] page not found! bundleName: com.huawei.hmsapp.hiai.hsp, moduleName: interactivelivenessHsp, url: pages/InteractivelivenessAbilityPage
Enter fullscreen mode Exit fullscreen mode

Background Knowledge

  • StrictMode is used to define strict mode. The useNormalizedOHMUrl field indicates whether to use the normalized OHMUrl format, which unifies the original OHMUrl format. The normalized OHMUrl format is required when using integrated HSP and bytecode HAR.
  • If a project references HAR/HSP, ensure that the useNormalizedOHMUrl configuration of the project is consistent with that of the HAR/HSP, and both should be set to true or false.
  • When useNormalizedOHMUrl is set to true, it is not allowed to import files using relative paths across modules or absolute paths. The alias used for the dependency package in oh-package.json5 must be consistent with the name in the oh-package.json5 of the dependency package.

Troubleshooting Process

  1. Check that all OHMUrl formats in the project are consistent.
  2. Check the case sensitivity of the imported file names and the path configuration information.
  3. Check whether the names of the imported third-party libraries are consistent.

Analysis Conclusion

In the configuration file build-profile.json5, setting the strictMode field and configuring useNormalizedOHMUrl to true is primarily intended to avoid compilation errors or runtime issues caused by inconsistent URL handling methods, thereby ensuring the stability and security of the application.

When useNormalizedOHMUrl is set to true, the alias of the dependency reference must exactly match the actual module name, and therefore, the error ‘This dependency alias does not match the package name. Change it to ‘XXX’.’ occurs.

Solution

  1. Enable strict mode.
  2. Ensure that the case of imported files exactly matches the path.
  3. Check and adjust the paths and case formats of imported files to ensure they meet the requirements of strict mode.

Written by Merve Yonetci

Top comments (0)