错误处理
Android SDK 的所有错误处理均集中在本节。onErrorAcessoBio 回调接收一个包含 code (Int) 和 description (String) 的 ErrorBio 对象。
处理回调
- Kotlin
- Java
override fun onErrorAcessoBio(error: ErrorBio) {
when (error.code) {
73002 -> { /* camera permission denied — redirect to app settings */ }
73006 -> { /* running on emulator — physical device required */ }
73100 -> { /* no internet connection */ }
else -> { /* generic error handling */ }
}
}
@Override
public void onErrorAcessoBio(ErrorBio error) {
switch (error.getCode()) {
case 73002: /* camera permission denied — redirect to app settings */ break;
case 73006: /* running on emulator — physical device required */ break;
case 73100: /* no internet connection */ break;
default: /* generic error handling */
}
}
生命周期回调
除 onErrorAcessoBio 外,SDK 还会触发:
onUserClosedCameraManually()— 用户手动关闭了相机。onSystemClosedCameraTimeoutSession()— 会话因超时而过期。onSystemChangedTypeCameraTimeoutFaceInference()— 13 秒内未检测到人脸;SDK 切换至手动采集模式。
错误代码
所有错误代码均来自 UnicoException 枚举,并通过 ErrorBio(code, message) 传递。message 字段包含 SDK 的精确字符串 — 请勿修改或本地化。
| 代码 | 消息 | 描述 |
|---|---|---|
73001 | Context invalid | 传递给 SDK 的 Android context 无效 |
73002 | Did not grant permission to open camera | 用户拒绝了摄像头权限 |
73003 | The lest API is 21(LOLLIPOP | 设备 API 级别低于最低要求 (API 21) |
73004 | Could not find implementation interface callback iAcessoBioSelfie | iAcessoBioSelfie 接口未实现 |
73005 | Could not find implementation interface callback iAcessoBioDocument | iAcessoBioDocument 接口未实现 |
73006 | Unable to open camera on emulators | SDK 不在模拟器上运行 — 请使用实体设备 |
73007 | Unknown and unexpected error in WebApp… | WebApp 通用错误(摄像头、存储、安全、网络) |
73100 | Unable to connect to internet. | 无网络连接 |
73200 | Please inform the config object or json file name | 未提供配置对象或 JSON 文件 |
73202 | Unable to parse json file | JSON 配置文件格式错误 |
73204 | Unable to initialize the SDK, please configure the environment on setEnviroment method of build | 初始化前未调用 setEnvironment() |
73300 | Unable to get unico authentication object | 获取认证对象失败 |
73301 | Unable to parse object | 解析认证响应失败 |
73302 | Could not find the unico token | 未找到 Unico 认证令牌 |
73303 | Current host is not registered | Bundle 标识符未在 SDK Key 中注册 |
73400 | Could not initialize camera | 摄像头初始化失败 |
73701 | Could not find active liveness import | 未找到活体检测模块 |
73703 | Unable to get active liveness session | 获取活体检测会话失败 |
73718 | The Session was cancelled because of an unknown and unexpected error… | 未知内部会话错误 |
73721 | The Session can't be performed: attempts limit exceeded. | 会话已取消 — 超过采集尝试次数限制 |
73722 | The Session can't be performed: face alignment timeout. | 会话已取消 — 人脸对齐超时 |
73726 | An error happened during video recording | 活体检测期间视频录制错误 |
73727 | No actions found in a video | 视频中未检测到活体动作 |
73740 | The user pressed the do not consent button and did not complete the Session. | 用户拒绝了授权 |
73800 | Could not build encrypted key. | 构建加密 JWT 失败 |
73801 | The Session of SDK was cancelled because of an unknown and unexpected error. | 未知内部 SDK 会话错误 |
73802 | The Session was cancelled because of an unknown and unexpected error… | 会话已取消 — 缺少必填 JWT 字段 |
73900 | Erro ao analisar imagem | 分析采集图像时出错 |
73901 | É necessário implementar a interface AcessoBioListener | AcessoBioListener 接口未实现 |
73902 | É necessário insirir um valor maior que 40 segundos no método: setTimeoutSession. | setTimeoutSession 的值必须大于 40 秒 |
73903 | Arquivo de configuração corrompido. Verifique o arquivo json e tente novamente. | 配置文件已损坏 — 请验证并重试 |
73904 | Erro ao finalizar processo | 完成采集流程时出错 |
73905 | Unable to open document camera | 无法打开文档摄像头 |
73906 | Document type uninformed | 未指定文档类型 |
74001 | onSuccess: not implemented when using open:webAppToken: | User Journey 的 onSuccess 回调未实现 |
74100 | Could not prepare SDK-S | 准备 SDK 组件失败 |
74101 | No URL token was provided. | 未提供 journey 的 URL 令牌 |
74102 | Environment type was not specified. | 未配置 Environment (PROD/UAT) |
737120 | Unable to initialize liveness | 活体检测 activity 无法初始化 |
737220 | Capture could not start | 采集流程无法启 动 |
737320 | Transaction could not start | 事务无法发起 |
737321 | The Session was cancelled because of an unknown and unexpected error. This return value is a catch-all for errors experienced during normal usage of these APIs. Try again. | 会话提供方通用错误 — 请重试 |
REST API 错误代码
上述代码为 SDK 回调错误。REST API 错误代码(HTTP 状态码系列)单独记录在 API 参考 > 错误代码。