请选择 进入手机版 | 继续访问电脑版

积分1659 / 贡献20

提问18答案被采纳67文章41

作者动态

用IDE(5.0.3.900)创建nativec++工程,在dayu200上运行(镜像版本:5.0.0 release)加载不了SO

深开鸿_王石 显示全部楼层 发表于 2024-10-11 10:47:20

【问题描述】

  1. 介绍问题现象和发生的背景:用IDE(5.0.3.900)创建nativec++工程,在dayu200上运行(镜像版本:5.0.0 release)加载不了SO

  2. 相关的代码(请勿使用截图):nativec++的模板代码

  3. 运行结果、错误截图

    直接jscrash,报错为:Module name:com.example.testnative Version:1.0.0 VersionCode:1000000 PreInstalled:No Foreground:Yes Pid:405 Uid:20010046 Reason:TypeError Error name:TypeError Error message:Cannot read property add of undefined Stacktrace: at anonymous (entry/src/main/ets/pages/Index.ets:16:75)

    查看hilog,发现原因为:

    10-11 10:45:28.007 21516-21516 C03f01/NAPI pid-21516 D [(native_async_work.cpp:240)(AsyncAfterWorkCallback)] NativeAsyncWork::AsyncAfterWorkCallback start to execute. 10-11 10:45:28.007 21516-21516 C04200/WindowImpl pid-21516 D (594)SetUIContentInner: NapiSetUIContent: pages/Index 10-11 10:45:28.244 21516-21516 C03f00/ArkCompiler pid-21516 D #08 pc 0000000000042377 /system/lib/platformsdk/libace_napi.z.so 10-11 10:45:28.244 21516-21516 C03f00/ArkCompiler pid-21516 D #12 pc 000000000004b943 /system/lib/platformsdk/libace_napi.z.so 10-11 10:45:28.245 21516-21516 C04200/JsWindowStage pid-21516 I (345)[NAPI]Window [54, testnative0] load content end, ret = 0 10-11 10:45:28.251 21516-21516 C03f01/NAPI pid-21516 D [(native_module_manager.cpp:553)(LoadNativeModule)] moduleName is entry, path is com.example.testnative/entry, relativePath is 10-11 10:45:28.251 21516-21516 C03f01/NAPI pid-21516 D [(native_module_manager.cpp:1222)(IsExistedPath)] pathKey is 'com.example.testnative/entry' 10-11 10:45:28.251 21516-21516 C03f01/NAPI pid-21516 I [(native_module_manager.cpp:605)(LoadNativeModule)] key is default/entry 10-11 10:45:28.251 21516-21516 C03f01/NAPI pid-21516 D [(native_module_manager.cpp:1222)(IsExistedPath)] pathKey is 'default' 10-11 10:45:28.251 21516-21516 C03f01/NAPI pid-21516 D [(native_module_manager.cpp:1222)(IsExistedPath)] pathKey is 'default' 10-11 10:45:28.251 21516-21516 C03f01/NAPI pid-21516 D [(native_module_manager.cpp:645)(LoadNativeModule)] module 'entry' does not in cache 10-11 10:45:28.252 21516-21516 C03f01/NAPI pid-21516 D [(native_module_manager.cpp:1002)(FindNativeModuleByDisk)] moduleName is entry. get primary module path is /system/lib/module/libentry.z.so 10-11 10:45:28.252 21516-21516 C03f01/NAPI pid-21516 D [(native_module_manager.cpp:874)(LoadModuleLibrary)] path: /system/lib/module/libentry.z.so, pathKey: default, isAppModule: 1 10-11 10:45:28.252 21516-21516 C03f01/NAPI pid-21516 D [(native_module_manager.cpp:1222)(IsExistedPath)] pathKey is 'default' 10-11 10:45:28.252 21516-21516 C03f01/NAPI pid-21516 D [(native_module_manager.cpp:129)(EmplaceModuleLib)] modulekey is 'default/entry' 10-11 10:45:28.252 21516-21516 C03f01/NAPI pid-21516 D [(native_module_manager.cpp:1009)(FindNativeModuleByDisk)] try to load secondary module path: /system/lib/module/libentry_napi.z.so 10-11 10:45:28.252 21516-21516 C03f01/NAPI pid-21516 D [(native_module_manager.cpp:874)(LoadModuleLibrary)] path: /system/lib/module/libentry_napi.z.so, pathKey: default, isAppModule: 1 10-11 10:45:28.252 21516-21516 C03f01/NAPI pid-21516 D [(native_module_manager.cpp:1222)(IsExistedPath)] pathKey is 'default' 10-11 10:45:28.252 21516-21516 C03f01/NAPI pid-21516 D [(native_module_manager.cpp:129)(EmplaceModuleLib)] modulekey is 'default/entry' 10-11 10:45:28.252 21516-21516 C03f01/NAPI pid-21516 D [(native_module_manager.cpp:1027)(FindNativeModuleByDisk)] try to load abc module path: /system/etc/abc/entry.abc 10-11 10:45:28.252 21516-21516 C03f01/NAPI pid-21516 E [(native_module_manager.cpp:932)(GetFileBuffer)] /system/etc/abc/entry.abc is not existed. 10-11 10:45:28.252 21516-21516 C03f01/NAPI pid-21516 E [(native_module_manager.cpp:1031)(FindNativeModuleByDisk)] First attempt: load app module failed. Error loading path /system/lib/module/libentry.z.so:No such file or directory 10-11 10:45:28.252 21516-21516 C03f01/NAPI pid-21516 E Second attempt: load app module failed. Error loading path /system/lib/module/libentry_napi.z.so:No such file or directory 10-11 10:45:28.252 21516-21516 C03f01/NAPI pid-21516 E try to load abc file from /system/etc/abc/entry.abc failed 10-11 10:45:28.252 21516-21516 C03f01/NAPI pid-21516 D [(native_module_manager.cpp:663)(LoadNativeModule)] load native module failed 10-11 10:45:28.253 21516-21516 C03f01/NAPI pid-21516 I [(ark_native_engine.cpp:487)(operator())] First attempt: load app module failed. Error loading path /system/lib/module/libentry.z.so:No such file or directory 10-11 10:45:28.253 21516-21516 C03f01/NAPI pid-21516 I Second attempt: load app module failed. Error loading path /system/lib/module/libentry_napi.z.so:No such file or directory 10-11 10:45:28.253 21516-21516 C03f01/NAPI pid-21516 I try to load abc file from /system/etc/abc/entry.abc failed

  4. 我尝试过的解决方法和结果:用之前4.0 编出来的nativeC++hap 可以用

  5. 我想要达到的结果

