报错信息
hvigor ERROR: Failed :entry:default@CompileArkTS...
13:56:59.965 > hvigor ERROR: Could not resolve "./lfis-openSchema/utssdk/app-harmony" from "entry/src/main/ets/uni_modules/index.generated.ets"
13:56:59.965 1 ERROR: 10505001 ArkTS Compiler Error
13:56:59.965 Error Message: Cannot find module './lfis-openSchema/utssdk/app-harmony' or its corresponding type declarations. At File: F:/20250904newsvn/AL/lfis_mobile/app-build/dist/dev/app-harmony/entry/src/main/ets/uni_modules/index.generated.ets:3:33
13:56:59.966 2 ERROR: 10505001 ArkTS Compiler Error
13:56:59.966 Error Message: Expected 1 arguments, but got 0. At File: F:/20250904newsvn/AL/lfis_mobile/app-build/dist/dev/app-harmony/entry/src/main/ets/entryability/EntryAbility.ets:7:1
13:56:59.966 COMPILE RESULT:FAIL {ERROR:3 WARN:635}
13:56:59.966 * Try:
13:56:59.966 > Run with --stacktrace option to get the stack trace.
13:56:59.966 > Run with --debug option to get more log output.
13:56:59.966 > hvigor ERROR: BUILD FAILED in 45 s 376 ms
13:57:00.277 运行包制作失败
生成的EntryAbility.ets文件有问题,initUniModules需要参数
import { UniEntryAbilityDev } from "@dcloudio/uni-app-runtime";
import { initUniModules } from "../uni_modules/index.generated";
import BuildProfile from "BuildProfile";
import * as hmr from '@uni_modules/hmr-for-uni-app'
import window from '@ohos.window';
initUniModules();
interface IHmr {
init: Function
}
// 此处的字面量在应用到鸿蒙工程目录时会被替换为真正的 APPID
const UNI_APPID = "UNI0E070CC";
export default class EntryAbility extends UniEntryAbilityDev {
constructor() {
super(UNI_APPID, {
debug: BuildProfile.DEBUG,
});
}
onWindowStageCreate(windowStage: window.WindowStage) {
super.onWindowStageCreate(windowStage)
hmr.init(UNI_APPID);
}
}
uni_modules/index.generated.ets 文件信息。我下载的uts 插件也没有编译到uni_modules文件夹下
import * as lfisOpenSchema from './lfis-openSchema/utssdk/app-harmony'
export function initUniModules(uni: ESObject) {
initUniExtApi(uni)
uni.registerUTSPlugin('uni_modules/lfis-openSchema', lfisOpenSchema)
}
function initUniExtApi(uni: ESObject) {
}
2 个回复
Ask小助手
根据报错信息和知识库内容,问题在于
initUniModules()调用缺少必要参数。鸿蒙平台要求必须传递uni对象参数,而您的EntryAbility.ets中直接调用initUniModules()未传参。解决方案:
修改
EntryAbility.ets,从@dcloudio/uni-app-runtime导入uni对象并传入:确保UTS插件正确编译到
uni_modules:package.json中配置了"arkts": truenpm run build:app-harmony重新编译插件验证鸿蒙工程配置:
oh-package.json5是否注册了插件包名build-profile.json5包含正确的moduleName配置特别注意:鸿蒙平台不支持
#ifdef app-plus,应使用#ifdef APP-HARMONY条件编译。确保插件名称不以uni-开头(官方保留前缀),建议使用自定义前缀如lfis-。1***@qq.com (作者)
不使用uts 插件,运行到鸿蒙模拟器的时候也报错initUniModules,要求传递参数。但是没有
要回复问题请先登录或注册
公告
更多>相关问题