• Home
Name Date Size #Lines LOC

..--

AppScope/06-May-2025-3532

entry/06-May-2025-746645

hvigor/06-May-2025-3836

screenshots/06-May-2025-

.gitignoreD06-May-2025133 1212

README.mdD06-May-20252.9 KiB7353

build-profile.json5D06-May-20251.4 KiB5857

code-linter.json5D06-May-2025959 3534

hvigorfile.tsD06-May-2025843 225

oh-package.json5D06-May-2025835 2624

ohosTest.mdD06-May-2025594 97

README.md

1# ArkTS同步方式动态加载native模块
2
3### 介绍
4
5本工程主要展示了使用loadNativeModule接口能力进行同步方式加载native模块。该工程中展示的代码详细描述可查如下链接部分。
6
7- [同步方式动态加载native模块](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/js-apis-load-native-module.md)
8
9### 效果预览
10
11| 首页                                                         | 点击HAP加载系统库模块按钮后                                  | 点击HAP加载Native库按钮后                                    |
12| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
13| <img src="./screenshots/JsApisLoadNativeModule1.png" style="zoom:50%;" /> | <img src="./screenshots/JsApisLoadNativeModule2.png" style="zoom:50%;" /> | <img src="./screenshots/JsApisLoadNativeModule3.png" style="zoom:50%;" /> |
14
15### 使用说明
16
171. 运行Index主界面。
182. 页面中Text组件文本呈现LoadNativeModule效果并有两个按钮,分别点击之后第两个个按钮Text文本变化如上图并在工作台打印日志。
193. 运行测试用例JsApisLoadNativeModule.test.ets文件对页面代码进行测试可以全部通过。
20
21### 工程目录
22
23```
24entry/src/
25 ├── main
26 │   ├── cpp
27 │   │   ├── types
28 │   │   │   ├── libentry
29 │   │   │   │   ├── index.d.ts
30 │   │   │   ├── CMakeList.txt
31 │   │   │   ├── napi_init.cpp
32 │   ├── ets
33 │   │   ├── entryability
34 │   │   ├── entrybackupability
35 │   │   ├── pages
36 │   │       ├── Index.ets               // 同步方式动态加载native模块
37 │   ├── module.json5
38 │   └── resources
39 ├── ohosTest
40 │   ├── ets
41 │   │   └── test
42 │   │       ├── Ability.test.ets
43 │   │       ├── JsApisLoadNativeModule.test.ets  // 自动化测试代码
44 │   │       └── List.test
45```
46
47### 相关权限
48
49不涉及。
50
51### 依赖
52
53不涉及。
54
55### 约束与限制
56
571.本示例仅支持标准系统上运行, 支持设备:RK3568。
58
592.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。
60
613.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。
62
63### 下载
64
65如需单独下载本工程,执行如下命令:
66
67````
68git init
69git config core.sparsecheckout true
70echo code/DocsSample/ArkTs/ArkTSRuntime/ArkTSModule/JsApisLoadNativeModule > .git/info/sparse-checkout
71git remote add origin https://gitee.com/openharmony/applications_app_samples.git
72git pull origin master
73````