【运行环境】

硬件: ROM版本: DevEvoStudio版本: SDK版本:

您尚未登录,无法参与评论,登录后可以:
参与开源共建问题交流
认同或收藏高质量问答
获取积分成为开源共建先驱

精彩评论5

battier

沙发 发表于 2024-10-12 12:52:13
运行时崩溃的,大概率跟镜像有关

深开鸿_王石

发表于 2024-10-14 09:31  IP属地: 江苏省盐城市

回复 battier: 用4.0.0.600 IDE创建个nativecpp工程就可以用,镜像没变,就是ide不同

【1 条回复】

马迪

板凳 发表于 2024-10-15 09:40:57
https://developer.huawei.com/con ... ides-V5/ohos-abi-V5

在HarmonyOS的C++工程中,找到C++代码所在项目build-profile.json5文件buildOption/externalNativeOptions字段,添加abiFilters字段,支持一下arm:

  1. {
  2.     “abiType”: 'stageMode',
  3.     “buildOption”: {
  4.         “externalNativeOptions”: {
  5.             "path": "./src/main/cpp/CMakeLists.txt",
  6.             "arguments": "",
  7.             "abiFilters": [
  8.                 "armeabi-v7a",
  9.                 "arm64-v8a"
  10.             ]
  11.         }
  12.     }
  13. }
复制代码

马迪

发表于 2024-10-15 09:59  IP属地: 广东省广州市

回复 马迪: 看下默认编译后build目录下 libs 子目录下so的架构是啥

深开鸿_王石

发表于 2024-10-15 10:11  IP属地: 江苏省盐城市

回复 马迪: 5.0.0Release创建的工程是HarmonyOS的工程,要改两个build-profile.json5,
一个是根目录下的:需要把HarmonyOS和api的配置改成:
"compileSdkVersion": 12,
        "compatibleSdkVersion": 12,
        "runtimeOS": "OpenHarmony",
然后改src目录下的build-profile.json5,在buildOption/externalNativeOptions里加abi:
"abiFilters": [
        "armeabi-v7a",
        "arm64-v8a"
      ],
这样重新sync工程,然后运行就可以了

【2 条回复】
共5 条回复,点击查看

Copyright   ©2023  OpenHarmony开发者论坛  京ICP备2020036654号-3 |技术支持 Discuz!

返回顶部