OpenHarmony开发者论坛
标题:
用IDE(5.0.3.900)创建nativec++工程,在dayu200上运行(镜像版本:5.0.0 release)加载不了SO
[打印本页]
作者:
深开鸿_王石
时间:
2024-10-11 10:47
标题:
用IDE(5.0.3.900)创建nativec++工程,在dayu200上运行(镜像版本:5.0.0 release)加载不了SO
[md]### 【问题描述】
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版本:
[/md]
作者:
battier
时间:
2024-10-12 12:52
运行时崩溃的,大概率跟镜像有关
作者:
深开鸿_王石
时间:
2024-10-14 09:31
回复
battier
: 用4.0.0.600 IDE创建个nativecpp工程就可以用,镜像没变,就是ide不同
作者:
马迪
时间:
2024-10-15 09:40
https://developer.huawei.com/con ... ides-V5/ohos-abi-V5
在HarmonyOS的C++工程中,找到C++代码所在项目build-profile.json5文件buildOption/externalNativeOptions字段,添加abiFilters字段,支持一下arm:
{
“abiType”: 'stageMode',
“buildOption”: {
“externalNativeOptions”: {
"path": "./src/main/cpp/CMakeLists.txt",
"arguments": "",
"abiFilters": [
"armeabi-v7a",
"arm64-v8a"
]
}
}
}
复制代码
作者:
马迪
时间:
2024-10-15 09:59
回复
马迪
: 看下默认编译后build目录下 libs 子目录下so的架构是啥
作者:
深开鸿_王石
时间:
2024-10-15 10:11
回复
马迪
: 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工程,然后运行就可以了
欢迎光临 OpenHarmony开发者论坛 (https://forums.openharmony.cn/)
Powered by Discuz! X3.5