diff --git a/docs/zh-cn/faqs/figures/faqs-useNormalizedOHMUrl.png b/docs/zh-cn/faqs/figures/faqs-useNormalizedOHMUrl.png new file mode 100644 index 0000000000000000000000000000000000000000..978b2e1ff5865e3275320a91ede8790358f692bf Binary files /dev/null and b/docs/zh-cn/faqs/figures/faqs-useNormalizedOHMUrl.png differ diff --git "a/docs/zh-cn/faqs/\347\274\226\350\257\221\347\261\273FAQ.md" "b/docs/zh-cn/faqs/\347\274\226\350\257\221\347\261\273FAQ.md" index 3a5019eaf8d036c0e7a6d836edd519f1f468dc68..7db0e156fb666c936805ae76c74385360cb34a3c 100644 --- "a/docs/zh-cn/faqs/\347\274\226\350\257\221\347\261\273FAQ.md" +++ "b/docs/zh-cn/faqs/\347\274\226\350\257\221\347\261\273FAQ.md" @@ -271,4 +271,33 @@ target_link_libraries(xxx PUBLIC ${folly_compile_options}) ], "check-action-status":"false" } - ``` \ No newline at end of file + ``` + +## ERROR: Bytecode HARs: [@rnoh/react-native-openharmony] not supported when useNormalizedOHMUrl is not true. + +- 现象 + + ![useNormalizedOHMUrl](./figures/faqs-useNormalizedOHMUrl.png) + +- 原因 + + 从0.72.58版本开始,RNOH的release版本har包中的ets文件会编译成字节码,因此从该版本之后,使用release版本的har包时,需要在工程级的build-profile.json5设置 `useNormalizedOHMUrl: true`。 + +- 解决 + + 在工程级的build-profile.json5设置 `useNormalizedOHMUrl: true`。 + ```diff + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.1(13)", + "runtimeOS": "HarmonyOS", + + "buildOption": { + + "strictMode": { + + "useNormalizedOHMUrl": true + + } + + } + } + ], + ``` \ No newline at end of file diff --git "a/docs/zh-cn/faqs/\350\277\220\350\241\214\347\261\273FAQ.md" "b/docs/zh-cn/faqs/\350\277\220\350\241\214\347\261\273FAQ.md" index dfa77f2cf90fdb9693bf7b3ef68c276621e21bbc..ee4c4b2da4f7659ed617cf1c68ca0f08982378aa 100644 --- "a/docs/zh-cn/faqs/\350\277\220\350\241\214\347\261\273FAQ.md" +++ "b/docs/zh-cn/faqs/\350\277\220\350\241\214\347\261\273FAQ.md" @@ -76,3 +76,28 @@ **参数说明详见**[文档](https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/ide-hvigor-build-profile-V5)。 手动解决:需要将 **RN** 源码目录 `oh_modules/@rnoh/react-native-openharmony/src/main/cpp/third-party/prebuilt` 下的内容整体拷贝到 `oh_modules/@rnoh/react-native-openharmony/libs` 目录下。 + +### 运行后报错:cannot find record '&@rnoh/react-native-openharmony/generated/ts&0.72.58',please check the request path.'/data/storage/el1/bundle/entry/ets/modules.abc'. + +- 现象 + + 运行 **RN** 应用时,jscrash,提示:`cannot find record '&@rnoh/react-native-openharmony/generated/ts&0.72.58',please check the request path.'/data/storage/el1/bundle/entry/ets/modules.abc'.`。 + +- 原因 + + 这个 jscrash 一般是使用 RNOH 0.72.58 及之后的 release 版本har包时遇到,具体原因如下: + 1. 业务方执行Codegen时会将ArkTS组件或Turbomodule的类型声明生成到 oh_modules/@rnoh/react-native-openharmony/generated 目录下; + 1. 在使用时也能支持导入到该目录; + 1. 但ohmurl的标准import路径没有指向文件,导致运行时找不到该record。 + +- 解决 + + react-native-openharmony-cli 0.0.29 及之后的版本中 **codegen-harmony** 命令提供了 `--ets-output-path` 参数,通过该参数将 Codegen 生成的 ets 文件生成在源码目录下,而不是在 oh_modules 目录下,然后重新调整相关文件的导入路径。如: + ```diff + - "codegen": "react-native codegen-harmony --cpp-output-path ../NativeProject/entry/src/main/cpp/generated --rnoh-module-path ../NativeProject/entry/oh_modules/@rnoh/react-native-openharmony --no-safety-check" + + "codegen": "react-native codegen-harmony --cpp-output-path ../NativeProject/entry/src/main/cpp/generated --ets-output-path ../NativeProject/entry/src/main/ets --no-safety-check" + ``` + ```diff + - import { RNC } from "@rnoh/react-native-openharmony/generated/ts" + + import { RNC } from "./generated/ts" + ``` \ No newline at end of file