HarmonyOS 鸿蒙Next ReactNative release打包CMake报错

HarmonyOS 鸿蒙Next ReactNative release打包CMake报错 加载bundle正常,尝试使用release包报错,参考教程最后的“release包使用”: https://gitee.com/openharmony-sig/ohos_react_native/blob/master/docs/zh-cn/%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA.md#release%E5%8C%85%E4%BD%BF%E7%94%A8

下面附上各阶段的报错

运行报错一(完全复制教程代码):

> hvigor ERROR: Failed :entry:default@BuildNativeWithCmake...
> hvigor ERROR: Exceptions happened while executing: CMake Warning (dev) at CMakeLists.txt:1 (project):
  cmake_minimum_required() should be called prior to this top-level project()
  call.  Please see the cmake-commands(7) manual for usage documentation of
  both commands.
This warning is for project developers.  Use -Wno-dev to suppress it.

Not searching for unused variables given on the command line.
CMake Deprecation Warning at CMakeLists.txt:2 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Error: File /Users/eastbuy/DevecostudioProjects/MyRNApplication/entry/oh_modules/@rnoh/react-native-openharmony/src/main/include/third-party/folly/CMake/folly-config.h.cmake does not exist.
CMake Error at CMakeLists.txt:65 (configure_file):
  configure_file Problem configuring file


Experimental C-API architecture enabled
-- Configuring incomplete, errors occurred!

> hvigor ERROR: BUILD FAILED in 1 s 39 ms 

参考描述,将 cmake_minimum_required(VERSION 3.4.1) 版本改为3.5,并移动到第一行,运行报错二:

> hvigor ERROR: Failed :entry:default@BuildNativeWithCmake...
> hvigor ERROR: Exceptions happened while executing: CMake Error: File /Users/eastbuy/DevecostudioProjects/MyRNApplication/entry/oh_modules/@rnoh/react-native-openharmony/src/main/include/third-party/folly/CMake/folly-config.h.cmake does not exist.
CMake Error at CMakeLists.txt:65 (configure_file):
  configure_file Problem configuring file


Experimental C-API architecture enabled
Not searching for unused variables given on the command line.
-- Configuring incomplete, errors occurred!

> hvigor ERROR: BUILD FAILED in 1 s 76 ms 

看报错内容是folly/CMake/folly-config.h.cmake does not exist.

有大佬解决过release打包报错的问题吗?


更多关于HarmonyOS 鸿蒙Next ReactNative release打包CMake报错的实战教程也可以访问 https://www.itying.com/category-93-b0.html

1 回复

更多关于HarmonyOS 鸿蒙Next ReactNative release打包CMake报错的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


在HarmonyOS鸿蒙Next中,使用React Native进行release打包时,若遇到CMake报错,可能涉及以下原因:

  1. CMake版本兼容性:鸿蒙Next的NDK可能对CMake版本有特定要求。版本不匹配会导致编译错误。
  2. NDK配置问题:React Native在鸿蒙平台上依赖NDK进行本地代码编译。若NDK路径或配置不正确,CMake无法定位工具链或库文件。
  3. 依赖库缺失或版本不匹配:鸿蒙Next可能有特定的本地库依赖,若项目中依赖的库未正确配置或版本不兼容,CMake会报错。
  4. CMakeLists.txt配置错误:React Native项目中的CMakeLists.txt文件可能包含不兼容的配置项,或未正确指定鸿蒙平台的相关参数。

解决方法:

  • 确保CMake版本与鸿蒙Next的NDK要求一致。
  • 检查NDK路径及环境变量配置,确保正确。
  • 更新或调整项目依赖库,确保与鸿蒙Next兼容。
  • 检查并修正CMakeLists.txt文件中的配置项,适配鸿蒙平台。

此问题通常通过调整相关配置或升级依赖解决。

回到顶部