想把上架的 uniapp 小程序迁移到鸿蒙,结果一打包,ERROR × 3,WARN × 519,所以就简单记录一下解决这些错误的过程。
首先先解决错误吧,错误的主要报错如下:
1 ERROR: ArkTS:ERROR File: //?/E:/Projects/uniapp/x/crystal-chest/crystal-chest/unpackage/release/cn.techfanyi.crystalchest/oh_modules/.ohpm/@ohos+videocompressor@soegz02lhnnihit14ad03wcy4dhlg8y+cdslhkqxb5s=/oh_modules/@ohos/videocompressor/src/main/ets/components/mainpage/CompressorResponse.ets
A page configured in 'main_pages.json or build-profile.json5' must have one and only one '@Entry' decorator.
* Try the following:
> Please make sure that the splash page has one and only one '@Entry' decorator.
2 ERROR: ArkTS:ERROR File: //?/E:/Projects/uniapp/x/crystal-chest/crystal-chest/unpackage/release/cn.techfanyi.crystalchest/oh_modules/.ohpm/@ohos+videocompressor@soegz02lhnnihit14ad03wcy4dhlg8y+cdslhkqxb5s=/oh_modules/@ohos/videocompressor/src/main/ets/components/mainpage/VideoCompressor.ets
A page configured in 'main_pages.json or build-profile.json5' must have one and only one '@Entry' decorator.
* Try the following:
> Please make sure that the splash page has one and only one '@Entry' decorator.
COMPILE RESULT:FAIL {ERROR:3 WARN:519}
* Try the following:
> Check whether undefined attributes or methods are used in the hvigorconfig.ts and hvigorfile.ts files.
> Go to the official website for help
> More info: https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/ide-hvigor-faqs-V5#section119742124315
> hvigor ERROR: BUILD FAILED in 44 s 145 ms
13:23:21.003 安装包制作失败
两个错误都是因为
A page configured in 'main_pages.json or build-profile.json5' must have one and only one '@Entry' decorator.
// 在 "main_pages.json 或 build-profile.json5 "中配置的页面必须有且仅有一个"@Entry "装饰器。
给出的建议是:
Please make sure that the splash page has one and only one '@Entry' decorator.
// 请确保闪屏页面只有一个"@Entry "装饰器。
去 Dcloud 论坛看到大概率是因为是项目路径里包含特殊字符,或者项目路径比较深(鸿蒙的项目某一个 ets 到盘符的路径超过 255 个字符就会编译 arkts 失败),会导致鸿蒙工具链执行异常。
也就是说,我现在的目录是 E:/Projects/uniapp/x/crystal-chest/crystal-chest/unpackage/release/cn.techfanyi.crystalchest/oh_modules/.ohpm/@ohos+videocompressor@soegz02lhnnihit14ad03wcy4dhlg8y+cdslhkqxb5s=/oh_modules/@ohos/videocompressor/src/main/ets/components/mainpage/CompressorResponse.ets
,我看了一下,有 265 个字符,我把这个项目移到根目录就差不多行啦!
再次编译就OK啦!其他的 WARN 估计也是因为这个原因。