- 复制 flutter_module 源码 和 flutter相关文件
javascript
cp -r my_flutter_module/.ohos/flutter_module MyApplication/
cp my_flutter_module/.ohos/har/flutter.har MyApplication/har/flutter.har
- 修改 MyApplication/build-profile.json5,modules下新增如下内容
javascript
// 以下为新增内容
{
"name": "flutter_module",
"srcPath": "./flutter_module",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
}
- 修改 MyApplication/oh-package.json5
javascript
"dependencies": {
"@ohos/flutter_module": "./flutter_module",
"@ohos/flutter_ohos": "file:./har/flutter.har"
},
"overrides": {
"@ohos/flutter_ohos": "./har/flutter.har"
}
- 使用 Deveco Studio 配置 MyApplication 的签名
- 运行 MyApplication
注意:由于没有真机,在模拟器运行会报如下错误。
Device info:emulator
Build info:emulator 5.0.0.65(SP73DEVC00E65R4P11log)
Fingerprint:f997680853fc6a9c5af3acd2878ed5936dc031867c36b8d1f7b42b8980fa8252
Module name:com.example.myapplication
Version:1.0.0
VersionCode:1000000
PreInstalled:No
Foreground:Yes
Timestamp:2024-10-01 20:34:34.447
Pid:17838
Uid:20020054
Process name:com.example.myapplication
Process life time:2s
Reason:Signal:SIGTRAP(TRAP_BRKPT)@0x0000007f96711dd0
Fault thread info:
Tid:17879, Name:1.raster
#00 pc 00000000023d1dd0 /data/storage/el1/bundle/libs/arm64/libflutter.so(103fd5b90568edc09203e114faebbaedd8f359d3)