From 90b24891ea53aa19e56c8d5018c21ec8c9bda435 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rulong=20Chen=EF=BC=88=E9=99=88=E6=B1=9D=E9=BE=99=EF=BC=89?= Date: Fri, 23 Feb 2024 23:30:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=81=A2=E5=A4=8D=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E7=AD=BE=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit c66b702282fc9f7a262d5fbf03604f85bcf59a37. --- README.en.md | 61 +++++++++++++++ README.md | 74 ++++++++++++++++++- .../flutter_tools/lib/src/ohos/hvigor.dart | 13 +++- 3 files changed, 142 insertions(+), 6 deletions(-) diff --git a/README.en.md b/README.en.md index f24e94ff0c..8c9fc2a23f 100644 --- a/README.en.md +++ b/README.en.md @@ -56,6 +56,7 @@ This repository is a compatible extension of Flutter SDK for the OpenHarmony pla 2. The application build relies on [Flutter Engine](https://github.com/flutter/engine) to build products: `ohos_debug_unopt_arm64` and `ohos_release_arm64`. Please add: `--local-engine= in the Flutter Tools command running parameters. --local-engine=src/out/`. Can be downloaded at this path [Compiled product](https://docs.qq.com/sheet/DUnljRVBYUWZKZEtF?tab=BB08J2) + 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): ``` @@ -77,6 +78,66 @@ This repository is a compatible extension of Flutter SDK for the OpenHarmony pla export PATH=$NODE_HOME/bin:$PATH ``` + 3. Signature + + You can sign the application using either of the following two methods. + + (1) Signing with `Deveco Studio` + + - Open the ohos directory of the project using Deveco Studio. + - Click on File > Project Structure > Project > Signing Configs. Check the Automatically generate signature option, wait for the automatic signing process to complete, and then click OK. + - Review the configuration information in build-profile.json5. Add the certificate information generated from the automatic signing process to the configuration. + + (2) Signing with signing tool + + - Download [Signature Tool](https://gitee.com/openharmony/developtools_hapsigner), and checkout a specific version as below: + ``` + git clone git@gitee.com:openharmony/developtools_hapsigner.git + git checkout 997e4824de4028f55521d00c8c3523713fbb5580 + ``` + + - Configure the environment variable `SIGN_TOOL_HOME` + ``` + export SIGN_TOOL_HOME=/home//ohos/developtools_hapsigner/autosign + ``` + - Execute the gradle command to compile and obtain hap-sign-tool.jar. Make sure it is in thedirectory: ./ hapsigntool/hap_sign_tool/build/libs/hap-sign-tool.jar. (gradle version recommended 7.x) + ``` + gradle build + ``` + - Edit the `autosign.config` and `createAppCertAndProfile.config` files in the autosign directory andmodify their values: + ``` + sign.profile.inFile=profile_tmp.json + ``` + - In the autosign directory (the command `chmod 777 *.sh` must be executed first in linux and macenvironments, and there is no need to execute this command in Windows environment), add the`profile_tmp_template.json` file and edit it as follows: + ``` + { + "version-name": "2.0.0", + "version-code": 2, + "app-distribution-type": "os_integration", + "uuid": "5027b99e-5f9e-465d-9508-a9e0134ffe18", + "validity": { + "not-before": 1594865258, + "not-after": 1689473258 + }, + "type": "release", + "bundle-info": { + "developer-id": "OpenHarmony", + "distribution-certificate": "-----BEGIN CERTIFICATE-----\nMIICSTCCA +gAwIBAgIFAJV7uNUwCgYIKoZIzj0EAwIwYzELMAkGA1UEBhMCQ04x\nFDASBgNVBAoMC09wZW5IYXJtb255MRkwFwYDVQLDBB PcGVuSGFybW9ueS BUZWTZMBcGA1UECwwQT3Blbkhhcm1vbnkgVGVhbTEoMCYGA1UEAwwf\nT3Blbkhhcm1vbnkgQXBwbGljYXRpb24gUmVsZWFzZT ZMBMGByqGSM49AgEGCCqG\nSM49AwEHA0IABAW8pFu7tHGUuWtddD5wvazc1qN8t s9UPZH4pecbb/ bSFWKh7X7R\neTVaRrCTSSdovI1dhoV5GjuFsKW+jT2TwSjazBpMB0GA1UdDgQWBBScyywAaAMj\nI7HcuIS42lvZx0L +zAJBgNVHRMEAjAAMA4GA1UdDwEB/ wQEAwIHgDATBgNVHSUE\nDDAKBggrBgEFBQcDAzAYBgwrBgEEAY9bAoJ4AQMECDAGAgEBCgEAMAoGCCqGSM49\nBAMCA2gAMGU CFfNidGo6uK6KGTzT1T5bY1NCHTH3P3muy5X1xudOgxWoOqIbnk\ntmQYB78dxWEHLQIxANfApAlXAD/ 0hnyNC8RDzfLOPEeay6jU9FXJj3AoR90rwZpR\noN9sYD6Oks4VGRw6yQ==\n-----END CERTIFICATE-----\n", + "bundle-name": "{{ohosId}}", + "apl": "normal", + "app-feature": "hos_normal_app" + }, + "acls": { + "allowed-acls": [ + "" + ] + }, + "permissions": { + "restricted-permissions": [] + }, + "issuer": "pki_internal" + } + ``` ## Build steps 1. Run `flutter doctor -v` to check whether the environment variable configuration is correct. **Futter** and **OpenHarmony** should both be ok. If the two prompts indicate that the environment is missing, just follow the prompts to fill in the corresponding environment. diff --git a/README.md b/README.md index 355fb27397..f3805e5df3 100644 --- a/README.md +++ b/README.md @@ -51,8 +51,75 @@ Flutter SDK 仓库 export PUB_HOSTED_URL=https://pub.flutter-io.cn export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn ``` - - 3. 应用构建依赖[Flutter Engine](https://github.com/flutter/engine)构建产物:`ohos_debug_unopt_arm64` 与 `ohos_release_arm64`,请在Flutter Tools指令运行参数中添加:`--local-engine=src/out/` 可在该路径下载[编译产物](https://docs.qq.com/sheet/DUnljRVBYUWZKZEtF?tab=BB08J2),engine路径指向需带上`src/out`目录 + + 3. 应用签名 + + 可以通过下面任意一种方式对应用进行签名。 + + - (1) 使用 `Deveco Studio` 签名 + + - 用 `Deveco Studio` 打开项目的 `ohos` 目录 + - 单击 `File > Project Structure > Project > Signing Configs` 界面勾选 `Automatically generate signature`,等待自动签名完成即可,单击 `OK`。 + - 查看 `build-profile.json5` 配置信息,配置信息中增加自动签名生成的证书信息。 + + - (2) 使用 [签名工具](https://gitee.com/openharmony/developtools_hapsigner) 签名 + + - 下载[签名工具](https://gitee.com/openharmony/developtools_hapsigner),检出到特定版本,如下: + ``` + git clone git@gitee.com:openharmony/developtools_hapsigner.git + git checkout 997e4824de4028f55521d00c8c3523713fbb5580 + ``` + + - 配置环境变量`SIGN_TOOL_HOME`。 + + ``` + export SIGN_TOOL_HOME=/home//ohos/developtools_hapsigner/autosign + ``` + + - 执行gradle命令编译得到hap-sign-tool.jar,确保其在目录:./hapsigntool/hap_sign_tool/build/libs/hap-sign-tool.jar。(gradle版本推荐7.x) + + ``` + gradle build + ``` + + - 编辑autosign目录下`autosign.config`和`createAppCertAndProfile.config`文件,并修改其中值: + + ``` + sign.profile.inFile=profile_tmp.json + ``` + + - 在autosign目录下( linux和mac环境下须先执行命令 `chmod 777 *.sh` ,Windows环境下无需执行此命令 ),新增`profile_tmp_template.json`文件,编辑如下: + + ``` + { + "version-name": "2.0.0", + "version-code": 2, + "app-distribution-type": "os_integration", + "uuid": "5027b99e-5f9e-465d-9508-a9e0134ffe18", + "validity": { + "not-before": 1594865258, + "not-after": 1689473258 + }, + "type": "release", + "bundle-info": { + "developer-id": "OpenHarmony", + "distribution-certificate": "-----BEGIN CERTIFICATE-----\nMIICSTCCAc+gAwIBAgIFAJV7uNUwCgYIKoZIzj0EAwIwYzELMAkGA1UEBhMCQ04x\nFDASBgNVBAoMC09wZW5IYXJtb255MRkwFwYDVQQLDBBPcGVuSGFybW9ueSBUZWFt\nMSMwIQYDVQQDDBpPcGVuSGFybW9ueSBBcHBsaWNhdGlvbiBDQTAeFw0yMjAxMjkw\nNTU0MTRaFw0yMzAxMjkwNTU0MTRaMGgxCzAJBgNVBAYTAkNOMRQwEgYDVQQKDAtP\ncGVuSGFybW9ueTEZMBcGA1UECwwQT3Blbkhhcm1vbnkgVGVhbTEoMCYGA1UEAwwf\nT3Blbkhhcm1vbnkgQXBwbGljYXRpb24gUmVsZWFzZTBZMBMGByqGSM49AgEGCCqG\nSM49AwEHA0IABAW8pFu7tHGUuWtddD5wvazc1qN8ts9UPZH4pecbb/bSFWKh7X7R\n/eTVaRrCTSSdovI1dhoV5GjuFsKW+jT2TwSjazBpMB0GA1UdDgQWBBScyywAaAMj\nI7HcuIS42lvZx0Lj+zAJBgNVHRMEAjAAMA4GA1UdDwEB/wQEAwIHgDATBgNVHSUE\nDDAKBggrBgEFBQcDAzAYBgwrBgEEAY9bAoJ4AQMECDAGAgEBCgEAMAoGCCqGSM49\nBAMCA2gAMGUCMFfNidGo6uK6KGT9zT1T5bY1NCHTH3P3muy5X1xudOgxWoOqIbnk\ntmQYB78dxWEHLQIxANfApAlXAD/0hnyNC8RDzfLOPEeay6jU9FXJj3AoR90rwZpR\noN9sYD6Oks4VGRw6yQ==\n-----END CERTIFICATE-----\n", + "bundle-name": "{{ohosId}}", + "apl": "normal", + "app-feature": "hos_normal_app" + }, + "acls": { + "allowed-acls": [ + "" + ] + }, + "permissions": { + "restricted-permissions": [] + }, + "issuer": "pki_internal" + } + ``` + 4. 应用构建依赖[Flutter Engine](https://github.com/flutter/engine)构建产物:`ohos_debug_unopt_arm64` 与 `ohos_release_arm64`,请在Flutter Tools指令运行参数中添加:`--local-engine=src/out/` 可在该路径下载[编译产物](https://docs.qq.com/sheet/DUnljRVBYUWZKZEtF?tab=BB08J2),engine路径指向需带上`src/out`目录 上述所有环境变量的配置(Windows下环境变量配置请在‘编辑系统环境变量’中设置),可参考下面的示例(其中user和具体代码路径请替换成实际路径): @@ -70,6 +137,9 @@ Flutter SDK 仓库 # HarmonyOS SDK,步骤1中解压开发套件包中 sdk/xxSDK.zip 之后的目录 export HOS_SDK_HOME=/home//ohos/sdk + # 签名工具 + export SIGN_TOOL_HOME=/home//ohos/developtools_hapsigner/autosign + # nodejs export NODE_HOME=/home//env/node-v14.19.1-linux-x64 export PATH=$NODE_HOME/bin:$PATH diff --git a/packages/flutter_tools/lib/src/ohos/hvigor.dart b/packages/flutter_tools/lib/src/ohos/hvigor.dart index 5f95ae4cf1..a32c6ef764 100644 --- a/packages/flutter_tools/lib/src/ohos/hvigor.dart +++ b/packages/flutter_tools/lib/src/ohos/hvigor.dart @@ -724,16 +724,21 @@ class OhosHvigorBuilder implements OhosBuilder { final String buildProfileConfig = buildProfile.readAsStringSync(); final dynamic obj = JSON5.parse(buildProfileConfig); dynamic signingConfigs = obj['app']?['signingConfigs']; - if (signingConfigs is List && signingConfigs.isEmpty) { - logger?.printError('请通过DevEco Studio打开ohos工程后配置调试签名(File -> Project Structure -> Signing Configs 勾选Automatically generate signature)'); - return; - } if (signingConfigs is List && signingConfigs.isNotEmpty) { final File signedFile = globals.localFileSystem.file(desSignedFile); if (signedFile.existsSync()) { return; } } + + final String unsignedFile = globals.fs.path.join( + ohosRootPath, + ohosProject.mainModuleName, + 'build/default/outputs/default', + 'entry-default-unsigned.hap'); + + await signHap(globals.localFileSystem, unsignedFile, desSignedFile, logger, + ohosBuildData.appInfo!.bundleName); } Future flutterBuildPre( -- Gitee From 96209ccdade23d5c569e0909d91946a0a488c1e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rulong=20Chen=EF=BC=88=E9=99=88=E6=B1=9D=E9=BE=99=EF=BC=89?= Date: Sat, 24 Feb 2024 00:33:40 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=9D=99=E6=80=81?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A3=80=E6=9F=A5=E5=A4=B1=E8=B4=A5=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 错误信息如下: WordsTool.91 flutter Words or descriptive texts in open source code should be common or original in the industry, and descriptions that may cause ambiguity should be avoided. --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f3805e5df3..ae0b2e1420 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,13 @@ Flutter SDK 仓库 "issuer": "pki_internal" } ``` - 4. 应用构建依赖[Flutter Engine](https://github.com/flutter/engine)构建产物:`ohos_debug_unopt_arm64` 与 `ohos_release_arm64`,请在Flutter Tools指令运行参数中添加:`--local-engine=src/out/` 可在该路径下载[编译产物](https://docs.qq.com/sheet/DUnljRVBYUWZKZEtF?tab=BB08J2),engine路径指向需带上`src/out`目录 + 4. 应用构建依赖[Flutter Engine](https://github.com/flutter/engine)构建产物。如使用本地引擎,请在`Flutter Tools`指令中添加`--local-engine`相关参数,例如: + ``` + flutter run --local-engine-src-path=path/to/my/engine/src --local-engine=ohos_debug_unopt_arm64 --debug + flutter run --local-engine-src-path=path/to/my/engine/src --local-engine=ohos_profile_arm64 --profile + flutter run --local-engine-src-path=path/to/my/engine/src --local-engine=ohos_release_arm64 --release + ``` + >可在该路径下载[编译产物](https://docs.qq.com/sheet/DUnljRVBYUWZKZEtF?tab=BB08J2) 上述所有环境变量的配置(Windows下环境变量配置请在‘编辑系统环境变量’中设置),可参考下面的示例(其中user和具体代码路径请替换成实际路径): -- Gitee