From 3fb135d1c6c9855aa20679b85be54d031db21b69 Mon Sep 17 00:00:00 2001 From: kemin <541416002@qq.com> Date: Wed, 7 Aug 2024 23:44:05 +0800 Subject: [PATCH 01/38] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=BB=91=E5=8A=A8?= =?UTF-8?q?=E9=98=88=E5=80=BC=20Signed-off-by:=20keminLuo=20<541416002@qq.?= =?UTF-8?q?com>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/flutter/lib/src/gestures/constants.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/gestures/constants.dart b/packages/flutter/lib/src/gestures/constants.dart index 2a09403e61..ecff376c7f 100644 --- a/packages/flutter/lib/src/gestures/constants.dart +++ b/packages/flutter/lib/src/gestures/constants.dart @@ -58,7 +58,7 @@ const Duration kZoomControlsTimeout = Duration(milliseconds: 3000); /// be a drag. // This value was empirically derived. We started at 8.0 and increased it to // 18.0 after getting complaints that it was too difficult to hit targets. -const double kTouchSlop = 5.0; // Logical pixels +const double kTouchSlop = 4.0; // Logical pixels /// The distance a touch has to travel for the framework to be confident that /// the gesture is a paging gesture. (Currently not used, because paging uses a -- Gitee From a8408d13caf5ad027e88acdbad8454edfe0adc3c Mon Sep 17 00:00:00 2001 From: wuzhiming Date: Thu, 8 Aug 2024 16:27:08 +0800 Subject: [PATCH 02/38] =?UTF-8?q?update:=20=E6=9C=AA=E6=8C=87=E5=AE=9A=20`?= =?UTF-8?q?build-number`=20=E5=92=8C=20`build-name`=20=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E4=BB=8E=20`pubspec.yaml`=20=E4=B8=AD?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=BD=93=E5=89=8D=E7=89=88=E6=9C=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wuzhiming --- packages/flutter_tools/lib/src/ohos/hvigor_utils.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/flutter_tools/lib/src/ohos/hvigor_utils.dart b/packages/flutter_tools/lib/src/ohos/hvigor_utils.dart index 437d9a330c..ea3fa101af 100644 --- a/packages/flutter_tools/lib/src/ohos/hvigor_utils.dart +++ b/packages/flutter_tools/lib/src/ohos/hvigor_utils.dart @@ -145,15 +145,15 @@ String getFlavor(File buildProfileFile, String? flavor) { void updateProjectVersion(FlutterProject project, BuildInfo? buildInfo) { final File targetFile = project.ohos.getAppJsonFile(); - if (targetFile.existsSync() && buildInfo != null) { + if (targetFile.existsSync()) { final String? buildNumber = validatedBuildNumberForPlatform( TargetPlatform.ohos_arm, - buildInfo.buildNumber, + buildInfo?.buildNumber ?? project.manifest.buildNumber, globals.logger, ); final String? buildName = validatedBuildNameForPlatform( TargetPlatform.ohos_arm, - buildInfo.buildName, + buildInfo?.buildName ?? project.manifest.buildName, globals.logger, ); -- Gitee From cbc8243e3277a5b9f8a2d7f954dba643777fae0b Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Thu, 8 Aug 2024 11:53:37 +0800 Subject: [PATCH 03/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9ohos=E5=B7=A5=E7=A8=8B?= =?UTF-8?q?=E7=BA=A7=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E6=97=B6=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E7=9B=B8=E5=AF=B9=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hezhengyi --- .../lib/src/ohos/ohos_plugins_manager.dart | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/packages/flutter_tools/lib/src/ohos/ohos_plugins_manager.dart b/packages/flutter_tools/lib/src/ohos/ohos_plugins_manager.dart index e4e8e2ddf5..0a89fe2dd6 100644 --- a/packages/flutter_tools/lib/src/ohos/ohos_plugins_manager.dart +++ b/packages/flutter_tools/lib/src/ohos/ohos_plugins_manager.dart @@ -51,7 +51,7 @@ Future checkOhosPluginsDependencies(FlutterProject flutterProject) async { if (flutterProject.isModule) { dependencies[plugin.name] = 'file:$absolutePath'; } else { - final String relativePath = globals.fs.path.relative(absolutePath, from: globals.fs.path.dirname(packageFile.path)); + final String relativePath = _relative(absolutePath, from: globals.fs.path.dirname(packageFile.path)); dependencies[plugin.name] = 'file:$relativePath'; } } @@ -86,13 +86,14 @@ Future addPluginsModules(FlutterProject flutterProject) async { } modules.add({ 'name': plugin.name, - 'srcPath': globals.fs.path.join(plugin.path, OhosPlugin.kConfigKey), + 'srcPath': _relative( + globals.fs.path.join(plugin.path, OhosPlugin.kConfigKey), + from: flutterProject.ohos.ohosRoot.path, + ), 'targets': >[ { 'name': 'default', - 'applyToProducts': [ - 'default' - ] + 'applyToProducts': ['default'] } ], }); @@ -119,9 +120,12 @@ Future addFlutterModuleAndPluginsSrcOverrides(FlutterProject flutterProjec final Map overrides = config['overrides'] as Map? ?? {}; for (final Plugin plugin in plugins) { - overrides[plugin.name] = globals.fs.path.join(plugin.path, OhosPlugin.kConfigKey); + overrides[plugin.name] = _relative( + globals.fs.path.join(plugin.path, OhosPlugin.kConfigKey), + from: flutterProject.ohos.ohosRoot.path, + ); } - final String relativePath = globals.fs.path.relative(flutterProject.ohos.flutterModuleDirectory.path, from: flutterProject.ohos.ohosRoot.path); + final String relativePath = _relative(flutterProject.ohos.flutterModuleDirectory.path, from: flutterProject.ohos.ohosRoot.path); overrides['@ohos/flutter_module'] = 'file:./$relativePath'; overrides['@ohos/flutter_ohos'] = 'file:./har/flutter.har'; final String configNew = const JsonEncoder.withIndent(' ').convert(config); @@ -189,3 +193,7 @@ Future addFlutterModuleAndPluginsOverrides(FlutterProject flutterProject) final String configNew = const JsonEncoder.withIndent(' ').convert(config); packageFile.writeAsStringSync(configNew, flush: true); } + +String _relative(String path, {String? from}) { + return globals.fs.path.relative(path, from: from).replaceAll(r'\', '/'); +} -- Gitee From c6fbac2bf2469f9e132460562edee2a4304085bd Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Fri, 9 Aug 2024 19:24:29 +0800 Subject: [PATCH 04/38] =?UTF-8?q?ohos=E8=B0=83=E7=94=A8=E7=9A=84hvigorw?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E5=91=BD=E4=BB=A4=E5=A2=9E=E5=8A=A0buildMode?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hezhengyi --- packages/flutter_tools/lib/src/ohos/hvigor.dart | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/flutter_tools/lib/src/ohos/hvigor.dart b/packages/flutter_tools/lib/src/ohos/hvigor.dart index 81e25f8eab..cd59457d29 100644 --- a/packages/flutter_tools/lib/src/ohos/hvigor.dart +++ b/packages/flutter_tools/lib/src/ohos/hvigor.dart @@ -148,6 +148,7 @@ Future assembleHap( required String ohosRootPath, required String hvigorwPath, required String flavor, + required String buildMode, Logger? logger}) async { final List command = [ hvigorwPath, @@ -155,6 +156,8 @@ Future assembleHap( 'assembleHap', '-p', 'product=$flavor', + '-p', + 'buildMode=$buildMode', '--no-daemon', ]; return hvigorwTask(command, @@ -169,6 +172,7 @@ Future assembleApp( required String ohosRootPath, required String hvigorwPath, required String flavor, + required String buildMode, Logger? logger}) async { final List command = [ hvigorwPath, @@ -176,6 +180,8 @@ Future assembleApp( 'assembleApp', '-p', 'product=$flavor', + '-p', + 'buildMode=$buildMode', '--no-daemon', ]; return hvigorwTask(command, @@ -190,6 +196,8 @@ Future assembleHar( required String workPath, required String hvigorwPath, required String moduleName, + required String buildMode, + String product = 'default', Logger? logger}) async { final List command = [ hvigorwPath, @@ -199,7 +207,7 @@ Future assembleHar( '-p', 'module=$moduleName', '-p', - 'product=default', + 'product=$product', 'assembleHar', '--no-daemon', ]; @@ -216,6 +224,7 @@ Future assembleHsp( required String hvigorwPath, required String moduleName, required String flavor, + required String buildMode, Logger? logger}) async { final List command = [ hvigorwPath, @@ -226,6 +235,8 @@ Future assembleHsp( 'module=$moduleName', '-p', 'product=$flavor', + '-p', + 'buildMode=$buildMode', 'assembleHsp', '--no-daemon', ]; @@ -477,6 +488,7 @@ class OhosHvigorBuilder implements OhosBuilder { hvigorwPath: hvigorwPath, flavor: getFlavor( _ohosProject.getBuildProfileFile(), ohosBuildInfo.buildInfo.flavor), + buildMode: ohosBuildInfo.buildInfo.modeName, logger: _logger); status.stop(); if (errorCode != 0) { @@ -620,6 +632,7 @@ class OhosHvigorBuilder implements OhosBuilder { flavor: getFlavor( _ohosProject.getBuildProfileFile(), ohosBuildInfo.buildInfo.flavor), hvigorwPath: hvigorwPath, + buildMode: ohosBuildInfo.buildInfo.modeName, logger: _logger); status.stop(); if (errorCode1 != 0) { @@ -706,6 +719,7 @@ class OhosHvigorBuilder implements OhosBuilder { workPath: ohosProjectPath, moduleName: moduleName, hvigorwPath: hvigorwPath, + buildMode: ohosBuildInfo.buildInfo.modeName, logger: logger); if (errorCode != 0) { throwToolExit('Oops! assembleHars failed! please check log.'); @@ -753,6 +767,7 @@ class OhosHvigorBuilder implements OhosBuilder { hvigorwPath: hvigorwPath, flavor: getFlavor( project.ohos.getBuildProfileFile(), ohosBuildInfo.buildInfo.flavor), + buildMode: ohosBuildInfo.buildInfo.modeName, logger: logger); if (errorCode != 0) { throwToolExit('Oops! assembleHsps failed! please check log.'); -- Gitee From 57065693ffe1a082b01cd0cc1bb849cdd87863a9 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Fri, 9 Aug 2024 19:56:21 +0800 Subject: [PATCH 05/38] =?UTF-8?q?=E6=9B=B4=E6=96=B0readme=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: hezhengyi --- README.en.md | 28 ++++++++++++++++++++++++++-- README.md | 28 ++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/README.en.md b/README.en.md index 87a9d2cc92..de839b0634 100644 --- a/README.en.md +++ b/README.en.md @@ -166,5 +166,29 @@ Attachment: [Flutter third-party library adaptation plan](https://docs.qq.com/sh 3. Execute `flutter run -d $DEVICE --debug` 3. Additional information: If a similar error occurs while running Android or iOS, you can also try restoring the environment variable FLUTTER_STORAGE_BASE_URL , clearing the cache, and then running again. -12. After the ROM update in Beta 2 version, anonymous memory requests are no longer supported. - 1. Reference Documents: [Explanation of Change in Anonymous Memory Execution Permission Control Policy](https://developer.huawei.com/consumer/cn/doc/harmonyos-roadmap-V5/changelogs-for-all-apps-b031-V5#%E5%8C%BF%E5%90%8D%E5%86%85%E5%AD%98%E6%89%A7%E8%A1%8C%E6%9D%83%E9%99%90%E7%AE%A1%E6%8E%A7%E7%AD%96%E7%95%A5%E5%8F%98%E6%9B%B4%E8%AF%B4%E6%98%8E) +12. After the ROM update of Beta 2 version, it no longer supports requesting anonymous memory with execution permission, resulting in debug crashing. + 1. Solution: Update flutter_flutter to a version after a44b8a6d (2024-07-25). + 2. Key logs: + + ``` + #20 at attachToNative (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterNapi.ets:78:32) + #21 at attachToNapi (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine.ets:144:5) + #22 at init (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine.ets:133:7) + ``` + +13. DevEco-Studio(5.0.3.600 Beta3),windows版本编译flutter应用报错 + 1. Solution: Update flutter_flutter to a version after c6fbac2b (2024-08-09). + 2. Key logs: + + ``` + hvigor ERROR: Schema validate failed. + Detail: Please check the following fields. + { + instancePath: 'modules[2].srcPath', + keyword: 'pattern', + params: { pattern: '^(\\./|\\.\\./)[\\s\\S]+$' }, + message: 'must match pattern "^(\\./|\\.\\./)[\\s\\S]+$"', + } + ``` + +[More FAQ](https://gitee.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/08_FAQ/README.md) diff --git a/README.md b/README.md index 6979fba390..4807cfb3dd 100644 --- a/README.md +++ b/README.md @@ -180,5 +180,29 @@ Flutter SDK 仓库 4. 运行 `flutter run -d $DEVICE --debug` 3. 补充信息: 运行android或ios出现类似错误,也可以尝试还原环境变量 FLUTTER_STORAGE_BASE_URL ,清除缓存后重新运行。 -11. Beta2版本的ROM更新后,不再支持申请匿名内存。 - 1. 参考文档:[匿名内存执行权限管控策略变更说明](https://developer.huawei.com/consumer/cn/doc/harmonyos-roadmap-V5/changelogs-for-all-apps-b031-V5#%E5%8C%BF%E5%90%8D%E5%86%85%E5%AD%98%E6%89%A7%E8%A1%8C%E6%9D%83%E9%99%90%E7%AE%A1%E6%8E%A7%E7%AD%96%E7%95%A5%E5%8F%98%E6%9B%B4%E8%AF%B4%E6%98%8E) +11. Beta2版本的ROM更新后,不再支持申请有执行权限的匿名内存,导致debug运行闪退。 + 1. 解决方案:更新 flutter_flutter 到 a44b8a6d (2024-07-25) 之后的版本。 + 2. 关键日志: + + ``` + #20 at attachToNative (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterNapi.ets:78:32) + #21 at attachToNapi (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine.ets:144:5) + #22 at init (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine.ets:133:7) + ``` + +12. DevEco-Studio(5.0.3.600 Beta3),windows版本编译flutter应用报错 + 1. 解决方案:更新 flutter_flutter 到 c6fbac2b (2024-08-09) 之后的版本。 + 2. 关键日志: + + ``` + hvigor ERROR: Schema validate failed. + Detail: Please check the following fields. + { + instancePath: 'modules[2].srcPath', + keyword: 'pattern', + params: { pattern: '^(\\./|\\.\\./)[\\s\\S]+$' }, + message: 'must match pattern "^(\\./|\\.\\./)[\\s\\S]+$"', + } + ``` + +[更多FAQ](https://gitee.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/08_FAQ/README.md) -- Gitee From 24ae22527213882928c4758bfbb7fa5ac326e2b2 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Sun, 11 Aug 2024 18:31:32 +0800 Subject: [PATCH 06/38] Update engine.ohos.version to 6384c631 Signed-off-by: hezhengyi --- bin/internal/engine.ohos.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/internal/engine.ohos.version b/bin/internal/engine.ohos.version index 3a4a29908e..f0303587b8 100644 --- a/bin/internal/engine.ohos.version +++ b/bin/internal/engine.ohos.version @@ -1 +1 @@ -0c6972dab55072672d164e08f71122e1b24324ae +6384c63172783d7e59f5c1dd9bad359266e359c3 \ No newline at end of file -- Gitee From dc05635e278637e22267533c3239250abdf518ba Mon Sep 17 00:00:00 2001 From: huangxiaoyao <976125628@qq.com> Date: Mon, 12 Aug 2024 10:07:17 +0800 Subject: [PATCH 07/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9ffi=20plugin=E6=8F=92?= =?UTF-8?q?=E4=BB=B6ohos=E7=B3=BB=E7=BB=9F=E7=9A=84=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huangxiaoyao <976125628@qq.com> --- .../templates/plugin_ffi/lib/projectName.dart.tmpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/flutter_tools/templates/plugin_ffi/lib/projectName.dart.tmpl b/packages/flutter_tools/templates/plugin_ffi/lib/projectName.dart.tmpl index 70a6e59f7a..572e3e8ef0 100644 --- a/packages/flutter_tools/templates/plugin_ffi/lib/projectName.dart.tmpl +++ b/packages/flutter_tools/templates/plugin_ffi/lib/projectName.dart.tmpl @@ -11,7 +11,7 @@ import 'dart:async'; import 'dart:ffi'; import 'dart:io'; import 'dart:isolate'; - +import 'package:flutter/foundation.dart'; import '{{projectName}}_bindings_generated.dart'; /// A very short-lived native function. @@ -48,7 +48,7 @@ final DynamicLibrary _dylib = () { if (Platform.isMacOS || Platform.isIOS) { return DynamicLibrary.open('$_libName.framework/$_libName'); } - if (Platform.isAndroid || Platform.isLinux || Platform.isOhos) { + if (Platform.isAndroid || Platform.isLinux || defaultTargetPlatform == TargetPlatform.ohos) { return DynamicLibrary.open('lib$_libName.so'); } if (Platform.isWindows) { -- Gitee From eb11c7c274b48aee89fd34dd62de16c12cc8d316 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Mon, 12 Aug 2024 21:35:00 +0800 Subject: [PATCH 08/38] =?UTF-8?q?=E8=B0=83=E6=95=B4ohos=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E7=9A=84=E7=BC=96=E8=AF=91=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hezhengyi --- .../flutter_tools/lib/src/ohos/hvigor.dart | 4 ++-- .../lib/src/ohos/ohos_plugins_manager.dart | 22 ++++++------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/packages/flutter_tools/lib/src/ohos/hvigor.dart b/packages/flutter_tools/lib/src/ohos/hvigor.dart index cd59457d29..bea955b09b 100644 --- a/packages/flutter_tools/lib/src/ohos/hvigor.dart +++ b/packages/flutter_tools/lib/src/ohos/hvigor.dart @@ -65,7 +65,7 @@ void checkPlatformEnvironment(String environment, Logger? logger) { } void copyFlutterAssets(String orgPath, String desPath, Logger? logger) { - logger?.printStatus('copy from "$orgPath" to "$desPath"'); + logger?.printTrace('copy from "$orgPath" to "$desPath"'); final LocalFileSystem localFileSystem = globals.localFileSystem; copyDirectory( localFileSystem.directory(orgPath), localFileSystem.directory(desPath)); @@ -395,7 +395,7 @@ void cleanAndCopyFlutterRuntime( ensureParentExists(desHarPath); final File originHarFile = globals.localFileSystem.file(localEngineHarPath); originHarFile.copySync(desHarPath); - logger?.printStatus('copy from "$localEngineHarPath" to "$desHarPath"'); + logger?.printTrace('copy from "$localEngineHarPath" to "$desHarPath"'); logger?.printTrace('copy flutter runtime to project end'); } diff --git a/packages/flutter_tools/lib/src/ohos/ohos_plugins_manager.dart b/packages/flutter_tools/lib/src/ohos/ohos_plugins_manager.dart index 0a89fe2dd6..e4e8e2ddf5 100644 --- a/packages/flutter_tools/lib/src/ohos/ohos_plugins_manager.dart +++ b/packages/flutter_tools/lib/src/ohos/ohos_plugins_manager.dart @@ -51,7 +51,7 @@ Future checkOhosPluginsDependencies(FlutterProject flutterProject) async { if (flutterProject.isModule) { dependencies[plugin.name] = 'file:$absolutePath'; } else { - final String relativePath = _relative(absolutePath, from: globals.fs.path.dirname(packageFile.path)); + final String relativePath = globals.fs.path.relative(absolutePath, from: globals.fs.path.dirname(packageFile.path)); dependencies[plugin.name] = 'file:$relativePath'; } } @@ -86,14 +86,13 @@ Future addPluginsModules(FlutterProject flutterProject) async { } modules.add({ 'name': plugin.name, - 'srcPath': _relative( - globals.fs.path.join(plugin.path, OhosPlugin.kConfigKey), - from: flutterProject.ohos.ohosRoot.path, - ), + 'srcPath': globals.fs.path.join(plugin.path, OhosPlugin.kConfigKey), 'targets': >[ { 'name': 'default', - 'applyToProducts': ['default'] + 'applyToProducts': [ + 'default' + ] } ], }); @@ -120,12 +119,9 @@ Future addFlutterModuleAndPluginsSrcOverrides(FlutterProject flutterProjec final Map overrides = config['overrides'] as Map? ?? {}; for (final Plugin plugin in plugins) { - overrides[plugin.name] = _relative( - globals.fs.path.join(plugin.path, OhosPlugin.kConfigKey), - from: flutterProject.ohos.ohosRoot.path, - ); + overrides[plugin.name] = globals.fs.path.join(plugin.path, OhosPlugin.kConfigKey); } - final String relativePath = _relative(flutterProject.ohos.flutterModuleDirectory.path, from: flutterProject.ohos.ohosRoot.path); + final String relativePath = globals.fs.path.relative(flutterProject.ohos.flutterModuleDirectory.path, from: flutterProject.ohos.ohosRoot.path); overrides['@ohos/flutter_module'] = 'file:./$relativePath'; overrides['@ohos/flutter_ohos'] = 'file:./har/flutter.har'; final String configNew = const JsonEncoder.withIndent(' ').convert(config); @@ -193,7 +189,3 @@ Future addFlutterModuleAndPluginsOverrides(FlutterProject flutterProject) final String configNew = const JsonEncoder.withIndent(' ').convert(config); packageFile.writeAsStringSync(configNew, flush: true); } - -String _relative(String path, {String? from}) { - return globals.fs.path.relative(path, from: from).replaceAll(r'\', '/'); -} -- Gitee From 83422d9b6afd84c318186c4eab3f78fdbb2a372b Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Tue, 13 Aug 2024 09:06:19 +0800 Subject: [PATCH 09/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hezhengyi --- README.en.md | 15 --------------- README.md | 15 --------------- 2 files changed, 30 deletions(-) diff --git a/README.en.md b/README.en.md index de839b0634..4838e7096d 100644 --- a/README.en.md +++ b/README.en.md @@ -176,19 +176,4 @@ Attachment: [Flutter third-party library adaptation plan](https://docs.qq.com/sh #22 at init (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine.ets:133:7) ``` -13. DevEco-Studio(5.0.3.600 Beta3),windows版本编译flutter应用报错 - 1. Solution: Update flutter_flutter to a version after c6fbac2b (2024-08-09). - 2. Key logs: - - ``` - hvigor ERROR: Schema validate failed. - Detail: Please check the following fields. - { - instancePath: 'modules[2].srcPath', - keyword: 'pattern', - params: { pattern: '^(\\./|\\.\\./)[\\s\\S]+$' }, - message: 'must match pattern "^(\\./|\\.\\./)[\\s\\S]+$"', - } - ``` - [More FAQ](https://gitee.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/08_FAQ/README.md) diff --git a/README.md b/README.md index 4807cfb3dd..f934136f5a 100644 --- a/README.md +++ b/README.md @@ -190,19 +190,4 @@ Flutter SDK 仓库 #22 at init (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine.ets:133:7) ``` -12. DevEco-Studio(5.0.3.600 Beta3),windows版本编译flutter应用报错 - 1. 解决方案:更新 flutter_flutter 到 c6fbac2b (2024-08-09) 之后的版本。 - 2. 关键日志: - - ``` - hvigor ERROR: Schema validate failed. - Detail: Please check the following fields. - { - instancePath: 'modules[2].srcPath', - keyword: 'pattern', - params: { pattern: '^(\\./|\\.\\./)[\\s\\S]+$' }, - message: 'must match pattern "^(\\./|\\.\\./)[\\s\\S]+$"', - } - ``` - [更多FAQ](https://gitee.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/08_FAQ/README.md) -- Gitee From af90abfef24b1562e74a33885c89a68f2cb85683 Mon Sep 17 00:00:00 2001 From: kemin <541416002@qq.com> Date: Tue, 13 Aug 2024 16:36:42 +0800 Subject: [PATCH 10/38] =?UTF-8?q?complex=5Flayout=E9=87=87=E7=94=A8API12,?= =?UTF-8?q?=E5=B9=B6=E4=B8=94profile=E6=A8=A1=E5=BC=8F=E4=B8=8D=E6=89=93?= =?UTF-8?q?=E5=8D=B0debug=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: kemin <541416002@qq.com> --- .../complex_layout/ohos/build-profile.json5 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/dev/benchmarks/complex_layout/ohos/build-profile.json5 b/dev/benchmarks/complex_layout/ohos/build-profile.json5 index 5fcb3dc466..7ceb22efee 100644 --- a/dev/benchmarks/complex_layout/ohos/build-profile.json5 +++ b/dev/benchmarks/complex_layout/ohos/build-profile.json5 @@ -20,8 +20,16 @@ { "name": "default", "signingConfig": "default", - "compatibleSdkVersion": "4.1.0(11)", - "runtimeOS": "HarmonyOS", + "compatibleSdkVersion": "5.0.0(12)", + "runtimeOS": "HarmonyOS" + } + ], + "buildModeSet": [ + { + "name": "profile", + "buildOption": { + "debuggable": false + } } ] }, -- Gitee From 4c0ad382789b9e8d673b770c81a15eb2aad52893 Mon Sep 17 00:00:00 2001 From: SimpleLove520 <1960997571@qq.com> Date: Tue, 13 Aug 2024 20:02:41 +0800 Subject: [PATCH 11/38] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=94=AE=E7=9B=98?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E5=8D=95=E5=8F=8C=E5=BC=95=E5=8F=B7logicalke?= =?UTF-8?q?y=E8=BF=94=E5=9B=9E=E4=B8=8D=E5=AF=B9=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: SimpleLove520 <1960997571@qq.com> --- packages/flutter/lib/src/services/keyboard_maps.g.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/flutter/lib/src/services/keyboard_maps.g.dart b/packages/flutter/lib/src/services/keyboard_maps.g.dart index 35a430cbd9..0b36a710be 100644 --- a/packages/flutter/lib/src/services/keyboard_maps.g.dart +++ b/packages/flutter/lib/src/services/keyboard_maps.g.dart @@ -603,6 +603,7 @@ const Map kOhosToLogicalKey = 2061: LogicalKeyboardKey.backslash, 2062: LogicalKeyboardKey.semicolon, // 2063: LogicalKeyboardKey.apostrophe, + 2063: LogicalKeyboardKey.quote, 2064: LogicalKeyboardKey.slash, 2067: LogicalKeyboardKey.contextMenu, 2466: LogicalKeyboardKey.compose, -- Gitee From 7314dd96bc73546cf1e8a9b556e5a2813159e8c1 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Tue, 13 Aug 2024 21:50:56 +0800 Subject: [PATCH 12/38] Update engine.ohos.version to 8ea76e22 Signed-off-by: hezhengyi --- bin/internal/engine.ohos.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/internal/engine.ohos.version b/bin/internal/engine.ohos.version index f0303587b8..1d2532340f 100644 --- a/bin/internal/engine.ohos.version +++ b/bin/internal/engine.ohos.version @@ -1 +1 @@ -6384c63172783d7e59f5c1dd9bad359266e359c3 \ No newline at end of file +8ea76e226b34ee7d07a90bb94655916d2b206c8c \ No newline at end of file -- Gitee From a430ac9bee68f573e3606c825ad54874c1a27585 Mon Sep 17 00:00:00 2001 From: lihiu868 Date: Wed, 14 Aug 2024 23:04:35 +0800 Subject: [PATCH 13/38] =?UTF-8?q?=E5=87=8F=E5=B0=8F=E6=9C=80=E5=B0=8F?= =?UTF-8?q?=E6=BB=91=E5=8A=A8=E8=B7=9D=E7=A6=BB=E9=98=88=E5=80=BC=EF=BC=8C?= =?UTF-8?q?=E6=8F=90=E5=8D=87=E5=BA=94=E7=94=A8=E5=93=8D=E5=BA=94=E9=80=9F?= =?UTF-8?q?=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lihiu868 --- packages/flutter/lib/src/gestures/constants.dart | 2 +- packages/flutter/lib/src/widgets/scroll_activity.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/flutter/lib/src/gestures/constants.dart b/packages/flutter/lib/src/gestures/constants.dart index ecff376c7f..6d83ad3769 100644 --- a/packages/flutter/lib/src/gestures/constants.dart +++ b/packages/flutter/lib/src/gestures/constants.dart @@ -58,7 +58,7 @@ const Duration kZoomControlsTimeout = Duration(milliseconds: 3000); /// be a drag. // This value was empirically derived. We started at 8.0 and increased it to // 18.0 after getting complaints that it was too difficult to hit targets. -const double kTouchSlop = 4.0; // Logical pixels +const double kTouchSlop = 18.0; // Logical pixels /// The distance a touch has to travel for the framework to be confident that /// the gesture is a paging gesture. (Currently not used, because paging uses a diff --git a/packages/flutter/lib/src/widgets/scroll_activity.dart b/packages/flutter/lib/src/widgets/scroll_activity.dart index b8b7b1fbee..57db46a2fd 100644 --- a/packages/flutter/lib/src/widgets/scroll_activity.dart +++ b/packages/flutter/lib/src/widgets/scroll_activity.dart @@ -359,7 +359,7 @@ class ScrollDragController implements Drag { ) * offset.sign; } } else { - return 0.0; + return offset < 0 ? offset - 1.0 : offset + 1.0; } } } -- Gitee From d55f899a8a783a5533b5755e538de061b572a21f Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Fri, 16 Aug 2024 09:49:27 +0800 Subject: [PATCH 14/38] Update engine.ohos.version to d80b57e4 Signed-off-by: hezhengyi --- bin/internal/engine.ohos.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/internal/engine.ohos.version b/bin/internal/engine.ohos.version index 1d2532340f..4d5e57799e 100644 --- a/bin/internal/engine.ohos.version +++ b/bin/internal/engine.ohos.version @@ -1 +1 @@ -8ea76e226b34ee7d07a90bb94655916d2b206c8c \ No newline at end of file +d80b57e4d18e54fa3d28194eb13cd4002a36f97c \ No newline at end of file -- Gitee From df7399531f8524247c8df08d9f24b4479f1c5c29 Mon Sep 17 00:00:00 2001 From: huangxiaoyao <976125628@qq.com> Date: Sat, 17 Aug 2024 10:14:48 +0800 Subject: [PATCH 15/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9md=E6=96=87=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 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f934136f5a..df9575a5d3 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,9 @@ Flutter SDK 仓库 ## 仓库说明 本仓库是基于Flutter SDK对于OpenHarmony平台的兼容拓展,可支持IDE或者终端使用Flutter Tools指令编译和构建OpenHarmony应用程序。 +## 开发文档 +文档入口:https://gitee.com/openharmony-sig/flutter_samples/tree/master/ohos/docs + ## 环境依赖 * 开发系统 @@ -37,7 +40,7 @@ Flutter SDK 仓库 export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn ``` - 3. `--local-engine` 成为可选参数,可以不传。 + 3. `--local-engine` 成为可选参数,可以不传,默认从云端获取。 - 使用示例:`--local-engine=src/out/` - 可在该路径下载[编译产物](https://docs.qq.com/sheet/DUnljRVBYUWZKZEtF?tab=BB08J2) - engine路径指向需带上 `src/out` 目录 @@ -190,4 +193,6 @@ Flutter SDK 仓库 #22 at init (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine.ets:133:7) ``` +12. 构建Hap命令直接执行`flutter build hap`即可,不再需要`--local-engine`参数,直接从云端获取编译产物。 + [更多FAQ](https://gitee.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/08_FAQ/README.md) -- Gitee From 8942c395273b778bae88373e1a58e11688377a82 Mon Sep 17 00:00:00 2001 From: SimpleLove520 <1960997571@qq.com> Date: Sun, 18 Aug 2024 10:18:59 +0800 Subject: [PATCH 16/38] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=89=B9=E5=AE=9A?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E4=BD=BF=E7=94=A8material3=E5=9C=A8debug?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E4=B8=8B=E4=BC=9A=E9=97=AA=E9=80=80=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: SimpleLove520 <1960997571@qq.com> --- packages/flutter/lib/src/material/theme_data.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/flutter/lib/src/material/theme_data.dart b/packages/flutter/lib/src/material/theme_data.dart index ddea89c87f..408d66e737 100644 --- a/packages/flutter/lib/src/material/theme_data.dart +++ b/packages/flutter/lib/src/material/theme_data.dart @@ -474,7 +474,7 @@ class ThemeData with Diagnosticable { pageTransitionsTheme ??= const PageTransitionsTheme(); scrollbarTheme ??= const ScrollbarThemeData(); visualDensity ??= VisualDensity.adaptivePlatformDensity; - useMaterial3 ??= false; + useMaterial3 = false; final bool useInkSparkle = platform == TargetPlatform.android && !kIsWeb; splashFactory ??= useMaterial3 ? useInkSparkle ? InkSparkle.splashFactory : InkRipple.splashFactory @@ -661,7 +661,7 @@ class ThemeData with Diagnosticable { platform: platform, scrollbarTheme: scrollbarTheme, splashFactory: splashFactory, - useMaterial3: useMaterial3, + useMaterial3: false, visualDensity: visualDensity, // COLOR canvasColor: canvasColor, @@ -2037,7 +2037,7 @@ class ThemeData with Diagnosticable { platform: platform ?? this.platform, scrollbarTheme: scrollbarTheme ?? this.scrollbarTheme, splashFactory: splashFactory ?? this.splashFactory, - useMaterial3: useMaterial3 ?? this.useMaterial3, + useMaterial3: false, visualDensity: visualDensity ?? this.visualDensity, // COLOR canvasColor: canvasColor ?? this.canvasColor, @@ -2237,7 +2237,7 @@ class ThemeData with Diagnosticable { platform: t < 0.5 ? a.platform : b.platform, scrollbarTheme: ScrollbarThemeData.lerp(a.scrollbarTheme, b.scrollbarTheme, t), splashFactory: t < 0.5 ? a.splashFactory : b.splashFactory, - useMaterial3: t < 0.5 ? a.useMaterial3 : b.useMaterial3, + useMaterial3: false, visualDensity: VisualDensity.lerp(a.visualDensity, b.visualDensity, t), // COLOR canvasColor: Color.lerp(a.canvasColor, b.canvasColor, t)!, -- Gitee From 3a168ca01e91d7e14c407439e788e2b36517be95 Mon Sep 17 00:00:00 2001 From: SimpleLove520 <1960997571@qq.com> Date: Sun, 18 Aug 2024 14:39:28 +0800 Subject: [PATCH 17/38] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=89=B9=E5=AE=9A?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E4=BD=BF=E7=94=A8material3=E5=9C=A8debug?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E4=B8=8B=E4=BC=9A=E9=97=AA=E9=80=80=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: SimpleLove520 <1960997571@qq.com> --- packages/flutter/lib/src/material/theme_data.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/flutter/lib/src/material/theme_data.dart b/packages/flutter/lib/src/material/theme_data.dart index 408d66e737..44c0d49855 100644 --- a/packages/flutter/lib/src/material/theme_data.dart +++ b/packages/flutter/lib/src/material/theme_data.dart @@ -474,7 +474,7 @@ class ThemeData with Diagnosticable { pageTransitionsTheme ??= const PageTransitionsTheme(); scrollbarTheme ??= const ScrollbarThemeData(); visualDensity ??= VisualDensity.adaptivePlatformDensity; - useMaterial3 = false; + useMaterial3 = (platform == TargetPlatform.ohos) ? false : (useMaterial3 ?? false); final bool useInkSparkle = platform == TargetPlatform.android && !kIsWeb; splashFactory ??= useMaterial3 ? useInkSparkle ? InkSparkle.splashFactory : InkRipple.splashFactory @@ -661,7 +661,7 @@ class ThemeData with Diagnosticable { platform: platform, scrollbarTheme: scrollbarTheme, splashFactory: splashFactory, - useMaterial3: false, + useMaterial3: useMaterial3, visualDensity: visualDensity, // COLOR canvasColor: canvasColor, @@ -2037,7 +2037,7 @@ class ThemeData with Diagnosticable { platform: platform ?? this.platform, scrollbarTheme: scrollbarTheme ?? this.scrollbarTheme, splashFactory: splashFactory ?? this.splashFactory, - useMaterial3: false, + useMaterial3: ((platform ?? this.platform ) == TargetPlatform.ohos) ? false : (useMaterial3 ?? this.useMaterial3), visualDensity: visualDensity ?? this.visualDensity, // COLOR canvasColor: canvasColor ?? this.canvasColor, @@ -2237,7 +2237,7 @@ class ThemeData with Diagnosticable { platform: t < 0.5 ? a.platform : b.platform, scrollbarTheme: ScrollbarThemeData.lerp(a.scrollbarTheme, b.scrollbarTheme, t), splashFactory: t < 0.5 ? a.splashFactory : b.splashFactory, - useMaterial3: false, + useMaterial3: ((t < 0.5 ? a.platform : b.platform) == TargetPlatform.ohos) ? false : (t < 0.5 ? a.useMaterial3 : b.useMaterial3), visualDensity: VisualDensity.lerp(a.visualDensity, b.visualDensity, t), // COLOR canvasColor: Color.lerp(a.canvasColor, b.canvasColor, t)!, -- Gitee From ec8aa799c06b24769aece810108c76f3e3cc652e Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Sun, 18 Aug 2024 20:56:59 +0800 Subject: [PATCH 18/38] Update engine.ohos.version to fd909238 Signed-off-by: hezhengyi --- bin/internal/engine.ohos.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/internal/engine.ohos.version b/bin/internal/engine.ohos.version index 4d5e57799e..d1b22c5b43 100644 --- a/bin/internal/engine.ohos.version +++ b/bin/internal/engine.ohos.version @@ -1 +1 @@ -d80b57e4d18e54fa3d28194eb13cd4002a36f97c \ No newline at end of file +fd90923880b8d1fe028f009db2b4fab7a6d54da1 \ No newline at end of file -- Gitee From dba4aa8ec1e6190260366b60bd2e5e953b8740ae Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Tue, 20 Aug 2024 21:37:57 +0800 Subject: [PATCH 19/38] Update engine.ohos.version to b20cf365 Signed-off-by: hezhengyi --- bin/internal/engine.ohos.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/internal/engine.ohos.version b/bin/internal/engine.ohos.version index d1b22c5b43..9cc8edf2f3 100644 --- a/bin/internal/engine.ohos.version +++ b/bin/internal/engine.ohos.version @@ -1 +1 @@ -fd90923880b8d1fe028f009db2b4fab7a6d54da1 \ No newline at end of file +b20cf3656c5203a3a52bd3be474cc89af0f6c6e0 \ No newline at end of file -- Gitee From cd221ca0edc1d87c024f236f7598c7d7d581cfee Mon Sep 17 00:00:00 2001 From: liuja <542689970@qq.com> Date: Wed, 21 Aug 2024 15:29:05 +0800 Subject: [PATCH 20/38] =?UTF-8?q?=E6=9B=B4=E6=96=B0md=E6=96=87=E6=A1=A3--?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=87=A0=E4=B8=AA=E5=B8=B8=E8=A7=81=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuja <542689970@qq.com> --- README.md | 261 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 161 insertions(+), 100 deletions(-) diff --git a/README.md b/README.md index df9575a5d3..9acbdc1bc3 100644 --- a/README.md +++ b/README.md @@ -1,74 +1,76 @@ -Flutter SDK 仓库 -============== +# Flutter SDK 仓库 原始仓来源:https://github.com/flutter/flutter ## 仓库说明 -本仓库是基于Flutter SDK对于OpenHarmony平台的兼容拓展,可支持IDE或者终端使用Flutter Tools指令编译和构建OpenHarmony应用程序。 + +本仓库是基于 Flutter SDK 对于 OpenHarmony 平台的兼容拓展,可支持 IDE 或者终端使用 Flutter Tools 指令编译和构建 OpenHarmony 应用程序。 ## 开发文档 + 文档入口:https://gitee.com/openharmony-sig/flutter_samples/tree/master/ohos/docs ## 环境依赖 -* 开发系统 +- 开发系统 + + Flutter Tools 指令目前已支持在 Linux、Mac 和 Windows 下使用。 - Flutter Tools指令目前已支持在Linux、Mac和Windows下使用。 +- 环境配置 + **请优先从[鸿蒙套件列表](https://developer.harmonyos.com/deveco-developer-suite/enabling/kit?currentPage=1&pageSize=100)下载配套开发工具,暂不支持非该渠道下载的套件** + _下列环境变量配置,类 Unix 系统(Linux、Mac),下可直接参照配置,Windows 下环境变量配置请在‘编辑系统环境变量’中设置_ -* 环境配置 - **请优先从[鸿蒙套件列表](https://developer.harmonyos.com/deveco-developer-suite/enabling/kit?currentPage=1&pageSize=100)下载配套开发工具,暂不支持非该渠道下载的套件** - *下列环境变量配置,类Unix系统(Linux、Mac),下可直接参照配置,Windows下环境变量配置请在‘编辑系统环境变量’中设置* + 1. 配置 HarmonyOS SDK 和环境变量 - 1. 配置HarmonyOS SDK和环境变量 - * API12, deveco-studio-5.0.3.300 或 command-line-tools-5.0.3.300 - * 配置 Java17 - * 配置环境变量 (SDK, node, ohpm, hvigor) + - API12, deveco-studio-5.0.3.300 或 command-line-tools-5.0.3.300 + - 配置 Java17 + - 配置环境变量 (SDK, node, ohpm, hvigor) - ```sh - export TOOL_HOME=/Applications/DevEco-Studio-5.0.3.300.app/Contents # mac环境 - export DEVECO_SDK_HOME=$TOOL_HOME/sdk # command-line-tools/sdk - export PATH=$TOOL_HOME/tools/ohpm/bin:$PATH # command-line-tools/ohpm/bin - export PATH=$TOOL_HOME/tools/hvigor/bin:$PATH # command-line-tools/hvigor/bin - export PATH=$TOOL_HOME/tools/node/bin:$PATH # command-line-tools/tool/node/bin - ``` + ```sh + export TOOL_HOME=/Applications/DevEco-Studio-5.0.3.300.app/Contents # mac环境 + export DEVECO_SDK_HOME=$TOOL_HOME/sdk # command-line-tools/sdk + export PATH=$TOOL_HOME/tools/ohpm/bin:$PATH # command-line-tools/ohpm/bin + export PATH=$TOOL_HOME/tools/hvigor/bin:$PATH # command-line-tools/hvigor/bin + export PATH=$TOOL_HOME/tools/node/bin:$PATH # command-line-tools/tool/node/bin + ``` - 2. 通过代码工具下载当前仓库代码`git clone https://gitee.com/openharmony-sig/flutter_flutter.git`,指定dev或master分支,并配置环境 + 2. 通过代码工具下载当前仓库代码`git clone https://gitee.com/openharmony-sig/flutter_flutter.git`,指定 dev 或 master 分支,并配置环境 ```sh export PATH=/bin:$PATH export PUB_HOSTED_URL=https://pub.flutter-io.cn export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn ``` - - 3. `--local-engine` 成为可选参数,可以不传,默认从云端获取。 - - 使用示例:`--local-engine=src/out/` - - 可在该路径下载[编译产物](https://docs.qq.com/sheet/DUnljRVBYUWZKZEtF?tab=BB08J2) - - engine路径指向需带上 `src/out` 目录 - 上述所有环境变量的配置(Windows下环境变量配置请在‘编辑系统环境变量’中设置),可参考下面的示例(其中user和具体代码路径请替换成实际路径): + 3. `--local-engine` 成为可选参数,可以不传,默认从云端获取。 - ```sh - # 国内镜像 - export PUB_HOSTED_URL=https://pub.flutter-io.cn - export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn + - 使用示例:`--local-engine=src/out/` + - 可在该路径下载[编译产物](https://docs.qq.com/sheet/DUnljRVBYUWZKZEtF?tab=BB08J2) + - engine 路径指向需带上 `src/out` 目录 - # 拉取下来的flutter_flutter/bin目录 - export PATH=/home//ohos/flutter_flutter/bin:$PATH + 上述所有环境变量的配置(Windows 下环境变量配置请在‘编辑系统环境变量’中设置),可参考下面的示例(其中 user 和具体代码路径请替换成实际路径): - # HamonyOS SDK - export TOOL_HOME=/Applications/DevEco-Studio-5.0.3.300.app/Contents # mac环境 - export DEVECO_SDK_HOME=$TOOL_HOME/sdk # command-line-tools/sdk - export PATH=$TOOL_HOME/tools/ohpm/bin:$PATH # command-line-tools/ohpm/bin - export PATH=$TOOL_HOME/tools/hvigor/bin:$PATH # command-line-tools/hvigor/bin - export PATH=$TOOL_HOME/tools/node/bin:$PATH # command-line-tools/tool/node/bin - ``` + ```sh + # 国内镜像 + export PUB_HOSTED_URL=https://pub.flutter-io.cn + export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn + + # 拉取下来的flutter_flutter/bin目录 + export PATH=/home//ohos/flutter_flutter/bin:$PATH + # HamonyOS SDK + export TOOL_HOME=/Applications/DevEco-Studio-5.0.3.300.app/Contents # mac环境 + export DEVECO_SDK_HOME=$TOOL_HOME/sdk # command-line-tools/sdk + export PATH=$TOOL_HOME/tools/ohpm/bin:$PATH # command-line-tools/ohpm/bin + export PATH=$TOOL_HOME/tools/hvigor/bin:$PATH # command-line-tools/hvigor/bin + export PATH=$TOOL_HOME/tools/node/bin:$PATH # command-line-tools/tool/node/bin + ``` ## 构建步骤 -1. 运行 `flutter doctor -v` 检查环境变量配置是否正确,**Futter**与**OpenHarmony**应都为ok标识,若两处提示缺少环境,按提示补上相应环境即可。 +1. 运行 `flutter doctor -v` 检查环境变量配置是否正确,**Futter**与**OpenHarmony**应都为 ok 标识,若两处提示缺少环境,按提示补上相应环境即可。 -2. 创建工程与编译命令,编译产物在\/ohos/entry/build/default/outputs/default/entry-default-signed.hap下。 +2. 创建工程与编译命令,编译产物在\/ohos/entry/build/default/outputs/default/entry-default-signed.hap 下。 ``` # 创建工程 @@ -79,45 +81,46 @@ Flutter SDK 仓库 flutter build hap --release ``` -3. 通过`flutter devices`指令发现ohos设备之后,使用 `hdc -t install `进行安装。 +3. 通过`flutter devices`指令发现 ohos 设备之后,使用 `hdc -t install `进行安装。 4. 也可直接使用下列指令运行: + ``` # 示例:flutter run [--local-engine=/src/out/ohos_debug_unopt_arm64] -d flutter run --debug -d ``` -5. 构建app包命令: +5. 构建 app 包命令: + ``` # 示例:flutter build app --release [--local-engine=/src/out/ohos_release_arm64] local-engine为可选项 flutter build app --release ``` - -## 已兼容OpenHarmony开发的指令列表 -| 指令名称 | 指令描述 | 使用说明 | -| ------- | ------- |-------------------------------------------------------------------| -| doctor | 环境检测 | flutter doctor | -| config | 环境配置 | flutter config --\ \ | -| create | 创建新项目 | flutter create --platforms ohos,android,ios --org \ \ | -| create | 创建module模板 | flutter create -t module \ | -| create | 创建plugin模板 | flutter create -t plugin --platforms ohos,android,ios \ | -| create | 创建plugin_ffi模板 | flutter create -t plugin_ffi --platforms ohos,android,ios \ | -| devices | 已连接设备查找 | flutter devices | -| install | 应用安装 | flutter install -t \ \ | -| assemble | 资源打包 | flutter assemble | -| build | 测试应用构建 | flutter build hap --debug [--target-platform ohos-arm64] [--local-engine=\<兼容ohos的debug engine产物路径\>] | -| build | 正式应用构建 | flutter build hap --release [--target-platform ohos-arm64] [--local-engine=\<兼容ohos的release engine产物路径\>] | -| run | 应用运行 | flutter run [--local-engine=\<兼容ohos的engine产物路径\>] | -| attach | 调试模式 | flutter attach | -| screenshot | 截屏 | flutter screenshot | - -附:[Flutter三方库适配计划](https://docs.qq.com/sheet/DVVJDWWt1V09zUFN2) - +## 已兼容 OpenHarmony 开发的指令列表 + +| 指令名称 | 指令描述 | 使用说明 | +| ---------- | -------------------- | -------------------------------------------------------------------------------------------------------------------- | +| doctor | 环境检测 | flutter doctor | +| config | 环境配置 | flutter config --\ \ | +| create | 创建新项目 | flutter create --platforms ohos,android,ios --org \ \ | +| create | 创建 module 模板 | flutter create -t module \ | +| create | 创建 plugin 模板 | flutter create -t plugin --platforms ohos,android,ios \ | +| create | 创建 plugin_ffi 模板 | flutter create -t plugin_ffi --platforms ohos,android,ios \ | +| devices | 已连接设备查找 | flutter devices | +| install | 应用安装 | flutter install -t \ \ | +| assemble | 资源打包 | flutter assemble | +| build | 测试应用构建 | flutter build hap --debug [--target-platform ohos-arm64] [--local-engine=\<兼容 ohos 的 debug engine 产物路径\>] | +| build | 正式应用构建 | flutter build hap --release [--target-platform ohos-arm64] [--local-engine=\<兼容 ohos 的 release engine 产物路径\>] | +| run | 应用运行 | flutter run [--local-engine=\<兼容 ohos 的 engine 产物路径\>] | +| attach | 调试模式 | flutter attach | +| screenshot | 截屏 | flutter screenshot | + +附:[Flutter 三方库适配计划](https://docs.qq.com/sheet/DVVJDWWt1V09zUFN2) ## 常见问题 -1. 切换FLUTTER_STORAGE_BASE_URL后需删除\/bin/cache 目录,并在项目中执行flutter clean后再运行 +1. 切换 FLUTTER_STORAGE_BASE_URL 后需删除\/bin/cache 目录,并在项目中执行 flutter clean 后再运行 2. 若出现报错:`The SDK license agreement is not accepted`,参考执行以下命令后再次编译: @@ -125,32 +128,35 @@ Flutter SDK 仓库 ./ohsdkmgr install ets:9 js:9 native:9 previewer:9 toolchains:9 --sdk-directory='/home/xc/code/sdk/ohos-sdk/' --accept-license ``` -3. 如果你使用的是DevEco Studio的Beta版本,编译工程时遇到“must have required property 'compatibleSdkVersion', location: demo/ohos/build-profile.json5:17:11"错误,请参考《DevEco Studio环境配置指导.docx》中的‘6 创建工程和运行Hello World’【配置插件】章节修改 hvigor/hvigor-config.json5文件。 +3. 如果你使用的是 DevEco Studio 的 Beta 版本,编译工程时遇到“must have required property 'compatibleSdkVersion', location: demo/ohos/build-profile.json5:17:11"错误,请参考《DevEco Studio 环境配置指导.docx》中的‘6 创建工程和运行 Hello World’【配置插件】章节修改 hvigor/hvigor-config.json5 文件。 4. 若提示安装报错:`fail to verify pkcs7 file` 请执行指令 ``` hdc shell param set persist.bms.ohCert.verify true ``` -5. linux虚拟机通过hdc无法直接发现OpenHarmony设备 - 解决方案:在windows宿主机中,开启hdc server,具体指令如下: +5. linux 虚拟机通过 hdc 无法直接发现 OpenHarmony 设备 + + 解决方案:在 windows 宿主机中,开启 hdc server,具体指令如下: + ``` hdc kill hdc -s serverIP:8710 -m ``` - 在linux中配置环境变量: + + 在 linux 中配置环境变量: + ``` HDC_SERVER= HDC_SERVER_PORT=8710 ``` - 配置完成后flutter sdk可以通过hdc server完成设备连接,也可参考[官方指导](https://docs.openharmony.cn/pages/v4.0/zh-cn/device-dev/subsystems/subsys-toolchain-hdc-guide.md/#hdc-client%E5%A6%82%E4%BD%95%E8%BF%9C%E7%A8%8B%E8%AE%BF%E9%97%AEhdc-server)。 - -6. 构建Hap任务时报错:Error: The hvigor depends on the npmrc file. Configure the npmrc file first. + 配置完成后 flutter sdk 可以通过 hdc server 完成设备连接,也可参考[官方指导](https://docs.openharmony.cn/pages/v4.0/zh-cn/device-dev/subsystems/subsys-toolchain-hdc-guide.md/#hdc-client%E5%A6%82%E4%BD%95%E8%BF%9C%E7%A8%8B%E8%AE%BF%E9%97%AEhdc-server)。 +6. 构建 Hap 任务时报错:Error: The hvigor depends on the npmrc file. Configure the npmrc file first. - 请在用户目录`~`下创建文件`.npmrc`,该配置也可参考[DevEco Studio官方文档](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/environment_config-0000001052902427-V3),编辑内容如下: + 请在用户目录`~`下创建文件`.npmrc`,该配置也可参考[DevEco Studio 官方文档](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/environment_config-0000001052902427-V3),编辑内容如下: ``` registry=https://repo.huaweicloud.com/repository/npm/ @@ -158,41 +164,96 @@ Flutter SDK 仓库 ``` 7. 查日志时,存在日志丢失现象。 - 解决方案:关闭全局日志,只打开自己领域的日志 + 解决方案:关闭全局日志,只打开自己领域的日志 - ``` - 步骤一:关闭所有领域的日志打印(部分特殊日志无法关闭) - hdc shell hilog -b X - 步骤二:只打开自己领域的日志 - hdc shell hilog -D - 其中为日志打印的级别:D/I/W/E/F,为Tag前面的数字 - 举例: - 打印A00000/XComFlutterOHOS_Native的日志,需要设置hdc shell hilog -b D -D A00000 - 注:上面的设置在机器重启后会失效,如果要继续使用,需要重新设置。 - ``` -8. 若Api11 Beta1版本的机器上无法启动debug签名的应用,可以通过将签名换成正式签名,或在手机端打开开发者模式解决(步骤:设置->通用->开发者模式) + ``` + 步骤一:关闭所有领域的日志打印(部分特殊日志无法关闭) + hdc shell hilog -b X + 步骤二:只打开自己领域的日志 + hdc shell hilog -D + 其中为日志打印的级别:D/I/W/E/F,为Tag前面的数字 + 举例: + 打印A00000/XComFlutterOHOS_Native的日志,需要设置hdc shell hilog -b D -D A00000 + 注:上面的设置在机器重启后会失效,如果要继续使用,需要重新设置。 + ``` + +8. 若 Api11 Beta1 版本的机器上无法启动 debug 签名的应用,可以通过将签名换成正式签名,或在手机端打开开发者模式解决(步骤:设置->通用->开发者模式) + +9. 如果报`Invalid CEN header (invalid zip64 extra data field size)`异常,请更换 Jdk 版本,参见[JDK-8313765](https://bugs.openjdk.org/browse/JDK-8313765) -9. 如果报`Invalid CEN header (invalid zip64 extra data field size)`异常,请更换Jdk版本,参见[JDK-8313765](https://bugs.openjdk.org/browse/JDK-8313765) +10. 运行 debug 版本的 flutter 应用用到鸿蒙设备后报错(release 和 profile 版本正常) -10. 运行debug版本的flutter应用用到鸿蒙设备后报错(release和profile版本正常) 1. 报错信息: `Error while initializing the Dart VM: Wrong full snapshot version, expected '8af474944053df1f0a3be6e6165fa7cf' found 'adb4292f3ec25074ca70abcd2d5c7251'` 2. 解决方案: 依次执行以下操作 - 1. 设置环境变量 `export FLUTTER_STORAGE_BASE_URL=https://flutter-ohos.obs.cn-south-1.myhuaweicloud.com` - 2. 删除 /bin/cache 目录下的缓存 - 3. 执行 `flutter clean`,清除项目编译缓存 - 4. 运行 `flutter run -d $DEVICE --debug` - 3. 补充信息: 运行android或ios出现类似错误,也可以尝试还原环境变量 FLUTTER_STORAGE_BASE_URL ,清除缓存后重新运行。 + 1. 设置环境变量 `export FLUTTER_STORAGE_BASE_URL=https://flutter-ohos.obs.cn-south-1.myhuaweicloud.com` + 2. 删除 /bin/cache 目录下的缓存 + 3. 执行 `flutter clean`,清除项目编译缓存 + 4. 运行 `flutter run -d $DEVICE --debug` + 3. 补充信息: 运行 android 或 ios 出现类似错误,也可以尝试还原环境变量 FLUTTER_STORAGE_BASE_URL ,清除缓存后重新运行。 -11. Beta2版本的ROM更新后,不再支持申请有执行权限的匿名内存,导致debug运行闪退。 +11. Beta2 版本的 ROM 更新后,不再支持申请有执行权限的匿名内存,导致 debug 运行闪退。 1. 解决方案:更新 flutter_flutter 到 a44b8a6d (2024-07-25) 之后的版本。 2. 关键日志: - ``` - #20 at attachToNative (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterNapi.ets:78:32) - #21 at attachToNapi (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine.ets:144:5) - #22 at init (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine.ets:133:7) - ``` +``` +#20 at attachToNative (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterNapi.ets:78:32) +#21 at attachToNapi (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine.ets:144:5) +#22 at init (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine.ets:133:7) +``` + +12. 构建 Hap 命令直接执行`flutter build hap`即可,不再需要`--local-engine`参数,直接从云端获取编译产物。 + +13. 配置环境完成后执行 flutter 命令闪退。 + 1. 解决方案:更新 flutter_flutter 到 a44b8a6d (2024-07-25) 之后的版本。 + +``` +export PATH=/cmd:$PATH +``` + +14. 执行`flutter pub cache clean` 正常 执行`flutter clean` 报错,按照报错信息执行 update 命令也没有效果。 + 1. 解决方案:通过注释掉 build.json5 文件中的配置规避。 + 2. 报错信息: + ``` + Parse ohos module. json5 error: Exception: Can not found module.json5 at + D:\pub_cache\git\flutter_packages-b00939bb44d018f0710d1b080d91dcf4c34ed06\packages\video_player\video_player_ohos\ohossrc\main\module.json5. + You need to update the Flutter plugin project structure. + See + https://gitee.com/openharmony-sig/flutter_samples/tree/master/ohos/docs/09_specifications/update_flutter_plugin_structure.md + ``` +15. 执行`flutter build hap` 路径校验报错。 + + 1. 解决方案:打开 deveco 安装路径 D:\DevEco Studio\tools\hvigor\hvigor-ohos-plugin\res\schemas 下的 ohos-project-build-profile-schema.json, + 删除 scrpath 相关配置:找到"pattern": "^(\\./|\\.\\./)[\\s\\S]+$",删除此行。 + 2. 报错信息: -12. 构建Hap命令直接执行`flutter build hap`即可,不再需要`--local-engine`参数,直接从云端获取编译产物。 + ``` + hvigor ERROR: Schema validate failed. + Detail: Please check the following fields. + instancePath: 'modules[1].scrPath', + keyword: 'pattern' + params: { pattern:'^(\\./|\\.\\./)[\\s\\S]+$' }, + message: 'must match pattern "^(\\./|\\.\\./)[\\s\\S]+$"', + location: 'D:/work/videoplayerdemo/video_cannot_stop_at_background/ohos/build-profile.json:42:146' + ``` + +16. 执行`flutter build hap` 报错。 + 1. 解决方案:打开 deveco 安装路径 D:\DevEco Studio\tools\hvigor\hvigor-ohos-plugin\src\model\module 下的 core-module-model-impl.js, + 修改 findBelongProjectPath 方法(需要管理员权限,可另存为后替换) + ``` + findBelongProjectPath(e) { + if (e === path_1.default.dirname(e)) { + return this.parentProject.getProjectDir() + } + } + ``` + 2. 报错信息: + ``` + > hvigor ERROR: Cannot find belonging project path for module at D:\. + > hvigor ERROR: BUILD FAILED in 2s 556ms. + Running Hvigor task assembleHap... + Oops; flutter has exited unexpectedly: "ProcessException: The eommand failed + Date: Wed, 21 Aug 2024 21:57:29 +0800 Subject: [PATCH 21/38] Update engine.ohos.version to c2bfbb69 Signed-off-by: hezhengyi --- bin/internal/engine.ohos.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/internal/engine.ohos.version b/bin/internal/engine.ohos.version index 9cc8edf2f3..f926b73388 100644 --- a/bin/internal/engine.ohos.version +++ b/bin/internal/engine.ohos.version @@ -1 +1 @@ -b20cf3656c5203a3a52bd3be474cc89af0f6c6e0 \ No newline at end of file +c2bfbb6906a066340d8597c0479885c6c3fc2643 \ No newline at end of file -- Gitee From 79f5bfa3c14715950ec2e23d6e4e845c52684bbd Mon Sep 17 00:00:00 2001 From: liuja <542689970@qq.com> Date: Thu, 22 Aug 2024 11:45:47 +0800 Subject: [PATCH 22/38] =?UTF-8?q?=E9=97=A8=E7=A6=81=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=8C=E6=A0=BC=E5=BC=8F=E5=8C=96=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuja <542689970@qq.com> --- README.md | 261 ++++++++++++++++++++++++++---------------------------- 1 file changed, 126 insertions(+), 135 deletions(-) diff --git a/README.md b/README.md index 9acbdc1bc3..f97b02a1ba 100644 --- a/README.md +++ b/README.md @@ -1,76 +1,74 @@ -# Flutter SDK 仓库 +Flutter SDK 仓库 +============== 原始仓来源:https://github.com/flutter/flutter ## 仓库说明 - -本仓库是基于 Flutter SDK 对于 OpenHarmony 平台的兼容拓展,可支持 IDE 或者终端使用 Flutter Tools 指令编译和构建 OpenHarmony 应用程序。 +本仓库是基于Flutter SDK对于OpenHarmony平台的兼容拓展,可支持IDE或者终端使用Flutter Tools指令编译和构建OpenHarmony应用程序。 ## 开发文档 - 文档入口:https://gitee.com/openharmony-sig/flutter_samples/tree/master/ohos/docs ## 环境依赖 -- 开发系统 +* 开发系统 - Flutter Tools 指令目前已支持在 Linux、Mac 和 Windows 下使用。 + Flutter Tools指令目前已支持在Linux、Mac和Windows下使用。 -- 环境配置 - **请优先从[鸿蒙套件列表](https://developer.harmonyos.com/deveco-developer-suite/enabling/kit?currentPage=1&pageSize=100)下载配套开发工具,暂不支持非该渠道下载的套件** - _下列环境变量配置,类 Unix 系统(Linux、Mac),下可直接参照配置,Windows 下环境变量配置请在‘编辑系统环境变量’中设置_ +* 环境配置 + **请优先从[鸿蒙套件列表](https://developer.harmonyos.com/deveco-developer-suite/enabling/kit?currentPage=1&pageSize=100)下载配套开发工具,暂不支持非该渠道下载的套件** + *下列环境变量配置,类Unix系统(Linux、Mac),下可直接参照配置,Windows下环境变量配置请在‘编辑系统环境变量’中设置* - 1. 配置 HarmonyOS SDK 和环境变量 + 1. 配置HarmonyOS SDK和环境变量 + * API12, deveco-studio-5.0.3.300 或 command-line-tools-5.0.3.300 + * 配置 Java17 + * 配置环境变量 (SDK, node, ohpm, hvigor) - - API12, deveco-studio-5.0.3.300 或 command-line-tools-5.0.3.300 - - 配置 Java17 - - 配置环境变量 (SDK, node, ohpm, hvigor) + ```sh + export TOOL_HOME=/Applications/DevEco-Studio-5.0.3.300.app/Contents # mac环境 + export DEVECO_SDK_HOME=$TOOL_HOME/sdk # command-line-tools/sdk + export PATH=$TOOL_HOME/tools/ohpm/bin:$PATH # command-line-tools/ohpm/bin + export PATH=$TOOL_HOME/tools/hvigor/bin:$PATH # command-line-tools/hvigor/bin + export PATH=$TOOL_HOME/tools/node/bin:$PATH # command-line-tools/tool/node/bin + ``` - ```sh - export TOOL_HOME=/Applications/DevEco-Studio-5.0.3.300.app/Contents # mac环境 - export DEVECO_SDK_HOME=$TOOL_HOME/sdk # command-line-tools/sdk - export PATH=$TOOL_HOME/tools/ohpm/bin:$PATH # command-line-tools/ohpm/bin - export PATH=$TOOL_HOME/tools/hvigor/bin:$PATH # command-line-tools/hvigor/bin - export PATH=$TOOL_HOME/tools/node/bin:$PATH # command-line-tools/tool/node/bin - ``` - - 2. 通过代码工具下载当前仓库代码`git clone https://gitee.com/openharmony-sig/flutter_flutter.git`,指定 dev 或 master 分支,并配置环境 + 2. 通过代码工具下载当前仓库代码`git clone https://gitee.com/openharmony-sig/flutter_flutter.git`,指定dev或master分支,并配置环境 ```sh export PATH=/bin:$PATH export PUB_HOSTED_URL=https://pub.flutter-io.cn export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn ``` + + 3. `--local-engine` 成为可选参数,可以不传,默认从云端获取。 + - 使用示例:`--local-engine=src/out/` + - 可在该路径下载[编译产物](https://docs.qq.com/sheet/DUnljRVBYUWZKZEtF?tab=BB08J2) + - engine路径指向需带上 `src/out` 目录 - 3. `--local-engine` 成为可选参数,可以不传,默认从云端获取。 + 上述所有环境变量的配置(Windows下环境变量配置请在‘编辑系统环境变量’中设置),可参考下面的示例(其中user和具体代码路径请替换成实际路径): - - 使用示例:`--local-engine=src/out/` - - 可在该路径下载[编译产物](https://docs.qq.com/sheet/DUnljRVBYUWZKZEtF?tab=BB08J2) - - engine 路径指向需带上 `src/out` 目录 + ```sh + # 国内镜像 + export PUB_HOSTED_URL=https://pub.flutter-io.cn + export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn - 上述所有环境变量的配置(Windows 下环境变量配置请在‘编辑系统环境变量’中设置),可参考下面的示例(其中 user 和具体代码路径请替换成实际路径): + # 拉取下来的flutter_flutter/bin目录 + export PATH=/home//ohos/flutter_flutter/bin:$PATH - ```sh - # 国内镜像 - export PUB_HOSTED_URL=https://pub.flutter-io.cn - export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn + # HamonyOS SDK + export TOOL_HOME=/Applications/DevEco-Studio-5.0.3.300.app/Contents # mac环境 + export DEVECO_SDK_HOME=$TOOL_HOME/sdk # command-line-tools/sdk + export PATH=$TOOL_HOME/tools/ohpm/bin:$PATH # command-line-tools/ohpm/bin + export PATH=$TOOL_HOME/tools/hvigor/bin:$PATH # command-line-tools/hvigor/bin + export PATH=$TOOL_HOME/tools/node/bin:$PATH # command-line-tools/tool/node/bin + ``` - # 拉取下来的flutter_flutter/bin目录 - export PATH=/home//ohos/flutter_flutter/bin:$PATH - - # HamonyOS SDK - export TOOL_HOME=/Applications/DevEco-Studio-5.0.3.300.app/Contents # mac环境 - export DEVECO_SDK_HOME=$TOOL_HOME/sdk # command-line-tools/sdk - export PATH=$TOOL_HOME/tools/ohpm/bin:$PATH # command-line-tools/ohpm/bin - export PATH=$TOOL_HOME/tools/hvigor/bin:$PATH # command-line-tools/hvigor/bin - export PATH=$TOOL_HOME/tools/node/bin:$PATH # command-line-tools/tool/node/bin - ``` ## 构建步骤 -1. 运行 `flutter doctor -v` 检查环境变量配置是否正确,**Futter**与**OpenHarmony**应都为 ok 标识,若两处提示缺少环境,按提示补上相应环境即可。 +1. 运行 `flutter doctor -v` 检查环境变量配置是否正确,**Futter**与**OpenHarmony**应都为ok标识,若两处提示缺少环境,按提示补上相应环境即可。 -2. 创建工程与编译命令,编译产物在\/ohos/entry/build/default/outputs/default/entry-default-signed.hap 下。 +2. 创建工程与编译命令,编译产物在\/ohos/entry/build/default/outputs/default/entry-default-signed.hap下。 ``` # 创建工程 @@ -81,46 +79,45 @@ flutter build hap --release ``` -3. 通过`flutter devices`指令发现 ohos 设备之后,使用 `hdc -t install `进行安装。 +3. 通过`flutter devices`指令发现ohos设备之后,使用 `hdc -t install `进行安装。 4. 也可直接使用下列指令运行: - ``` # 示例:flutter run [--local-engine=/src/out/ohos_debug_unopt_arm64] -d flutter run --debug -d ``` -5. 构建 app 包命令: - +5. 构建app包命令: ``` # 示例:flutter build app --release [--local-engine=/src/out/ohos_release_arm64] local-engine为可选项 flutter build app --release ``` -## 已兼容 OpenHarmony 开发的指令列表 - -| 指令名称 | 指令描述 | 使用说明 | -| ---------- | -------------------- | -------------------------------------------------------------------------------------------------------------------- | -| doctor | 环境检测 | flutter doctor | -| config | 环境配置 | flutter config --\ \ | -| create | 创建新项目 | flutter create --platforms ohos,android,ios --org \ \ | -| create | 创建 module 模板 | flutter create -t module \ | -| create | 创建 plugin 模板 | flutter create -t plugin --platforms ohos,android,ios \ | -| create | 创建 plugin_ffi 模板 | flutter create -t plugin_ffi --platforms ohos,android,ios \ | -| devices | 已连接设备查找 | flutter devices | -| install | 应用安装 | flutter install -t \ \ | -| assemble | 资源打包 | flutter assemble | -| build | 测试应用构建 | flutter build hap --debug [--target-platform ohos-arm64] [--local-engine=\<兼容 ohos 的 debug engine 产物路径\>] | -| build | 正式应用构建 | flutter build hap --release [--target-platform ohos-arm64] [--local-engine=\<兼容 ohos 的 release engine 产物路径\>] | -| run | 应用运行 | flutter run [--local-engine=\<兼容 ohos 的 engine 产物路径\>] | -| attach | 调试模式 | flutter attach | -| screenshot | 截屏 | flutter screenshot | - -附:[Flutter 三方库适配计划](https://docs.qq.com/sheet/DVVJDWWt1V09zUFN2) + +## 已兼容OpenHarmony开发的指令列表 +| 指令名称 | 指令描述 | 使用说明 | +| ------- | ------- |-------------------------------------------------------------------| +| doctor | 环境检测 | flutter doctor | +| config | 环境配置 | flutter config --\ \ | +| create | 创建新项目 | flutter create --platforms ohos,android,ios --org \ \ | +| create | 创建module模板 | flutter create -t module \ | +| create | 创建plugin模板 | flutter create -t plugin --platforms ohos,android,ios \ | +| create | 创建plugin_ffi模板 | flutter create -t plugin_ffi --platforms ohos,android,ios \ | +| devices | 已连接设备查找 | flutter devices | +| install | 应用安装 | flutter install -t \ \ | +| assemble | 资源打包 | flutter assemble | +| build | 测试应用构建 | flutter build hap --debug [--target-platform ohos-arm64] [--local-engine=\<兼容ohos的debug engine产物路径\>] | +| build | 正式应用构建 | flutter build hap --release [--target-platform ohos-arm64] [--local-engine=\<兼容ohos的release engine产物路径\>] | +| run | 应用运行 | flutter run [--local-engine=\<兼容ohos的engine产物路径\>] | +| attach | 调试模式 | flutter attach | +| screenshot | 截屏 | flutter screenshot | + +附:[Flutter三方库适配计划](https://docs.qq.com/sheet/DVVJDWWt1V09zUFN2) + ## 常见问题 -1. 切换 FLUTTER_STORAGE_BASE_URL 后需删除\/bin/cache 目录,并在项目中执行 flutter clean 后再运行 +1. 切换FLUTTER_STORAGE_BASE_URL后需删除\/bin/cache 目录,并在项目中执行flutter clean后再运行 2. 若出现报错:`The SDK license agreement is not accepted`,参考执行以下命令后再次编译: @@ -128,35 +125,32 @@ ./ohsdkmgr install ets:9 js:9 native:9 previewer:9 toolchains:9 --sdk-directory='/home/xc/code/sdk/ohos-sdk/' --accept-license ``` -3. 如果你使用的是 DevEco Studio 的 Beta 版本,编译工程时遇到“must have required property 'compatibleSdkVersion', location: demo/ohos/build-profile.json5:17:11"错误,请参考《DevEco Studio 环境配置指导.docx》中的‘6 创建工程和运行 Hello World’【配置插件】章节修改 hvigor/hvigor-config.json5 文件。 +3. 如果你使用的是DevEco Studio的Beta版本,编译工程时遇到“must have required property 'compatibleSdkVersion', location: demo/ohos/build-profile.json5:17:11"错误,请参考《DevEco Studio环境配置指导.docx》中的‘6 创建工程和运行Hello World’【配置插件】章节修改 hvigor/hvigor-config.json5文件。 4. 若提示安装报错:`fail to verify pkcs7 file` 请执行指令 ``` hdc shell param set persist.bms.ohCert.verify true ``` +5. linux虚拟机通过hdc无法直接发现OpenHarmony设备 -5. linux 虚拟机通过 hdc 无法直接发现 OpenHarmony 设备 - - 解决方案:在 windows 宿主机中,开启 hdc server,具体指令如下: - + 解决方案:在windows宿主机中,开启hdc server,具体指令如下: ``` hdc kill hdc -s serverIP:8710 -m ``` - - 在 linux 中配置环境变量: - + 在linux中配置环境变量: ``` HDC_SERVER= HDC_SERVER_PORT=8710 ``` - 配置完成后 flutter sdk 可以通过 hdc server 完成设备连接,也可参考[官方指导](https://docs.openharmony.cn/pages/v4.0/zh-cn/device-dev/subsystems/subsys-toolchain-hdc-guide.md/#hdc-client%E5%A6%82%E4%BD%95%E8%BF%9C%E7%A8%8B%E8%AE%BF%E9%97%AEhdc-server)。 + 配置完成后flutter sdk可以通过hdc server完成设备连接,也可参考[官方指导](https://docs.openharmony.cn/pages/v4.0/zh-cn/device-dev/subsystems/subsys-toolchain-hdc-guide.md/#hdc-client%E5%A6%82%E4%BD%95%E8%BF%9C%E7%A8%8B%E8%AE%BF%E9%97%AEhdc-server)。 -6. 构建 Hap 任务时报错:Error: The hvigor depends on the npmrc file. Configure the npmrc file first. +6. 构建Hap任务时报错:Error: The hvigor depends on the npmrc file. Configure the npmrc file first. - 请在用户目录`~`下创建文件`.npmrc`,该配置也可参考[DevEco Studio 官方文档](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/environment_config-0000001052902427-V3),编辑内容如下: + + 请在用户目录`~`下创建文件`.npmrc`,该配置也可参考[DevEco Studio官方文档](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/environment_config-0000001052902427-V3),编辑内容如下: ``` registry=https://repo.huaweicloud.com/repository/npm/ @@ -164,76 +158,73 @@ ``` 7. 查日志时,存在日志丢失现象。 - 解决方案:关闭全局日志,只打开自己领域的日志 - - ``` - 步骤一:关闭所有领域的日志打印(部分特殊日志无法关闭) - hdc shell hilog -b X - 步骤二:只打开自己领域的日志 - hdc shell hilog -D - 其中为日志打印的级别:D/I/W/E/F,为Tag前面的数字 - 举例: - 打印A00000/XComFlutterOHOS_Native的日志,需要设置hdc shell hilog -b D -D A00000 - 注:上面的设置在机器重启后会失效,如果要继续使用,需要重新设置。 - ``` - -8. 若 Api11 Beta1 版本的机器上无法启动 debug 签名的应用,可以通过将签名换成正式签名,或在手机端打开开发者模式解决(步骤:设置->通用->开发者模式) + 解决方案:关闭全局日志,只打开自己领域的日志 -9. 如果报`Invalid CEN header (invalid zip64 extra data field size)`异常,请更换 Jdk 版本,参见[JDK-8313765](https://bugs.openjdk.org/browse/JDK-8313765) + ``` + 步骤一:关闭所有领域的日志打印(部分特殊日志无法关闭) + hdc shell hilog -b X + 步骤二:只打开自己领域的日志 + hdc shell hilog -D + 其中为日志打印的级别:D/I/W/E/F,为Tag前面的数字 + 举例: + 打印A00000/XComFlutterOHOS_Native的日志,需要设置hdc shell hilog -b D -D A00000 + 注:上面的设置在机器重启后会失效,如果要继续使用,需要重新设置。 + ``` +8. 若Api11 Beta1版本的机器上无法启动debug签名的应用,可以通过将签名换成正式签名,或在手机端打开开发者模式解决(步骤:设置->通用->开发者模式) -10. 运行 debug 版本的 flutter 应用用到鸿蒙设备后报错(release 和 profile 版本正常) +9. 如果报`Invalid CEN header (invalid zip64 extra data field size)`异常,请更换Jdk版本,参见[JDK-8313765](https://bugs.openjdk.org/browse/JDK-8313765) +10. 运行debug版本的flutter应用用到鸿蒙设备后报错(release和profile版本正常) 1. 报错信息: `Error while initializing the Dart VM: Wrong full snapshot version, expected '8af474944053df1f0a3be6e6165fa7cf' found 'adb4292f3ec25074ca70abcd2d5c7251'` 2. 解决方案: 依次执行以下操作 - 1. 设置环境变量 `export FLUTTER_STORAGE_BASE_URL=https://flutter-ohos.obs.cn-south-1.myhuaweicloud.com` - 2. 删除 /bin/cache 目录下的缓存 - 3. 执行 `flutter clean`,清除项目编译缓存 - 4. 运行 `flutter run -d $DEVICE --debug` - 3. 补充信息: 运行 android 或 ios 出现类似错误,也可以尝试还原环境变量 FLUTTER_STORAGE_BASE_URL ,清除缓存后重新运行。 + 1. 设置环境变量 `export FLUTTER_STORAGE_BASE_URL=https://flutter-ohos.obs.cn-south-1.myhuaweicloud.com` + 2. 删除 /bin/cache 目录下的缓存 + 3. 执行 `flutter clean`,清除项目编译缓存 + 4. 运行 `flutter run -d $DEVICE --debug` + 3. 补充信息: 运行android或ios出现类似错误,也可以尝试还原环境变量 FLUTTER_STORAGE_BASE_URL ,清除缓存后重新运行。 -11. Beta2 版本的 ROM 更新后,不再支持申请有执行权限的匿名内存,导致 debug 运行闪退。 +11. Beta2版本的ROM更新后,不再支持申请有执行权限的匿名内存,导致debug运行闪退。 1. 解决方案:更新 flutter_flutter 到 a44b8a6d (2024-07-25) 之后的版本。 2. 关键日志: -``` -#20 at attachToNative (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterNapi.ets:78:32) -#21 at attachToNapi (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine.ets:144:5) -#22 at init (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine.ets:133:7) -``` + ``` + #20 at attachToNative (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterNapi.ets:78:32) + #21 at attachToNapi (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine.ets:144:5) + #22 at init (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine.ets:133:7) + ``` -12. 构建 Hap 命令直接执行`flutter build hap`即可,不再需要`--local-engine`参数,直接从云端获取编译产物。 +12. 构建Hap命令直接执行`flutter build hap`即可,不再需要`--local-engine`参数,直接从云端获取编译产物。 -13. 配置环境完成后执行 flutter 命令闪退。 +13. 配置环境完成后执行 flutter 命令 出现崩溃。 1. 解决方案:更新 flutter_flutter 到 a44b8a6d (2024-07-25) 之后的版本。 - -``` -export PATH=/cmd:$PATH -``` + ``` + export PATH=/cmd:$PATH + ``` 14. 执行`flutter pub cache clean` 正常 执行`flutter clean` 报错,按照报错信息执行 update 命令也没有效果。 1. 解决方案:通过注释掉 build.json5 文件中的配置规避。 2. 报错信息: ``` - Parse ohos module. json5 error: Exception: Can not found module.json5 at - D:\pub_cache\git\flutter_packages-b00939bb44d018f0710d1b080d91dcf4c34ed06\packages\video_player\video_player_ohos\ohossrc\main\module.json5. - You need to update the Flutter plugin project structure. - See - https://gitee.com/openharmony-sig/flutter_samples/tree/master/ohos/docs/09_specifications/update_flutter_plugin_structure.md + #Parse ohos module. json5 error: Exception: Can not found module.json5 at + #D:\pub_cache\git\flutter_packages-b00939bb44d018f0710d1b080d91dcf4c34ed06\packages\video_player\video_player_ohos\ohossrc\main\module.json5. + #You need to update the Flutter plugin project structure. + #See + #https://gitee.com/openharmony-sig/flutter_samples/tree/master/ohos/docs/09_specifications/update_flutter_plugin_structure.md ``` -15. 执行`flutter build hap` 路径校验报错。 - 1. 解决方案:打开 deveco 安装路径 D:\DevEco Studio\tools\hvigor\hvigor-ohos-plugin\res\schemas 下的 ohos-project-build-profile-schema.json, - 删除 scrpath 相关配置:找到"pattern": "^(\\./|\\.\\./)[\\s\\S]+$",删除此行。 +15. 执行`flutter build hap` 时遇到路径校验报错。 + 1. 解决方案: + ·打开 deveco 安装路径 D:\DevEco Studio\tools\hvigor\hvigor-ohos-plugin\res\schemas 下的 ohos-project-build-profile-schema.json文件。 + ·在该文件中找到包含:"pattern": "^(\\./|\\.\\./)[\\s\\S]+$"的行,并删除此行。 2. 报错信息: - ``` - hvigor ERROR: Schema validate failed. - Detail: Please check the following fields. - instancePath: 'modules[1].scrPath', - keyword: 'pattern' - params: { pattern:'^(\\./|\\.\\./)[\\s\\S]+$' }, - message: 'must match pattern "^(\\./|\\.\\./)[\\s\\S]+$"', - location: 'D:/work/videoplayerdemo/video_cannot_stop_at_background/ohos/build-profile.json:42:146' + #hvigor ERROR: Schema validate failed. + # Detail: Please check the following fields. + #instancePath: 'modules[1].scrPath', + #keyword: 'pattern' + #params: { pattern:'^(\\./|\\.\\./)[\\s\\S]+$' }, + #message: 'must match pattern "^(\\./|\\.\\./)[\\s\\S]+$"', + #location: 'D:/work/videoplayerdemo/video_cannot_stop_at_background/ohos/build-profile.json:42:146' ``` 16. 执行`flutter build hap` 报错。 @@ -248,12 +239,12 @@ export PATH=/cmd:$PATH ``` 2. 报错信息: ``` - > hvigor ERROR: Cannot find belonging project path for module at D:\. - > hvigor ERROR: BUILD FAILED in 2s 556ms. - Running Hvigor task assembleHap... - Oops; flutter has exited unexpectedly: "ProcessException: The eommand failed - Date: Thu, 22 Aug 2024 12:12:06 +0800 Subject: [PATCH 23/38] =?UTF-8?q?codecheck=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuja <542689970@qq.com> --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f97b02a1ba..d83365c15c 100644 --- a/README.md +++ b/README.md @@ -195,7 +195,7 @@ Flutter SDK 仓库 12. 构建Hap命令直接执行`flutter build hap`即可,不再需要`--local-engine`参数,直接从云端获取编译产物。 -13. 配置环境完成后执行 flutter 命令 出现崩溃。 +13. 配置环境完成后执行 flutter 命令 出现闪退。 1. 解决方案:更新 flutter_flutter 到 a44b8a6d (2024-07-25) 之后的版本。 ``` export PATH=/cmd:$PATH @@ -242,7 +242,7 @@ Flutter SDK 仓库 # hvigor ERROR: Cannot find belonging project path for module at D:\. # hvigor ERROR: BUILD FAILED in 2s 556ms. #Running Hvigor task assembleHap... - #Oops; flutter has exited unexpectedly: "ProcessException: The eommand failed + #Oops; flutter has exited unexpectedly: "ProcessException: The command failed # Date: Thu, 22 Aug 2024 14:30:10 +0800 Subject: [PATCH 24/38] =?UTF-8?q?readme=E5=B1=8F=E8=94=BDcodecheck?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuja <542689970@qq.com> --- OAT.xml | 2 +- README.md | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/OAT.xml b/OAT.xml index ff270e602a..e2f53d4c5d 100644 --- a/OAT.xml +++ b/OAT.xml @@ -129,7 +129,7 @@ - + diff --git a/README.md b/README.md index d83365c15c..b94b129334 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ Flutter SDK 仓库 2. 通过代码工具下载当前仓库代码`git clone https://gitee.com/openharmony-sig/flutter_flutter.git`,指定dev或master分支,并配置环境 ```sh + export PUB_CACHE=D:/PUB export PATH=/bin:$PATH export PUB_HOSTED_URL=https://pub.flutter-io.cn export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn @@ -48,6 +49,9 @@ Flutter SDK 仓库 上述所有环境变量的配置(Windows下环境变量配置请在‘编辑系统环境变量’中设置),可参考下面的示例(其中user和具体代码路径请替换成实际路径): ```sh + #依赖缓存 + export PUB_CACHE=D:/PUB(自定义路径) + # 国内镜像 export PUB_HOSTED_URL=https://pub.flutter-io.cn export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn -- Gitee From b3b8905a9a5beed290e57e2358ba84e03fbfcdf9 Mon Sep 17 00:00:00 2001 From: liuja <542689970@qq.com> Date: Thu, 22 Aug 2024 14:45:43 +0800 Subject: [PATCH 25/38] =?UTF-8?q?=E5=9B=9E=E9=80=80OTA=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuja <542689970@qq.com> --- OAT.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OAT.xml b/OAT.xml index e2f53d4c5d..ff270e602a 100644 --- a/OAT.xml +++ b/OAT.xml @@ -129,7 +129,7 @@ - + -- Gitee From b40d7b4cb952a944967f06039362bb30f28ae2a8 Mon Sep 17 00:00:00 2001 From: kemin <541416002@qq.com> Date: Thu, 22 Aug 2024 20:06:47 +0800 Subject: [PATCH 26/38] =?UTF-8?q?=E7=BC=96=E8=AF=91har=E5=8C=85=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0buildMode=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: kemin <541416002@qq.com> --- .../flutter_tools/lib/src/ohos/hvigor.dart | 42 +++++++++++++------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/packages/flutter_tools/lib/src/ohos/hvigor.dart b/packages/flutter_tools/lib/src/ohos/hvigor.dart index bea955b09b..d6a9f35270 100644 --- a/packages/flutter_tools/lib/src/ohos/hvigor.dart +++ b/packages/flutter_tools/lib/src/ohos/hvigor.dart @@ -199,18 +199,36 @@ Future assembleHar( required String buildMode, String product = 'default', Logger? logger}) async { - final List command = [ - hvigorwPath, - // 'clean', - '--mode', - 'module', - '-p', - 'module=$moduleName', - '-p', - 'product=$product', - 'assembleHar', - '--no-daemon', - ]; + final List command = []; + if (buildMode.compareTo('debug') == 0 || buildMode.compareTo('release') == 0) { + command.addAll([ + hvigorwPath, + '--mode', + 'module', + '-p', + 'module=$moduleName', + '-p', + 'product=$product', + '-p', + 'buildMode=$buildMode', + 'assembleHar', + '--no-daemon', + ]); + } else { + command.addAll([ + hvigorwPath, + '--mode', + 'module', + '-p', + 'module=$moduleName', + '-p', + 'product=$product', + '-p', + 'buildMode=debug', + 'assembleHar', + '--no-daemon', + ]); + } return hvigorwTask(command, processUtils: processUtils, workPath: workPath, -- Gitee From 2151b5a89c468771e9982d22d81673ea6a4bce9a Mon Sep 17 00:00:00 2001 From: liuja <542689970@qq.com> Date: Thu, 22 Aug 2024 21:52:42 +0800 Subject: [PATCH 27/38] =?UTF-8?q?redeme=E6=96=87=E6=A1=A3=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuja <542689970@qq.com> --- README.en.md | 211 ++++++++++++++++++++++++++++++++++----------------- README.md | 176 +++++++++++++++++++++--------------------- 2 files changed, 231 insertions(+), 156 deletions(-) diff --git a/README.en.md b/README.en.md index 4838e7096d..a5c8f7445c 100644 --- a/README.en.md +++ b/README.en.md @@ -6,6 +6,9 @@ Original warehouse source: https://github.com/flutter/flutter ## Warehouse description This repository is a compatible extension of Flutter SDK for the OpenHarmony platform, and can support IDE or terminal use of Flutter Tools instructions to compile and build OpenHarmony applications. +## Development document +[Docs](https://gitee.com/openharmony-sig/flutter_samples/tree/master/ohos/docs) + ## Environment dependencies * development system @@ -14,53 +17,56 @@ This repository is a compatible extension of Flutter SDK for the OpenHarmony pla * Environment configuration - **Please give priority to downloading the supporting development tools from [Hongmeng Kit List](https://developer.harmonyos.com/deveco-developer-suite/enabling/kit?currentPage=1&pageSize=100). Downloads from other channels are not currently supported. Kit** + **Please give priority to downloading the supporting development tools from [OpenHarmony SDK](https://developer.huawei.com/consumer/cn/develop) Download the matching development tool,Suites that are not downloaded through this channel are not supported** *The following environment variable configuration is for Unix-like systems (Linux, Mac). You can directly refer to the configuration below. For environment variable configuration under Windows, please set it in ‘Edit System Environment Variables’* - 1. Download OpenHarmony SDK and configure environment variables - * API12, deveco-studio-5.0.3.300 or command-line-tools-5.0.3.300 + 1. Configure the HarmonyOS SDK and environment variables + * API12, deveco-studio-5.0 or command-line-tools-5.0 * Configure Java17 * Configure environment variables (SDK, node, ohpm, hvigor) ```sh - export TOOL_HOME=/Applications/DevEco-Studio-5.0.3.300.app/Contents # For mac - export DEVECO_SDK_HOME=$TOOL_HOME/sdk # command-line-tools/sdk - export PATH=$TOOL_HOME/tools/ohpm/bin:$PATH # command-line-tools/ohpm/bin - export PATH=$TOOL_HOME/tools/hvigor/bin:$PATH # command-line-tools/hvigor/bin - export PATH=$TOOL_HOME/tools/node/bin:$PATH # command-line-tools/tool/node/bin + export TOOL_HOME=/Applications/DevEco-Studio.app/Contents # For mac + export DEVECO_SDK_HOME=$TOOL_HOME/sdk # command-line-tools/sdk + export PATH=$TOOL_HOME/tools/ohpm/bin:$PATH # command-line-tools/ohpm/bin + export PATH=$TOOL_HOME/tools/hvigor/bin:$PATH # command-line-tools/hvigor/bin + export PATH=$TOOL_HOME/tools/node/bin:$PATH # command-line-tools/tool/node/bin ``` - 2. Download the current warehouse code `git clone https://gitee.com/openharmony-sig/flutter_flutter.git` through the code tool, and configure the environment + 2. Download the current warehouse code `git clone https://gitee.com/openharmony-sig/flutter_flutter.git` Specify the dev or master branch and configure the environment ```sh - export PATH=/bin:$PATH - + export PATH=/bin:$PATH + export PUB_CACHE=D:/PUB # Domestic mirror - export PUB_HOSTED_URL=https://pub.flutter-io.cn - export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn + export PUB_HOSTED_URL=https://pub.flutter-io.cn + export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn ``` - 3. becomes an optional parameter and may not be passed. - - Usage example: `--local-engine=src/out/` + 3. `--local-engine` becomes an optional parameter and can be obtained from the cloud by default. + - Usage example: `--local-engine=src/out/` - You can download [compiled product](https://docs.qq.com/sheet/DUnljRVBYUWZKZEtF?tab=BB08J2) from this path. - The engine path points to the directory that needs to be accompanied by 'src/out'. For the configuration of all the above environment variables (for environment variable configuration under Windows, please set it in 'Edit System Environment Variables'), you can refer to the following example (please replace user and specific code path with the actual path): - ``` - # Domestic mirror - export PUB_HOSTED_URL=https://pub.flutter-io.cn - export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn - - # The flutter_flutter directory pulled from Gitee - export PATH=/home//ohos/flutter_flutter/bin:$PATH - - # HarmonyOS SDK - export TOOL_HOME=/Applications/DevEco-Studio-5.0.3.300.app/Contents # For mac - export DEVECO_SDK_HOME=$TOOL_HOME/sdk # command-line-tools/sdk - export PATH=$TOOL_HOME/tools/ohpm/bin:$PATH # command-line-tools/ohpm/bin - export PATH=$TOOL_HOME/tools/hvigor/bin:$PATH # command-line-tools/hvigor/bin - export PATH=$TOOL_HOME/tools/node/bin:$PATH # command-line-tools/tool/node/bin + ```sh + # Dependent cache + export PUB_CACHE=D:/PUB(Custom path) + + # Domestic mirror + export PUB_HOSTED_URL=https://pub.flutter-io.cn + export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn + + # The flutter_flutter directory pulled from Gitee + export PATH=/home//ohos/flutter_flutter/bin:$PATH + + # HarmonyOS SDK + export TOOL_HOME=/Applications/DevEco-Studio-5.0.app/Contents # For mac + export DEVECO_SDK_HOME=$TOOL_HOME/sdk # command-line-tools/sdk + export PATH=$TOOL_HOME/tools/ohpm/bin:$PATH # command-line-tools/ohpm/bin + export PATH=$TOOL_HOME/tools/hvigor/bin:$PATH # command-line-tools/hvigor/bin + export PATH=$TOOL_HOME/tools/node/bin:$PATH # command-line-tools/tool/node/bin ``` ## Build steps @@ -70,21 +76,27 @@ This repository is a compatible extension of Flutter SDK for the OpenHarmony pla 2. Create the project and compile the command. The compiled product is under \/ohos/entry/build/default/outputs/default/entry-default-signed.hap. ``` - # Create project - flutter create --platforms ohos + # Create project + flutter create --platforms ohos - # Enter the project root directory to compile - # Example: flutter build hap [--target-platform ohos-arm64] --local-engine=/src/out/ohos_release_arm64 --release - flutter build hap --local-engine=/home/user/engine_make/src/out/ohos_release_arm64 --release + # Go to the project root directory for compilation + # Example: flutter build hap [--target-platform ohos-arm64] [--local-engine=/src/out/ohos_release_arm64] --release + flutter build hap --release ``` 3. After discovering the ohos device through the `flutter devices` command, use `hdc -t install ` to install it. 4. You can also directly use the following command to run: -``` - # Example: flutter run --local-engine=/src/out/ohos_debug_unopt_arm64 - flutter run --local-engine=/home/user/engine_make/src/out/ohos_debug_unopt_arm64 --debug -``` + ``` + # Example: flutter run [--local-engine=/src/out/ohos_debug_unopt_arm64] -d + flutter run --debug -d + ``` + +5. Build app package command: + ``` + # Example: flutter build app --release [--local-engine=/src/out/ohos_release_arm64] local-engine(is optional) + flutter build app --release + ``` ## Compatible command list developed by OpenHarmony @@ -100,9 +112,9 @@ This repository is a compatible extension of Flutter SDK for the OpenHarmony pla | devices | Connected device discovery | flutter devices | | install | application installation | flutter install -t \ \ | | assemble | resource packaging | flutter assemble | -| build | Test application build | flutter build hap --target-platform ohos-arm64 --debug --local-engine=\ | -| build | Formal application build | flutter build hap --target-platform ohos-arm64 --release --local-engine=\ | -| run | application run | flutter run --local-engine=\ | +| build | Test application build | flutter build hap --debug [--target-platform ohos-arm64] [--local-engine=\] | +| build | Formal application build | flutter build hap --release [--target-platform ohos-arm64] [--local-engine=\] | +| run | application run | flutter run [--local-engine=\] | | attach | debug mode | flutter attach | | screenshot | screenshot | flutter screenshot | @@ -112,52 +124,61 @@ Attachment: [Flutter third-party library adaptation plan](https://docs.qq.com/sh 1. After switching to FLUTTER_STORAGE_BASE_URL, you need to delete the \/bin/cache directory and execute Flutter clean in the project before running it again. -2. Recommended version of OpenHarmony SDK: `4.0.10.3`, which can be downloaded around August 20 when it is built daily. If there are problems related to the SDK version during the compilation process, you can try to replace this version of the SDK. - -3. If an error message appears: `The SDK license agreement is not accepted`, please execute the following command and compile again: +2. If an error message appears: `The SDK license agreement is not accepted`, please execute the following command and compile again: ``` - ./ohsdkmgr install ets:9 js:9 native:9 previewer:9 toolchains:9 --sdk-directory='/home/xc/code/sdk/ohos-sdk/' --accept-license + ./ohsdkmgr install ets:9 js:9 native:9 previewer:9 toolchains:9 --sdk-directory='/home/xc/code/sdk/ohos-sdk/' --accept-license ``` -4. After switching between debug and release compilation modes, an error may be reported during operation. You can try deleting the oh_modules cache file and recompiling. - -5. If `flutter docker -v` prompts that ohpm cannot be found, but the environment variables are detected correctly, please ensure that you have executed the `ohpm/bin/init` command to install ohpm and check again. - -6. If you encounter the error Unsupported class file major version 61 when compiling the signature tool, it means that the current JDK version does not support it. Please lower the Java SDK version and try again. +3. If you are using the Beta version of DevEco Studio and encounter the error "must have required property 'compatibleSdkVersion', location: demo/ohos/build-profile.json5:17:11" when compiling the project, Modify the hvigor/hvigor-config.json5 file by referring to section ‘6 Create the project and run Hello World’ [Configuration Plug-in] in《DevEco Studio Environment configuration guide.docx》. -7. If you are using the Beta version of DevEco Studio and encounter the error "must have required property 'compatibleSdkVersion', location: demo/ohos/build-profile.json5:17:11" when compiling the project, please refer to "DevEco Studio" Modify the hvigor/hvigor-config.json5 file in the '6 Creating Projects and Running Hello World' [Configuration Plug-in] chapter in "Environment Configuration Guide.docx". - -8. If you are prompted with an installation error: `fail to verify pkcs7 file`, please execute the command +4. If you are prompted with an installation error: `fail to verify pkcs7 file`, please execute the command ``` - hdc shell param set persist.bms.ohCert.verify true + hdc shell param set persist.bms.ohCert.verify true ``` -9. Linux virtual machine cannot directly discover OpenHarmony devices through hdc +5. Linux virtual machine cannot directly discover OpenHarmony devices through hdc Solution: In the Windows host, open the hdc server. The specific instructions are as follows: ``` - hdc kill - hdc -s serverIP:8710 -m + hdc kill + hdc -s serverIP:8710 -m ``` - Configure environment variables in linux: + Configure environment variables in linux: ``` - HDC_SERVER= - HDC_SERVER_PORT=8710 + HDC_SERVER= + HDC_SERVER_PORT=8710 ``` After the configuration is completed, the flutter sdk can complete the device connection through the hdc server. You can also refer to [official guidance](https://docs.openharmony.cn/pages/v4.0/zh-cn/device-dev/subsystems/subsys-toolchain -hdc-guide.md/#hdc-client%E5%A6%82%E4%BD%95%E8%BF%9C%E7%A8%8B%E8%AE%BF%E9%97%AEhdc-server) . -10. An error occurred when building the Hap task: Error: The hvigor depends on the npmrc file. Configure the npmrc file first. +6. An error occurred when building the Hap task: Error: The hvigor depends on the npmrc file. Configure the npmrc file first. Please create the file `.npmrc` in the user directory `~`. For this configuration, please refer to [DevEco Studio official documentation](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/environment_config -0000001052902427-V3), the edited content is as follows: ``` - registry=https://repo.huaweicloud.com/repository/npm/ - @ohos:registry=https://repo.harmonyos.com/npm/ + registry=https://repo.huaweicloud.com/repository/npm/ + @ohos:registry=https://repo.harmonyos.com/npm/ ``` -11. An error occurs when running a debug version of the Flutter application on a HarmonyOS device (release and profile versions are normal) +7. Symptom Logs are lost during log query。 + Solution:Disable global logs and enable only logs in your domain + + ``` + Step one:Disable log printing for all fields(Some special logs cannot be closed) + hdc shell hilog -b X + Step two:Open logs for your domain only + hdc shell hilog -D + indicates the level of log printing:D/I/W/E/F,is the number before the Tag + Example: + To print logs about 'A00000/XComFlutterOHOS_Native', set 'hdc shell hilog -b D -D A00000' + annotation:The above Settings will be invalid after the machine is restarted, and you need to reset them if you want to continue using them + ``` +8. If the debug signature application cannot be started on API 11BETA1, it can be resolved by changing the signature to an official signature or opening the developer mode on the mobile terminal (steps: Settings -> General -> Developer mode). + +9. If `Invalid CEN header (invalid zip64 extra data field size)` is abnormal, please replace the JDK version, see [JDK-8313765] + +10. An error occurs when running a debug version of the Flutter application on a HarmonyOS device (release and profile versions are normal) 1. Error message: `Error while initializing the Dart VM: Wrong full snapshot version, expected '8af474944053df1f0a3be6e6165fa7cf' found 'adb4292f3ec25074ca70abcd2d5c7251'` 2. Solution: Perform the following actions in sequence 1. Set environment variables `export FLUTTER_STORAGE_BASE_URL=https://flutter-ohos.obs.cn-south-1.myhuaweicloud.com` @@ -166,14 +187,68 @@ Attachment: [Flutter third-party library adaptation plan](https://docs.qq.com/sh 3. Execute `flutter run -d $DEVICE --debug` 3. Additional information: If a similar error occurs while running Android or iOS, you can also try restoring the environment variable FLUTTER_STORAGE_BASE_URL , clearing the cache, and then running again. -12. After the ROM update of Beta 2 version, it no longer supports requesting anonymous memory with execution permission, resulting in debug crashing. +11. After the ROM update of Beta 2 version, it no longer supports requesting anonymous memory with execution permission, resulting in debug crashing. 1. Solution: Update flutter_flutter to a version after a44b8a6d (2024-07-25). 2. Key logs: ``` - #20 at attachToNative (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterNapi.ets:78:32) - #21 at attachToNapi (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine.ets:144:5) - #22 at init (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine.ets:133:7) + #20 at attachToNative (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterNapi.ets:78:32) + #21 at attachToNapi (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine.ets:144:5) + #22 at init (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine.ets:133:7) ``` +12. Build Hap command directly execute `flutter build hap`, no longer need `--local-engine` parameter, directly from the cloud to obtain the compilation product + +13. After the environment is configured, the system crashes when the flutter command is executed。 + 1. Solution:Add git environment variable configuration in windows environment。 + ``` + export PATH=/cmd:$PATH + ``` + +14. If `flutter pub cache clean` is executed normally, `flutter clean` will report an error. If update command is executed according to the error message, it has no effect。 + 1. Solution:To avoid this problem, comment out the configuration in the build.json5 file。 + 2. Error message: + ``` + #Parse ohos module. json5 error: Exception: Can not found module.json5 at + #D:\pub_cache\git\flutter_packages-b00939bb44d018f0710d1b080d91dcf4c34ed06\packages\video_player\video_player_ohos\ohossrc\main\module.json5. + #You need to update the Flutter plugin project structure. + #See + #https://gitee.com/openharmony-sig/flutter_samples/tree/master/ohos/docs/09_specifications/update_flutter_plugin_structure.md + ``` + +15. An error message indicating path verification occurs when `flutter build hap` is executed。 + 1. Solution: + · Open the ohos-project-build-profile-schema.json file in deveco installation path D:\DevEco Studio\tools\hvigor\hvigor-ohos-plugin\res\schemas。 + · Find the line containing: "pattern": "^(\\./|\\.\\./)[\\s\\S]+$" in the file and delete it。 + 2. Error message: + ``` + #hvigor ERROR: Schema validate failed. + # Detail: Please check the following fields. + #instancePath: 'modules[1].scrPath', + #keyword: 'pattern' + #params: { pattern:'^(\\./|\\.\\./)[\\s\\S]+$' }, + #message: 'must match pattern "^(\\./|\\.\\./)[\\s\\S]+$"', + #location: 'D:/work/videoplayerdemo/video_cannot_stop_at_background/ohos/build-profile.json:42:146' + ``` + +16. Execute `flutter build hap` report an error。 + 1. Solution:Open the core-module-model-impl.js file in deveco installation path D:\DevEco Studio\tools\hvigor\hvigor-ohos-plugin\src\model\module。, + Modify the findBelongProjectPath method (requires administrator rights, can be saved as and replaced) + ``` + findBelongProjectPath(e) { + if (e === path_1.default.dirname(e)) { + return this.parentProject.getProjectDir() + } + } + ``` + 2. Error message: + ``` + # hvigor ERROR: Cannot find belonging project path for module at D:\. + # hvigor ERROR: BUILD FAILED in 2s 556ms. + #Running Hvigor task assembleHap... + #Oops; flutter has exited unexpectedly: "ProcessException: The command failed + # /bin:$PATH - export PUB_HOSTED_URL=https://pub.flutter-io.cn - export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn + export PUB_CACHE=D:/PUB + export PATH=/bin:$PATH + export PUB_HOSTED_URL=https://pub.flutter-io.cn + export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn ``` 3. `--local-engine` 成为可选参数,可以不传,默认从云端获取。 @@ -49,22 +49,22 @@ Flutter SDK 仓库 上述所有环境变量的配置(Windows下环境变量配置请在‘编辑系统环境变量’中设置),可参考下面的示例(其中user和具体代码路径请替换成实际路径): ```sh - #依赖缓存 - export PUB_CACHE=D:/PUB(自定义路径) - - # 国内镜像 - export PUB_HOSTED_URL=https://pub.flutter-io.cn - export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn - - # 拉取下来的flutter_flutter/bin目录 - export PATH=/home//ohos/flutter_flutter/bin:$PATH - - # HamonyOS SDK - export TOOL_HOME=/Applications/DevEco-Studio-5.0.3.300.app/Contents # mac环境 - export DEVECO_SDK_HOME=$TOOL_HOME/sdk # command-line-tools/sdk - export PATH=$TOOL_HOME/tools/ohpm/bin:$PATH # command-line-tools/ohpm/bin - export PATH=$TOOL_HOME/tools/hvigor/bin:$PATH # command-line-tools/hvigor/bin - export PATH=$TOOL_HOME/tools/node/bin:$PATH # command-line-tools/tool/node/bin + #依赖缓存 + export PUB_CACHE=D:/PUB(自定义路径) + + # 国内镜像 + export PUB_HOSTED_URL=https://pub.flutter-io.cn + export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn + + # 拉取下来的flutter_flutter/bin目录 + export PATH=/home//ohos/flutter_flutter/bin:$PATH + + # HamonyOS SDK + export TOOL_HOME=/Applications/DevEco-Studio-5.0.app/Contents # mac环境 + export DEVECO_SDK_HOME=$TOOL_HOME/sdk # command-line-tools/sdk + export PATH=$TOOL_HOME/tools/ohpm/bin:$PATH # command-line-tools/ohpm/bin + export PATH=$TOOL_HOME/tools/hvigor/bin:$PATH # command-line-tools/hvigor/bin + export PATH=$TOOL_HOME/tools/node/bin:$PATH # command-line-tools/tool/node/bin ``` @@ -75,27 +75,27 @@ Flutter SDK 仓库 2. 创建工程与编译命令,编译产物在\/ohos/entry/build/default/outputs/default/entry-default-signed.hap下。 ``` - # 创建工程 - flutter create --platforms ohos + # 创建工程 + flutter create --platforms ohos - # 进入工程根目录编译 - # 示例:flutter build hap [--target-platform ohos-arm64] [--local-engine=/src/out/ohos_release_arm64] --release - flutter build hap --release + # 进入工程根目录编译 + # 示例:flutter build hap [--target-platform ohos-arm64] [--local-engine=/src/out/ohos_release_arm64] --release + flutter build hap --release ``` 3. 通过`flutter devices`指令发现ohos设备之后,使用 `hdc -t install `进行安装。 4. 也可直接使用下列指令运行: -``` - # 示例:flutter run [--local-engine=/src/out/ohos_debug_unopt_arm64] -d - flutter run --debug -d -``` + ``` + # 示例:flutter run [--local-engine=/src/out/ohos_debug_unopt_arm64] -d + flutter run --debug -d + ``` 5. 构建app包命令: -``` - # 示例:flutter build app --release [--local-engine=/src/out/ohos_release_arm64] local-engine为可选项 - flutter build app --release -``` + ``` + # 示例:flutter build app --release [--local-engine=/src/out/ohos_release_arm64] local-engine为可选项 + flutter build app --release + ``` ## 已兼容OpenHarmony开发的指令列表 @@ -126,7 +126,7 @@ Flutter SDK 仓库 2. 若出现报错:`The SDK license agreement is not accepted`,参考执行以下命令后再次编译: ``` - ./ohsdkmgr install ets:9 js:9 native:9 previewer:9 toolchains:9 --sdk-directory='/home/xc/code/sdk/ohos-sdk/' --accept-license + ./ohsdkmgr install ets:9 js:9 native:9 previewer:9 toolchains:9 --sdk-directory='/home/xc/code/sdk/ohos-sdk/' --accept-license ``` 3. 如果你使用的是DevEco Studio的Beta版本,编译工程时遇到“must have required property 'compatibleSdkVersion', location: demo/ohos/build-profile.json5:17:11"错误,请参考《DevEco Studio环境配置指导.docx》中的‘6 创建工程和运行Hello World’【配置插件】章节修改 hvigor/hvigor-config.json5文件。 @@ -134,19 +134,19 @@ Flutter SDK 仓库 4. 若提示安装报错:`fail to verify pkcs7 file` 请执行指令 ``` - hdc shell param set persist.bms.ohCert.verify true + hdc shell param set persist.bms.ohCert.verify true ``` 5. linux虚拟机通过hdc无法直接发现OpenHarmony设备 解决方案:在windows宿主机中,开启hdc server,具体指令如下: ``` - hdc kill - hdc -s serverIP:8710 -m + hdc kill + hdc -s serverIP:8710 -m ``` - 在linux中配置环境变量: + 在linux中配置环境变量: ``` - HDC_SERVER= - HDC_SERVER_PORT=8710 + HDC_SERVER= + HDC_SERVER_PORT=8710 ``` 配置完成后flutter sdk可以通过hdc server完成设备连接,也可参考[官方指导](https://docs.openharmony.cn/pages/v4.0/zh-cn/device-dev/subsystems/subsys-toolchain-hdc-guide.md/#hdc-client%E5%A6%82%E4%BD%95%E8%BF%9C%E7%A8%8B%E8%AE%BF%E9%97%AEhdc-server)。 @@ -157,22 +157,22 @@ Flutter SDK 仓库 请在用户目录`~`下创建文件`.npmrc`,该配置也可参考[DevEco Studio官方文档](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/environment_config-0000001052902427-V3),编辑内容如下: ``` - registry=https://repo.huaweicloud.com/repository/npm/ - @ohos:registry=https://repo.harmonyos.com/npm/ + registry=https://repo.huaweicloud.com/repository/npm/ + @ohos:registry=https://repo.harmonyos.com/npm/ ``` 7. 查日志时,存在日志丢失现象。 解决方案:关闭全局日志,只打开自己领域的日志 ``` - 步骤一:关闭所有领域的日志打印(部分特殊日志无法关闭) - hdc shell hilog -b X - 步骤二:只打开自己领域的日志 - hdc shell hilog -D - 其中为日志打印的级别:D/I/W/E/F,为Tag前面的数字 - 举例: - 打印A00000/XComFlutterOHOS_Native的日志,需要设置hdc shell hilog -b D -D A00000 - 注:上面的设置在机器重启后会失效,如果要继续使用,需要重新设置。 + 步骤一:关闭所有领域的日志打印(部分特殊日志无法关闭) + hdc shell hilog -b X + 步骤二:只打开自己领域的日志 + hdc shell hilog -D + 其中为日志打印的级别:D/I/W/E/F,为Tag前面的数字 + 举例: + 打印A00000/XComFlutterOHOS_Native的日志,需要设置hdc shell hilog -b D -D A00000 + 注:上面的设置在机器重启后会失效,如果要继续使用,需要重新设置。 ``` 8. 若Api11 Beta1版本的机器上无法启动debug签名的应用,可以通过将签名换成正式签名,或在手机端打开开发者模式解决(步骤:设置->通用->开发者模式) @@ -192,28 +192,28 @@ Flutter SDK 仓库 2. 关键日志: ``` - #20 at attachToNative (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterNapi.ets:78:32) - #21 at attachToNapi (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine.ets:144:5) - #22 at init (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine.ets:133:7) + #20 at attachToNative (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterNapi.ets:78:32) + #21 at attachToNapi (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine.ets:144:5) + #22 at init (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine.ets:133:7) ``` 12. 构建Hap命令直接执行`flutter build hap`即可,不再需要`--local-engine`参数,直接从云端获取编译产物。 13. 配置环境完成后执行 flutter 命令 出现闪退。 - 1. 解决方案:更新 flutter_flutter 到 a44b8a6d (2024-07-25) 之后的版本。 + 1. 解决方案:windows环境中添加git环境变量配置。 ``` - export PATH=/cmd:$PATH + export PATH=/cmd:$PATH ``` 14. 执行`flutter pub cache clean` 正常 执行`flutter clean` 报错,按照报错信息执行 update 命令也没有效果。 1. 解决方案:通过注释掉 build.json5 文件中的配置规避。 2. 报错信息: ``` - #Parse ohos module. json5 error: Exception: Can not found module.json5 at - #D:\pub_cache\git\flutter_packages-b00939bb44d018f0710d1b080d91dcf4c34ed06\packages\video_player\video_player_ohos\ohossrc\main\module.json5. - #You need to update the Flutter plugin project structure. - #See - #https://gitee.com/openharmony-sig/flutter_samples/tree/master/ohos/docs/09_specifications/update_flutter_plugin_structure.md + #Parse ohos module. json5 error: Exception: Can not found module.json5 at + #D:\pub_cache\git\flutter_packages-b00939bb44d018f0710d1b080d91dcf4c34ed06\packages\video_player\video_player_ohos\ohossrc\main\module.json5. + #You need to update the Flutter plugin project structure. + #See + #https://gitee.com/openharmony-sig/flutter_samples/tree/master/ohos/docs/09_specifications/update_flutter_plugin_structure.md ``` 15. 执行`flutter build hap` 时遇到路径校验报错。 @@ -222,33 +222,33 @@ Flutter SDK 仓库 ·在该文件中找到包含:"pattern": "^(\\./|\\.\\./)[\\s\\S]+$"的行,并删除此行。 2. 报错信息: ``` - #hvigor ERROR: Schema validate failed. - # Detail: Please check the following fields. - #instancePath: 'modules[1].scrPath', - #keyword: 'pattern' - #params: { pattern:'^(\\./|\\.\\./)[\\s\\S]+$' }, - #message: 'must match pattern "^(\\./|\\.\\./)[\\s\\S]+$"', - #location: 'D:/work/videoplayerdemo/video_cannot_stop_at_background/ohos/build-profile.json:42:146' + #hvigor ERROR: Schema validate failed. + # Detail: Please check the following fields. + #instancePath: 'modules[1].scrPath', + #keyword: 'pattern' + #params: { pattern:'^(\\./|\\.\\./)[\\s\\S]+$' }, + #message: 'must match pattern "^(\\./|\\.\\./)[\\s\\S]+$"', + #location: 'D:/work/videoplayerdemo/video_cannot_stop_at_background/ohos/build-profile.json:42:146' ``` 16. 执行`flutter build hap` 报错。 1. 解决方案:打开 deveco 安装路径 D:\DevEco Studio\tools\hvigor\hvigor-ohos-plugin\src\model\module 下的 core-module-model-impl.js, 修改 findBelongProjectPath 方法(需要管理员权限,可另存为后替换) ``` - findBelongProjectPath(e) { - if (e === path_1.default.dirname(e)) { - return this.parentProject.getProjectDir() - } - } + findBelongProjectPath(e) { + if (e === path_1.default.dirname(e)) { + return this.parentProject.getProjectDir() + } + } ``` 2. 报错信息: - ``` - # hvigor ERROR: Cannot find belonging project path for module at D:\. - # hvigor ERROR: BUILD FAILED in 2s 556ms. - #Running Hvigor task assembleHap... - #Oops; flutter has exited unexpectedly: "ProcessException: The command failed - # Date: Thu, 22 Aug 2024 22:06:08 +0800 Subject: [PATCH 28/38] =?UTF-8?q?readme=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuja <542689970@qq.com> --- README.en.md | 4 ++-- README.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.en.md b/README.en.md index a5c8f7445c..401cf1519c 100644 --- a/README.en.md +++ b/README.en.md @@ -17,7 +17,7 @@ This repository is a compatible extension of Flutter SDK for the OpenHarmony pla * Environment configuration - **Please give priority to downloading the supporting development tools from [OpenHarmony SDK](https://developer.huawei.com/consumer/cn/develop) Download the matching development tool,Suites that are not downloaded through this channel are not supported** + **Please download the supporting development tool from [OpenHarmony SDK](https://developer.huawei.com/consumer/cn/develop)** *The following environment variable configuration is for Unix-like systems (Linux, Mac). You can directly refer to the configuration below. For environment variable configuration under Windows, please set it in ‘Edit System Environment Variables’* 1. Configure the HarmonyOS SDK and environment variables @@ -62,7 +62,7 @@ This repository is a compatible extension of Flutter SDK for the OpenHarmony pla export PATH=/home//ohos/flutter_flutter/bin:$PATH # HarmonyOS SDK - export TOOL_HOME=/Applications/DevEco-Studio-5.0.app/Contents # For mac + export TOOL_HOME=/Applications/DevEco-Studio.app/Contents # For mac export DEVECO_SDK_HOME=$TOOL_HOME/sdk # command-line-tools/sdk export PATH=$TOOL_HOME/tools/ohpm/bin:$PATH # command-line-tools/ohpm/bin export PATH=$TOOL_HOME/tools/hvigor/bin:$PATH # command-line-tools/hvigor/bin diff --git a/README.md b/README.md index e083aa8404..3d2701d81d 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Flutter SDK 仓库 Flutter Tools指令目前已支持在Linux、Mac和Windows下使用。 * 环境配置 - **请优先从[鸿蒙SDK](https://developer.huawei.com/consumer/cn/develop)下载配套开发工具,暂不支持非该渠道下载的套件** + **请从[鸿蒙SDK](https://developer.huawei.com/consumer/cn/develop)下载配套开发工具** *下列环境变量配置,类Unix系统(Linux、Mac),下可直接参照配置,Windows下环境变量配置请在‘编辑系统环境变量’中设置* 1. 配置HarmonyOS SDK和环境变量 @@ -60,7 +60,7 @@ Flutter SDK 仓库 export PATH=/home//ohos/flutter_flutter/bin:$PATH # HamonyOS SDK - export TOOL_HOME=/Applications/DevEco-Studio-5.0.app/Contents # mac环境 + export TOOL_HOME=/Applications/DevEco-Studio.app/Contents # mac环境 export DEVECO_SDK_HOME=$TOOL_HOME/sdk # command-line-tools/sdk export PATH=$TOOL_HOME/tools/ohpm/bin:$PATH # command-line-tools/ohpm/bin export PATH=$TOOL_HOME/tools/hvigor/bin:$PATH # command-line-tools/hvigor/bin -- Gitee From 49d346510646eebf5f9c3f20deb0ff9db059ab6a Mon Sep 17 00:00:00 2001 From: liuja <542689970@qq.com> Date: Fri, 23 Aug 2024 17:11:08 +0800 Subject: [PATCH 29/38] =?UTF-8?q?README=20FAQ=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuja <542689970@qq.com> --- README.en.md | 7 +++++++ README.md | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/README.en.md b/README.en.md index 401cf1519c..c66a83deec 100644 --- a/README.en.md +++ b/README.en.md @@ -250,5 +250,12 @@ Attachment: [Flutter third-party library adaptation plan](https://docs.qq.com/sh # Date: Fri, 23 Aug 2024 17:13:28 +0800 Subject: [PATCH 30/38] =?UTF-8?q?=E6=8B=AC=E5=8F=B7=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuja <542689970@qq.com> --- README.en.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.en.md b/README.en.md index c66a83deec..3d63edb79e 100644 --- a/README.en.md +++ b/README.en.md @@ -165,7 +165,7 @@ Attachment: [Flutter third-party library adaptation plan](https://docs.qq.com/sh Solution:Disable global logs and enable only logs in your domain ``` - Step one:Disable log printing for all fields(Some special logs cannot be closed) + Step one:Disable log printing for all fields(Some special logs cannot be closed) hdc shell hilog -b X Step two:Open logs for your domain only hdc shell hilog -D -- Gitee From 677a2de9c3a71acad1cf9ad3ac889ed95a5fe6d0 Mon Sep 17 00:00:00 2001 From: liuja <542689970@qq.com> Date: Fri, 23 Aug 2024 17:19:59 +0800 Subject: [PATCH 31/38] =?UTF-8?q?=E8=A1=8C=E9=97=B4=E8=B7=9D=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuja <542689970@qq.com> --- README.en.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.en.md b/README.en.md index 3d63edb79e..092c7820e6 100644 --- a/README.en.md +++ b/README.en.md @@ -250,6 +250,7 @@ Attachment: [Flutter third-party library adaptation plan](https://docs.qq.com/sh # Date: Fri, 23 Aug 2024 20:12:38 +0800 Subject: [PATCH 32/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=AD=E6=96=87?= =?UTF-8?q?=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuja <542689970@qq.com> --- README.en.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.en.md b/README.en.md index 092c7820e6..88d4bf355c 100644 --- a/README.en.md +++ b/README.en.md @@ -255,7 +255,7 @@ Attachment: [Flutter third-party library adaptation plan](https://docs.qq.com/sh 1. Solution:Delete the .ohos folder and execute `flutter pub get` again 2. Error message: ``` - Oops; flutter has exited unexpectedly: "PathNotFoundException: Cannot open file, path = 'D:\code\.ohos\build-profile.json5' (OS Error: 系统找不到指定的文件。,error = 2)". + Oops; flutter has exited unexpectedly: "PathNotFoundException: Cannot open file, path = 'D:\code\.ohos\build-profile.json5' (OS Error: The system cannot find the specified file。,error = 2)". A crash report has been written to D:\code\flutter_01.log. ``` -- Gitee From 89c04bf5059bd4cd2fb8ba954304826ef72b6138 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Fri, 23 Aug 2024 21:36:30 +0800 Subject: [PATCH 33/38] revert pr_304 Signed-off-by: hezhengyi --- .../flutter_tools/lib/src/ohos/hvigor.dart | 42 ++++++------------- 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/packages/flutter_tools/lib/src/ohos/hvigor.dart b/packages/flutter_tools/lib/src/ohos/hvigor.dart index d6a9f35270..bea955b09b 100644 --- a/packages/flutter_tools/lib/src/ohos/hvigor.dart +++ b/packages/flutter_tools/lib/src/ohos/hvigor.dart @@ -199,36 +199,18 @@ Future assembleHar( required String buildMode, String product = 'default', Logger? logger}) async { - final List command = []; - if (buildMode.compareTo('debug') == 0 || buildMode.compareTo('release') == 0) { - command.addAll([ - hvigorwPath, - '--mode', - 'module', - '-p', - 'module=$moduleName', - '-p', - 'product=$product', - '-p', - 'buildMode=$buildMode', - 'assembleHar', - '--no-daemon', - ]); - } else { - command.addAll([ - hvigorwPath, - '--mode', - 'module', - '-p', - 'module=$moduleName', - '-p', - 'product=$product', - '-p', - 'buildMode=debug', - 'assembleHar', - '--no-daemon', - ]); - } + final List command = [ + hvigorwPath, + // 'clean', + '--mode', + 'module', + '-p', + 'module=$moduleName', + '-p', + 'product=$product', + 'assembleHar', + '--no-daemon', + ]; return hvigorwTask(command, processUtils: processUtils, workPath: workPath, -- Gitee From dd5811465436b4a6091545fe76319fe547ae59b4 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Fri, 23 Aug 2024 21:37:18 +0800 Subject: [PATCH 34/38] =?UTF-8?q?=E6=9B=B4=E6=96=B0readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hezhengyi --- README.en.md | 4 ++++ README.md | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/README.en.md b/README.en.md index 401cf1519c..e0297bda58 100644 --- a/README.en.md +++ b/README.en.md @@ -15,6 +15,10 @@ This repository is a compatible extension of Flutter SDK for the OpenHarmony pla Flutter Tools commands are currently supported on Linux, Mac and Windows. +* development limitations + + The Flutter project and dependent plugin projects in the Windows environment need to be on the same disk. + * Environment configuration **Please download the supporting development tool from [OpenHarmony SDK](https://developer.huawei.com/consumer/cn/develop)** diff --git a/README.md b/README.md index 3d2701d81d..afffdf3853 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,10 @@ Flutter SDK 仓库 Flutter Tools指令目前已支持在Linux、Mac和Windows下使用。 +* 开发限制 + + Windows环境下flutter工程和依赖的插件工程需要在同一个磁盘。 + * 环境配置 **请从[鸿蒙SDK](https://developer.huawei.com/consumer/cn/develop)下载配套开发工具** *下列环境变量配置,类Unix系统(Linux、Mac),下可直接参照配置,Windows下环境变量配置请在‘编辑系统环境变量’中设置* -- Gitee From 1deb00b3dc0be96db7659579acfc21b264967b6e Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Fri, 23 Aug 2024 22:42:24 +0800 Subject: [PATCH 35/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9flutter=E9=B8=BF?= =?UTF-8?q?=E8=92=99=E5=8C=96=E7=89=88=E6=9C=AC=E8=A7=A3=E6=9E=90=E8=A7=84?= =?UTF-8?q?=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hezhengyi --- packages/flutter_tools/lib/src/version.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/flutter_tools/lib/src/version.dart b/packages/flutter_tools/lib/src/version.dart index 162bb0a59e..883eff4802 100644 --- a/packages/flutter_tools/lib/src/version.dart +++ b/packages/flutter_tools/lib/src/version.dart @@ -799,7 +799,7 @@ class GitTagVersion { static GitTagVersion parseOhosVersion(String version) { final RegExp versionPattern = RegExp( - r'^(\d+)\.(\d+)\.(\d+)(-ohos)?(?:-(\d+)-g([a-f0-9]+))?$'); + r'^(\d+)\.(\d+)\.(\d+)(-ohos-\d+\.\d+\.\d+)?(?:-(\d+)-g([a-f0-9]+))?$'); final Match? match = versionPattern.firstMatch(version.trim()); if (match == null) { return const GitTagVersion.unknown(); @@ -821,7 +821,7 @@ class GitTagVersion { z: z, commits: commits, hash: hash, - gitTag: '$x.$y.$z${devString ?? ''}', // e.g. 1.2.3-ohos + gitTag: '$x.$y.$z${devString ?? ''}', // e.g. 3.7.12-ohos-1.0.0 ); } -- Gitee From 13e43f33140392098fbc59c9ba0d07cca48fb956 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Sat, 24 Aug 2024 09:52:33 +0800 Subject: [PATCH 36/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9flutter=E9=B8=BF?= =?UTF-8?q?=E8=92=99=E5=8C=96=E7=89=88=E6=9C=AC=E8=A7=A3=E6=9E=90=E8=A7=84?= =?UTF-8?q?=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hezhengyi --- packages/flutter_tools/lib/src/version.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/flutter_tools/lib/src/version.dart b/packages/flutter_tools/lib/src/version.dart index 883eff4802..f7dd6011da 100644 --- a/packages/flutter_tools/lib/src/version.dart +++ b/packages/flutter_tools/lib/src/version.dart @@ -799,21 +799,21 @@ class GitTagVersion { static GitTagVersion parseOhosVersion(String version) { final RegExp versionPattern = RegExp( - r'^(\d+)\.(\d+)\.(\d+)(-ohos-\d+\.\d+\.\d+)?(?:-(\d+)-g([a-f0-9]+))?$'); + r'^(\d+)\.(\d+)\.(\d+)(-ohos(-\d+\.\d+\.\d+)?)?(?:-(\d+)-g([a-f0-9]+))?$'); final Match? match = versionPattern.firstMatch(version.trim()); if (match == null) { return const GitTagVersion.unknown(); } - final List matchGroups = match.groups([1, 2, 3, 4, 5, 6]); + final List matchGroups = match.groups([1, 2, 3, 4, 5, 6, 7]); final int? x = matchGroups[0] == null ? null : int.tryParse(matchGroups[0]!); final int? y = matchGroups[1] == null ? null : int.tryParse(matchGroups[1]!); final int? z = matchGroups[2] == null ? null : int.tryParse(matchGroups[2]!); final String? devString = matchGroups[3]; // count of commits past last tagged version - final int? commits = matchGroups[4] == null ? 0 : int.tryParse(matchGroups[4]!); - final String hash = matchGroups[5] ?? ''; + final int? commits = matchGroups[5] == null ? 0 : int.tryParse(matchGroups[5]!); + final String hash = matchGroups[6] ?? ''; return GitTagVersion( x: x, -- Gitee From 7ede20dc69f46e084408c6c3e1eeb3ac4c207c3d Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Sat, 24 Aug 2024 14:02:27 +0800 Subject: [PATCH 37/38] update engine to 8ef94277 Signed-off-by: hezhengyi --- bin/internal/engine.ohos.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/internal/engine.ohos.version b/bin/internal/engine.ohos.version index f926b73388..d57635ec41 100644 --- a/bin/internal/engine.ohos.version +++ b/bin/internal/engine.ohos.version @@ -1 +1 @@ -c2bfbb6906a066340d8597c0479885c6c3fc2643 \ No newline at end of file +8ef94277f0029e61ff6a96f630d0f10b60330cd8 \ No newline at end of file -- Gitee From 4993e12fdee18982ae907ec387a0ed7ac561862b Mon Sep 17 00:00:00 2001 From: lihiu868 Date: Sat, 24 Aug 2024 19:01:51 +0800 Subject: [PATCH 38/38] invoke checkUpdate method while dragstate is accepted. Signed-off-by: lihiu868 --- packages/flutter/lib/src/gestures/monodrag.dart | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/flutter/lib/src/gestures/monodrag.dart b/packages/flutter/lib/src/gestures/monodrag.dart index 15e6d5e9d6..f7a8bc49fb 100644 --- a/packages/flutter/lib/src/gestures/monodrag.dart +++ b/packages/flutter/lib/src/gestures/monodrag.dart @@ -347,6 +347,13 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer { ).distance * (_getPrimaryValueFromOffset(movedLocally) ?? 1).sign; if (_hasSufficientGlobalDistanceToAccept(event.kind, gestureSettings?.touchSlop)) { resolve(GestureDisposition.accepted); + _checkUpdate( + sourceTimeStamp: event.timeStamp, + delta: movedLocally, + primaryDelta: _getPrimaryValueFromOffset(localDelta), + globalPosition: position, + localPosition: localPosition, + ); } } } -- Gitee