在引用了 jar 包的情况下,运行真机调试,报错:Unresolved reference: uni_requireNativePlugin
相关信息
vue3; HBuilder X:4.56;项目类型:uni-app x
# jar 包相对路径:nativeplugins/ADWApiManager/android/adw_api.jar
# 导入 jar 的 package.json
{
"name": "ADWApiManager",
"id": "ADWApiManager",
"version": "1.0",
"description": "外部jar",
"_dp_type": "nativeplugin",
"_dp_nativeplugin": {
"android": {
"plugins": [{
"tpye": "module",
"name": "ADWApiManager",
"class": "cn.uniplugin_richalert.ADWApiManager"
}],
"integrateType": "jar",
"minSdkVersion": 16
}
}
}
const DCloudRichAlert = uni.requireNativePlugin("ADWApiManager");
console.log(DCloudRichAlert);
在最后一个代码块的第一行出现了问题,uts 校验表示 uni 中不存在 requireNativePlugin;点击 “运行到Android基座”后,编译控制台报错:
[plugin:uni:app-uts] 编译失败
Unresolved reference: requireNativePlugin
at pages/index/index.uvue:20:31
beforeCreate() {
const DCloudRichAlert = uni.requireNativePlugin("ADWApiManager");
^
console.log(DCloudRichAlert);
},
error: Unresolved reference: uni_requireNativePlugin
APM_129 (作者)
原生插件,用java写的
2025-03-21 09:48