HarmonyOS鸿蒙Next中hvigor ERROR: Failed :entry:default@BuildNativeWithNinja...

HarmonyOS鸿蒙Next中hvigor ERROR: Failed :entry:default@BuildNativeWithNinja

“D:\soft\DevEco Studio\tools\node\node.exe” C:\Users\tang_lizhen.hvigor\project_caches\883ff35a95baac36e903ba0f9d6852bd\workspace\node_modules@ohos\hvigor\bin\hvigor.js --mode module -p product=default assembleHap --parallel --incremental --daemon

hvigor Finished :entry:default@PreBuild… after 21 ms
hvigor Finished :entry:default@GenerateMetadata… after 20 ms
hvigor Finished :entry:default@PreCheckSyscap… after 2 ms
hvigor Finished :entry:default@CreateBuildProfile… after 3 ms
hvigor Finished :entry:default@BuildNativeWithCmake… after 16 s 174 ms
hvigor Finished :entry:default@GenerateLoaderJson… after 6 ms
hvigor Finished :entry:default@MergeProfile… after 3 ms
hvigor Finished :entry:default@SyscapTransform… after 5 ms
hvigor ERROR: Failed :entry:default@BuildNativeWithNinja
hvigor ERROR: Tools execution failed.

Command failed with exit code 1: E:\opensdk4.1\11\native\build-tools\cmake\bin\ninja.exe -C D:\deskFiles\hapApk\code\app_framework_harmonyOS\entry.cxx\default\default\arm64-v8a

ninja: Entering directory `D:\deskFiles\hapApk\code\app_framework_harmonyOS\entry.cxx\default\default\arm64-v8a’

[1/476] Building C object ocr_core/leptonica/CMakeFiles/leptonica.dir/src/src/graymorph.c.o clang: warning: argument unused during compilation: ‘–gcc-toolchain=E:/opensdk4.1/11/native/llvm’ [-Wunused-command-line-argument]

[2/476] Building C object ocr_core/leptonica/CMakeFiles/leptonica.dir/src/src/gplot.c.o clang: warning: argument unused during compilation: ‘–gcc-toolchain=E:/opensdk4.1/11/native/llvm’ [-Wunused-command-line-argument]

[173/476] Building CXX object ocr_core/tesseract/CMakeFiles/tesseract.dir/src/src/ccstruct/blobs.cpp.o clang++: warning: argument unused during compilation: ‘–gcc-toolchain=E:/opensdk4.1/11/native/llvm’ [-Wunused-command-line-argument]


更多关于HarmonyOS鸿蒙Next中hvigor ERROR: Failed :entry:default@BuildNativeWithNinja...的实战教程也可以访问 https://www.itying.com/category-93-b0.html

3 回复

什么意思

更多关于HarmonyOS鸿蒙Next中hvigor ERROR: Failed :entry:default@BuildNativeWithNinja...的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


在HarmonyOS Next中遇到hvigor构建错误"Failed :entry:default@BuildNativeWithNinja",可能由以下原因导致:

  1. 原生模块依赖缺失或版本冲突
  2. 构建配置文件(如build-profile.json)存在语法错误
  3. Ninja构建工具路径未正确配置
  4. 设备资源不足导致编译中断

检查步骤:

  1. 确认hvigor版本与HarmonyOS SDK匹配
  2. 清理构建缓存(删除/build目录)
  3. 检查native相关模块的CMakeLists.txt配置
  4. 查看详细日志定位具体失败环节

从日志来看,问题出现在BuildNativeWithNinja阶段,主要是编译Leptonica和Tesseract库时出现了警告和错误。以下是关键点分析:

  1. 主要错误是Tools execution failedCommand failed with exit code 1,表明ninja编译过程失败。

  2. 大量出现的警告信息:

clang: warning: argument unused during compilation: '--gcc-toolchain=E:/opensdk4.1/11/native/llvm'

这是工具链参数未被使用的警告,通常不会导致编译失败。

  1. 一个关键错误出现在scale2.c文件:
D:/deskFiles/hapApk/code/app_framework_harmonyOS/entry/src/main/cpp/ocr_core/leptonica/src/src/scale2.c:257:28: warning: floating-point comparison is always false; constant cannot be represented exactly in type 'float'

建议检查:

  1. 确保NDK和工具链版本兼容
  2. 检查Leptonica库的浮点比较逻辑问题
  3. 清理项目后重新构建(删除.cxx和build目录)
  4. 确认native代码依赖库是否完整

失败可能源于代码中的浮点比较问题或环境配置问题。可以尝试先修复scale2.c中的浮点比较警告,这可能是导致后续失败的原因。

回到顶部