uni-app 【报Bug】@dcloudio/uni-app-harmony 被 entry/src/main/ets/entryability/EntryAbility.ets 导入

发布于 1周前 作者 songsunli 来自 Uni-App

uni-app 【报Bug】@dcloudio/uni-app-harmony 被 entry/src/main/ets/entryability/EntryAbility.ets 导入

产品分类

uniapp/App

开发环境信息

项⽬创建方式 PC开发环境操作系统 PC开发环境操作系统版本号 HBuilderX类型 HBuilderX版本号 手机系统 手机系统版本号 手机厂商 手机机型 页面类型 vue版本 打包方式
HBuilderX Windows win11 正式 4.29 HarmonyOS NEXT HarmonyOS NEXT Developer Beta2 华为 ipad vue vue3 云端

bug描述

12:01:25.681 打包生成 .hap … 12:01:56.452 > hvigor WARN: The current module ‘app-harmony@1.3.7’ has dependency which is not installed at its oh-package.json5. 12:01:56.452 > hvigor WARN: The current module ‘app-harmony@1.3.7’ has dependency which is not installed at its oh-package.json5. 12:01:56.452 > hvigor WARN: The current module ‘app-harmony@1.3.7’ has dependency which is not installed at its oh-package.json5. 12:01:56.452 > hvigor WARN: The current module ‘app-harmony@1.3.7’ has dependency which is not installed at its oh-package.json5. 12:01:56.452 > hvigor WARN: The current module ‘app-harmony@1.3.7’ has dependency which is not installed at its oh-package.json5. 12:01:56.453 “@dcloudio/uni-app-harmony” is imported by “entry/src/main/ets/entryability/EntryAbility.ets”, but could not be resolved – treating it as an external dependency. 12:01:56.453 打包失败

示例代码

12:01:25.681 打包生成 .hap … 12:01:56.452 > hvigor WARN: The current module ‘app-harmony@1.3.7’ has dependency which is not installed at its oh-package.json5. 12:01:56.452 > hvigor WARN: The current module ‘app-harmony@1.3.7’ has dependency which is not installed at its oh-package.json5. 12:01:56.452 > hvigor WARN: The current module ‘app-harmony@1.3.7’ has dependency which is not installed at its oh-package.json5. 12:01:56.452 > hvigor WARN: The current module ‘app-harmony@1.3.7’ has dependency which is not installed at its oh-package.json5. 12:01:56.452 > hvigor WARN: The current module ‘app-harmony@1.3.7’ has dependency which is not installed at its oh-package.json5. 12:01:56.453 “@dcloudio/uni-app-harmony” is imported by “entry/src/main/ets/entryability/EntryAbility.ets”, but could not be resolved – treating it as an external dependency. 12:01:56.453 打包失败

操作步骤

12:01:25.681 打包生成 .hap … 12:01:56.452 > hvigor WARN: The current module ‘app-harmony@1.3.7’ has dependency which is not installed at its oh-package.json5. 12:01:56.452 > hvigor WARN: The current module ‘app-harmony@1.3.7’ has dependency which is not installed at its oh-package.json5. 12:01:56.452 > hvigor WARN: The current module ‘app-harmony@1.3.7’ has dependency which is not installed at its oh-package.json5. 12:01:56.452 > hvigor WARN: The current module ‘app-harmony@1.3.7’ has dependency which is not installed at its oh-package.json5. 12:01:56.452 > hvigor WARN: The current module ‘app-harmony@1.3.7’ has dependency which is not installed at its oh-package.json5. 12:01:56.453 “@dcloudio/uni-app-harmony” is imported by “entry/src/main/ets/entryability/EntryAbility.ets”, but could not be resolved – treating it as an external dependency. 12:01:56.453 打包失败

预期结果

