diff --git a/README.en.md b/README.en.md index de839b063496849b2704f24da7f9ea2ae30e3f76..4838e7096d7db0e0fbf2b755fcf0ca1d6962675d 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 4807cfb3ddb9ae09f2ef665e0a7711cfb2637eae..f934136f5a8b4c6c22eb12c1231b5f39b1671644 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) diff --git a/packages/flutter_tools/lib/src/ohos/hvigor.dart b/packages/flutter_tools/lib/src/ohos/hvigor.dart index cd59457d2904a7290290504e3f330349a49c1501..bea955b09bbda8e14a4d6a3b970b81b5b364ca15 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 0a89fe2dd6c1de1d0b04f9aafa7a190d9d7d772f..e4e8e2ddf57b3699a964bf7ac1f81b890b1c2867 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'\', '/'); -}