You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Appium Inspector无法启动会话,权限拒绝错误求助

解决Appium会话创建失败(WRITE_SECURE_SETTINGS权限问题)

核心问题分析

报错提示需要android.permission.WRITE_SECURE_SETTINGS权限,是因为Appium依赖的UIAutomator2服务器未获取该系统权限,导致ADB命令执行失败(返回码255)。

解决步骤

1. 手动授予UIAutomator2服务器权限

打开终端执行以下ADB命令,给UIAutomator2核心服务包授予所需权限:

adb shell pm grant io.appium.uiautomator2.server android.permission.WRITE_SECURE_SETTINGS

若仍有相关权限报错,可同时授予测试服务包权限:

adb shell pm grant io.appium.uiautomator2.server.test android.permission.WRITE_SECURE_SETTINGS

2. 修正Desired Capabilities配置错误

你的配置中存在键名错误:"appium:appium": "ignoreHiddenApiPolicyError" 无效,正确参数配置如下:

{
  "appium:automationName": "uiautomator2",
  "appium:platformName": "Android",
  "appium:platformVersion": "9",
  "appium:deviceName": "CYTKIB6SPN8SIRE6",
  "appium:app": "D:/Automation/ApiDemos-debug.apk",
  "appium:ignoreHiddenApiPolicyError": true
}

该参数用于绕过Android 9及以上版本的隐藏API限制,是适配此系统版本的必要配置。

3. 验证ADB连接状态

  • 执行adb devices确认设备已正常连接且处于授权状态
  • 若连接异常,重启ADB服务:
adb kill-server
adb start-server

4. 重新安装UIAutomator2驱动(可选)

如果上述步骤无效,可重新安装UIAutomator2驱动确保版本兼容:

appium driver install uiautomator2

内容的提问来源于stack exchange,提问作者Vivek Thapliyal

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.20 13:12:37