12:01:25.681 打包生成 .hap … 12:01:56.452 > hvigor WARN: The current module ‘app-harmony@1.3.7’ has dependency which is not installed at its oh-package.json5. 12:01:56.452 > hvigor WARN: The current module ‘app-harmony@1.3.7’ has dependency which is not installed at its oh-package.json5. 12:01:56.452 > hvigor WARN: The current module ‘app-harmony@1.3.7’ has dependency which is not installed at its oh-package.json5. 12:01:56.452 > hvigor WARN: The current module ‘app-harmony@1.3.7’ has dependency which is not installed at its oh-package.json5. 12:01:56.452 > hvigor WARN: The current module ‘app-harmony@1.3.7’ has dependency which is not installed at its oh-package.json5. 12:01:56.453 “@dcloudio/uni-app-harmony” is imported by “entry/src/main/ets/entryability/EntryAbility.ets”, but could not be resolved – treating it as an external dependency. 12:01:56.453 打包失败

实际结果

12:01:25.681 打包生成 .hap … 12:01:56.452 > hvigor WARN: The current module ‘app-harmony@1.3.7’ has dependency which is not installed at its oh-package.json5. 12:01:56.452 > hvigor WARN: The current module ‘app-harmony@1.3.7’ has dependency which is not installed at its oh-package.json5. 12:01:56.452 > hvigor WARN: The current module ‘app-harmony@1.3.7’ has dependency which is not installed at its oh-package.json5. 12:01:56.452 > hvigor WARN: The current module ‘app-harmony@1.3.7’ has dependency which is not installed at its oh-package.json5. 12:01:56.452 > hvigor WARN: The current module ‘app-harmony@1.3.7’ has dependency which is not installed at its oh-package.json5. 12:01:56.453 “@dcloudio/uni-app-harmony” is imported by “entry/src/main/ets/entryability/EntryAbility.ets”, but could not be resolved – treating it as an external dependency. 12:01:56.453 打包失败


2 回复

可能是 cli 项目关联的编译器的版本比较低导致的。建议先升级编译器的版本再重试。 https://uniapp.dcloud.net.cn/quickstart-cli.html#cliversion


在处理 uni-app 框架中遇到的与 @dcloudio/uni-app-harmony 相关的导入问题时,通常这类问题涉及到模块路径错误、配置问题或依赖未正确安装。根据你提供的错误描述,entry/src/main/ets/entryability/EntryAbility.ets 导入 @dcloudio/uni-app-harmony 出现了问题。由于 uni-app 支持多平台开发,包括小程序、App、H5等,而 EntryAbility.ets 文件名暗示你可能在尝试开发鸿蒙(HarmonyOS)应用。

以下是一些可能的解决方案和代码示例,帮助你检查和修复这个问题:

1. 检查依赖安装

确保 @dcloudio/uni-app-harmony 依赖已经正确安装在你的项目中。可以在项目根目录下运行以下命令来安装或检查依赖:

npm install @dcloudio/uni-app-harmony --save

2. 检查导入路径

由于 uni-app 在不同平台下的项目结构可能有所不同,确保你的导入路径是正确的。以下是一个假设性的导入示例,具体路径可能需要根据你的项目结构调整:

// 假设你在一个 HarmonyOS 特定的模块中
import { someFunction } from '@dcloudio/uni-app-harmony';

export default {
    onCreate() {
        someFunction();
    }
};

3. 配置检查

确保你的 manifest.json 和其他配置文件正确设置了目标平台。对于 HarmonyOS,你可能需要在 manifest.json 中添加或修改相关配置:

{
    "mp-huawei": { // 或其他 HarmonyOS 相关的平台标识
        "appid": "your-app-id",
        "setting": {
            // 配置项
        }
    }
}

4. 示例代码结构

确保你的项目结构符合 uni-app 和 HarmonyOS 的要求。例如,你可能需要有一个特定的目录结构来存放 HarmonyOS 相关的代码:

project-root/
├── entry/
│   ├── src/
│   │   ├── main/
│   │   │   ├── ets/
│   │   │   │   └── entryability/
│   │   │   │       └── EntryAbility.ets
│   ├── manifest.json
├── package.json

5. 清理和重建

有时候,简单的清理和重建项目可以解决缓存或编译问题:

npm run clean // 如果你有这样的脚本
npm run dev

如果上述步骤仍然无法解决问题,可能需要更详细的错误信息来进一步诊断问题。检查控制台输出的错误堆栈,看看是否有更具体的提示可以帮助定位问题。

回到顶部