uni-app 鸿蒙自动闪退问题 Error message: Parameter error. Invalid arguments

uni-app 鸿蒙自动闪退问题 Error message: Parameter error. Invalid arguments
切换页面或是时间久了鸿蒙模拟器会自己闪退

开发环境 版本号 项目创建方式
emulator 5.0.0.112(SP2DEVC00E112R4P11log) Module name: com.example.knowledgeplanet
Fingerprint: 3b977c28837f6f7097744e3331c1625d3fb79c16d4af7a85dc42fac61a9ef4e9 Version: 1.5.6 PreInstalled: No
VersionCode: 56 Foreground: Yes
Pid: 15472 Uid: 20020050

Reason: Error
Error name: Error
Error message: Parameter error. invalid arguments!
Error code: 401

Stacktrace:
at getExtensionFromMimeType (oh_modules/.ohpm/@dcloudio+uni-app-runtime@idazlhvgikh3aw++r+ncdsd8lhisx+iuufxvzpgrtyy=/oh_modules/@dcloudio/uni-app-runtime/src/main/ets/uni-mp-sdk/sdk.js:1279:1)
at lookupExt (oh_modules/.ohpm/@dcloudio+uni-app-runtime@idazlhvgikh3aw++r+ncdsd8lhisx+iuufxvzpgrtyy=/oh_modules/@dcloudio/uni-app-runtime/src/main/ets/uni-app-harmony/uni.api.ets:7635:17)
at getPossibleExt (oh_modules/.ohpm/@dcloudio+uni-app-runtime@idazlhvgikh3aw++r+ncdsd8lhisx+iuufxvzpgrtyy=/oh_modules/@dcloudio/uni-app-runtime/src/main/ets/uni-app-harmony/uni.api.ets:7821:32)
at anonymous (oh_modules/.ohpm/@dcloudio+uni-app-runtime@idazlhvgikh3aw++r+ncdsd8lhisx+iuufxvzpgrtyy=/oh_modules/@dcloudio/uni-app-runtime/src/main/ets/uni-app-harmony/uni.api.ets:7942:29)

Image Image


更多关于uni-app 鸿蒙自动闪退问题 Error message: Parameter error. Invalid arguments的实战教程也可以访问 https://www.itying.com/category-93-b0.html

4 回复

能够稳定复现吗?可以提供一个可以复现的项目吗?

更多关于uni-app 鸿蒙自动闪退问题 Error message: Parameter error. Invalid arguments的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


经常报的,不确定是哪个模块,不好提供,主要想知道这个api在uniapp中哪里会用到

对应的原生api

针对您提到的uni-app在鸿蒙系统上运行时出现的自动闪退问题,并且错误信息为“Parameter error. Invalid arguments”,这通常表明应用传递了一些不被系统接受或格式不正确的参数。由于具体代码和环境配置未知,我将提供一个基础的代码审查和调试思路,并展示一些可能的代码修改案例,以帮助您定位和解决问题。

1. 检查启动参数

首先,确保传递给uni-app或鸿蒙系统的所有启动参数都是正确的。如果您在manifest.jsonpages.json中配置了启动参数,请检查这些配置是否符合鸿蒙系统的要求。

// 示例:检查manifest.json中的配置
{
  "mp-huawei": { // 鸿蒙平台配置
    "appid": "your-app-id",
    "setting": {
      "requestPermissions": ["ohos.permission.INTERNET"] // 确保权限请求正确
    },
    "launchOptions": {
      // 确保这里的参数都是鸿蒙支持的
      "path": "/",
      "query": {}
    }
  }
}

2. 调试和日志输出

在代码中添加日志输出,以跟踪参数传递和函数调用的过程。这可以帮助您确定是哪一部分代码传递了无效参数。

// 示例:在函数调用前后添加console.log
function someFunction(param) {
  console.log('Function called with parameter:', param);
  // 您的业务逻辑
  if (!isValidParameter(param)) {
    throw new Error('Invalid parameter: ' + param);
  }
}

function isValidParameter(param) {
  // 实现参数验证逻辑
  return typeof param === 'string' && param.length > 0;
}

3. 参数校验

在关键函数调用前增加参数校验逻辑,确保所有参数都符合预期。

// 示例:在调用API前校验参数
const apiCall = (param) => {
  if (!validateParam(param)) {
    throw new Error('Parameter error. Invalid arguments');
  }
  // 调用API
};

const validateParam = (param) => {
  // 具体的校验逻辑,如类型检查、范围检查等
  return typeof param === 'object' && param !== null && 'requiredField' in param;
};

4. 使用try-catch捕获异常

在可能抛出异常的地方使用try-catch语句捕获异常,避免应用崩溃。

try {
  someFunction(someParam);
} catch (error) {
  console.error('Error occurred:', error.message);
  // 适当的错误处理,如显示错误提示、回退等
}

通过上述方法,您可以逐步缩小问题范围,并最终定位到导致“Parameter error. Invalid arguments”的具体代码位置。希望这些示例能帮助您解决问题。如果问题依旧存在,建议进一步检查uni-app和鸿蒙系统的兼容性文档,或寻求官方支持。

回到顶部