HarmonyOS鸿蒙Next中@react-native-oh-tpl/react-native-gesture-handler无法使用

HarmonyOS鸿蒙Next中@react-native-oh-tpl/react-native-gesture-handler无法使用 rn内通过桥接的方式使用 @react-native-oh-tpl/react-native-gesture-handler 时,通过步骤接入到鸿蒙侧之后,报错:

cke_1856.png

报错信息:

FAILED: /Users/a1/Desktop/Code/harmony/entry/build/default/intermediates/cmake/default/obj/arm64-v8a/librnoh_app.so 
: &ld.lld: error: undefined symbol: rnoh::RNGestureHandlerModule::RNGestureHandlerModule(rnoh::ArkTSTurboModule::Context, std::__n1::basic_string<char, std::__n1::char_traits<char>, std::__n1::allocator<char>>)
>>> referenced by shared_ptr.h:294 (/Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/native/llvm/bin/../include/libcxx-ohos/include/c++/v1/__memory/shared_ptr.h:294)
clang-15: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
A 'undefined symbol' error has occurred.
* Try the following:
  > Troubleshoot the errors according to the following guidelines.
  > More info: https://developer.huawei.com/consumer/cn/doc/harmonyos-faqs/faqs-compiling-and-building-116

插件安装流程

https://github.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-gesture-handler.md

相应的issue: https://github.com/react-native-oh-library/react-native-harmony-gesture-handler/issues/58

SDK: 5.0.0(12) rnoh:0.72.38-3

rn:0.72.5

插件版本:2.14.16


更多关于HarmonyOS鸿蒙Next中@react-native-oh-tpl/react-native-gesture-handler无法使用的实战教程也可以访问 https://www.itying.com/category-93-b0.html

2 回复

在HarmonyOS鸿蒙Next中,@react-native-oh-tpl/react-native-gesture-handler无法使用的原因是当前该库尚未适配鸿蒙Next的ArkTS/ArkUI架构。鸿蒙Next不再兼容Android生态,原React Native组件需基于鸿蒙原生API重构。可检查华为官方提供的鸿蒙版React Native组件库更新状态,或使用鸿蒙原生手势处理API替代实现。

更多关于HarmonyOS鸿蒙Next中@react-native-oh-tpl/react-native-gesture-handler无法使用的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


这个错误是由于链接器无法找到 RNGestureHandlerModule 符号导致的。根据报错信息,问题出现在构建 librnoh_app.so 时,缺少对应的模块实现。

可能的原因和解决方向:

  1. 检查模块注册:确保在鸿蒙侧的模块注册表中正确注册了 RNGestureHandlerModule。模块名称和路径需要与 RN 侧的调用一致。

  2. 依赖版本兼容性:确认使用的 @react-native-oh-tpl/react-native-gesture-handler 版本与当前 RNOH(0.72.38-3)和 RN(0.72.5)兼容。某些版本可能存在符号导出或接口不一致的问题。

  3. 构建配置:检查 CMakeLists.txt 或相关构建脚本,确认是否正确引入了手势处理器的库文件(如 .a.so),并且链接路径配置无误。

  4. 符号可见性:确认模块的构造函数 RNGestureHandlerModule 在鸿蒙侧被正确定义和导出,C++ 命名空间(如 rnoh::)需要与声明完全匹配。

建议参考提供的 GitHub issue 链接中的讨论,查看是否有已知的修复方案或临时解决措施。

回到顶部