From a4525cec076cfbc6a0058ad36f47a5579dc5158a Mon Sep 17 00:00:00 2001 From: huangxiaoyao <976125628@qq.com> Date: Thu, 26 Dec 2024 20:32:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=B5=8B=E8=83=BD=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huangxiaoyao <976125628@qq.com> --- README.md | 4 +- ...50\257\225dart\344\273\243\347\240\201.md" | 7 +++- ...70\345\205\263\351\227\256\351\242\230.md" | 24 +++++++++++- ...70\345\205\263\351\227\256\351\242\230.md" | 38 +++++++++++++++++++ ...70\345\205\263\351\227\256\351\242\230.md" | 14 +++++++ 5 files changed, 82 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1bd5630b..d5538f7e 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,9 @@ | [clock_test](https://gitee.com/openharmony-sig/flutter_samples/tree/master/ohos/clock_test) | ohos/clock_test | 计时器demo,可计时,查看历史计时记录和一些详细数据 | | [dio_test](https://gitee.com/openharmony-sig/flutter_samples/tree/master/ohos/dio_test) | ohos/dio_test | 测试demo合集 | | [event_bus_test](https://gitee.com/openharmony-sig/flutter_samples/tree/master/ohos/event_bus_test) | ohos/event_bus_test | 事件驱动demo | -| [flutter_page_sample1](https://gitee.com/openharmony-sig/flutter_samples/tree/master/ohos/flutter_page_sample1) | ohos/flutter_page_sample1 | 页面跳转demo | +| [flutter_page_sample1](https://gitee.com/openharmony-sig/flutter_samples/tree/master/ohos/flutter_page_sample1) | ohos/flutter_page_sample1 | route路由页面跳转demo | | [flutter_page_sample2](https://gitee.com/openharmony-sig/flutter_samples/tree/master/ohos/flutter_page_sample2) | ohos/flutter_page_sample2 | FlutterEntry的使用示例 | -| [multiple_flutters_ohos](https://gitee.com/openharmony-sig/flutter_samples/tree/master/add_to_app/multiple_flutters) | add_to_app/multiple_flutters/multiple_flutters_ohos | FlutterEngineGroup使用示例 | +| [multiple_flutters_ohos](https://gitee.com/openharmony-sig/flutter_samples/tree/master/add_to_app/multiple_flutters) | add_to_app/multiple_flutters/multiple_flutters_ohos | FlutterEngineGroup多引擎使用示例,可监听生命周期 | | [flutter_svg_test](https://gitee.com/openharmony-sig/flutter_samples/tree/master/ohos/flutter_svg_test ) | ohos/flutter_svg_test | svg图片demo | | [http_parser_test](https://gitee.com/openharmony-sig/flutter_samples/tree/master/ohos/http_parser_test) | ohos/http_parser_test | http解析demo | | [http_test](https://gitee.com/openharmony-sig/flutter_samples/tree/master/ohos/http_test) | ohos/http_test | http网页请求 demo | diff --git "a/ohos/docs/06_debug/\350\260\203\350\257\225dart\344\273\243\347\240\201.md" "b/ohos/docs/06_debug/\350\260\203\350\257\225dart\344\273\243\347\240\201.md" index 6bd90139..e5dd9142 100644 --- "a/ohos/docs/06_debug/\350\260\203\350\257\225dart\344\273\243\347\240\201.md" +++ "b/ohos/docs/06_debug/\350\260\203\350\257\225dart\344\273\243\347\240\201.md" @@ -1,8 +1,11 @@ # 调试dart代码 - ets 代码使用 DevEco-Studio 进行调试。 -- dart 代码可以使用 vscode 和 Android Studio 进行调试。 - - flutter鸿蒙化版本调试时,需要加上参数,如: `--local-engine=/Users/xxx/ohos/engine/src/out/ohos_debug_unopt_arm64` +- dart 代码可以使用 vscode 和 Android Studio 进行调试,点击运行按钮启动调试即可。 + +# 指定本地引擎调试 dart 代码 + + 调试时需要加上参数,如: `--local-engine=/Users/xxx/ohos/engine/src/out/ohos_debug_unopt_arm64` ## 使用 vscode 调试 dart 代码 diff --git "a/ohos/docs/08_FAQ/ohos\344\273\243\347\240\201\345\274\200\345\217\221\347\233\270\345\205\263\351\227\256\351\242\230.md" "b/ohos/docs/08_FAQ/ohos\344\273\243\347\240\201\345\274\200\345\217\221\347\233\270\345\205\263\351\227\256\351\242\230.md" index 09d32f94..f30950d1 100644 --- "a/ohos/docs/08_FAQ/ohos\344\273\243\347\240\201\345\274\200\345\217\221\347\233\270\345\205\263\351\227\256\351\242\230.md" +++ "b/ohos/docs/08_FAQ/ohos\344\273\243\347\240\201\345\274\200\345\217\221\347\233\270\345\205\263\351\227\256\351\242\230.md" @@ -78,4 +78,26 @@ export struct DemoComponent { 参考: [demo](https://onebox.huawei.com/p/b3e5806b9ce3683c8c13b237ec319294) -跑demo_plugin_asset\example\ohos可以跑起来界面,界面“flutter图片资源展示”下会显示图片,“原生图片资源展示”下未显示图片,相关代码在 demo_plugin_asset\example\lib\main.dart、demo_plugin_asset\ohos\src\main\ets\components\plugin\DemoPluginAssetPlugin.ets \ No newline at end of file +跑demo_plugin_asset\example\ohos可以跑起来界面,界面“flutter图片资源展示”下会显示图片,“原生图片资源展示”下未显示图片,相关代码在 demo_plugin_asset\example\lib\main.dart、demo_plugin_asset\ohos\src\main\ets\components\plugin\DemoPluginAssetPlugin.ets + +## flutter inappwebview设置高度后网页内容被拉伸 + +问题分析:目前OS原生web画布限制范围是在2400以下,超过2400的高度原生web无法加载 + +解决方案:将px类型的参数转换为dp类型 + +``` +class _MyHomePageState extends State { + double _height = 10.0; + + void _changeHeight(double newHeight) { + setState(() { + double devicePixelRatio = MediaQuery.of(context).devicePixelRatio; + _height = newHeight / devicePixelRatio; + }); + } + + @override + Widget build(BuildContext context) { +... +``` diff --git "a/ohos/docs/08_FAQ/ohos\345\272\224\347\224\250\347\274\226\350\257\221\347\233\270\345\205\263\351\227\256\351\242\230.md" "b/ohos/docs/08_FAQ/ohos\345\272\224\347\224\250\347\274\226\350\257\221\347\233\270\345\205\263\351\227\256\351\242\230.md" index 78e26bb7..e5849a53 100644 --- "a/ohos/docs/08_FAQ/ohos\345\272\224\347\224\250\347\274\226\350\257\221\347\233\270\345\205\263\351\227\256\351\242\230.md" +++ "b/ohos/docs/08_FAQ/ohos\345\272\224\347\224\250\347\274\226\350\257\221\347\233\270\345\205\263\351\227\256\351\242\230.md" @@ -139,3 +139,41 @@ hvigor install success. 解决:需要指定versionName和versionCode可以在build指令时加上指定版本 参考:flutter build hap --build-name=4.0.3 --build-number=10000 + +## 应用编译报错flutter工程和依赖的插件工程不是在同一个磁盘 + +日志信息: + +```log +ohpm ERROR: Found exception: xxx is not in the same file system as the current project, reached retry limit or non retryable error encountered. +``` + +问题分析:flutter工程和依赖的插件工程不是在同一个磁盘,这种情况下就会出现这个报错信息。 + +解决方案:Windows环境下flutter工程和依赖的插件工程需要在同一个磁盘。 + +## Note that you need plugins to import files that are not JavaScript + +日志信息: + +```log +> hvigor ERROR: Failed :entry:default@CompileArkTS... +> hvigor ERROR: Unexpected token (Note that you need plugins to import files that are not JavaScript) +``` + +问题分析:DevEco Studio由低版本升级到高版本,这种情况下就会出现这个报错信息。 + +解决方案: + +修改 `hvigor-config.json5` 配置文件 + +```yaml +{ + "modelVersion": "5.0.0", + "dependencies": { + }, + "properties": { + "ohos.nativeResolver": false + } +} +``` diff --git "a/ohos/docs/08_FAQ/ohos\350\277\220\350\241\214\347\233\270\345\205\263\351\227\256\351\242\230.md" "b/ohos/docs/08_FAQ/ohos\350\277\220\350\241\214\347\233\270\345\205\263\351\227\256\351\242\230.md" index d69e01db..ea3c137d 100644 --- "a/ohos/docs/08_FAQ/ohos\350\277\220\350\241\214\347\233\270\345\205\263\351\227\256\351\242\230.md" +++ "b/ohos/docs/08_FAQ/ohos\350\277\220\350\241\214\347\233\270\345\205\263\351\227\256\351\242\230.md" @@ -19,3 +19,17 @@ SourceMap is not initialized yet 可能原因: /data/storage/el1/bundle/entry/ets/modules.abc 可能是SDK与镜像不匹配导致abc文件无法正常运行,该现象根本原因是SDK工具与镜像版本不匹配,推荐使用匹配的SDK与手机镜像版本;请提供当前手机版本 和 ide版本截图。 若版本是匹配的,请提供完整日志来。 + +## app包安装成功后,运行闪退 + +日志信息: + +```log +#20 at attachToNative (entry|@ohos/flutter_ohos|1.0.0-115ba6b8be|src/main/ets/embedding/engine/FlutterNapi.ts:60:1) +#21 at attachToNapi (entry|@ohos/flutter_ohos|1.0.0-115ba6b8be|src/main/ets/embedding/engine/FlutterEngine.ts:97:1) +#22 at init (entry|@ohos/flutter_ohos|1.0.0-115ba6b8be|src/main/ets/embedding/engine/FlutterEngine.ts:88:1) +``` + +问题分析:上线包使用了debug版本的flutter.har,这种情况下就会出现这个报错信息。 + +解决方案:建议上线前重新打包release版本的flutter.har,执行命令 `flutter build hap --release`。 -- Gitee