前往小程序,Get更优阅读体验!
立即前往
发布
社区首页 >专栏 >uniapp 打包鸿蒙5.0应用出现问题

uniapp 打包鸿蒙5.0应用出现问题

作者头像
繁依Fanyi
发布2025-02-22 20:19:53
发布2025-02-22 20:19:53
8910
代码可运行
举报
运行总次数:0
代码可运行

想把上架的 uniapp 小程序迁移到鸿蒙,结果一打包,ERROR × 3,WARN × 519,所以就简单记录一下解决这些错误的过程。

首先先解决错误吧,错误的主要报错如下:

代码语言:javascript
代码运行次数:0
复制
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 安装包制作失败

两个错误都是因为

代码语言:javascript
代码运行次数:0
复制
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 "装饰器。

给出的建议是:

代码语言:javascript
代码运行次数:0
复制
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 估计也是因为这个原因。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2025-02-21,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档