测试人社区

使用真机android10版本进行app自动化测试,appium 报错,报错信息:Security exception,Permission denial

建议先查一下app的activity正不正确,其它版本的android可以正常使用吗?
可以试用aapt dump badging命令看一下启动activity与你目前试用的activity是否一致

贴下错误提示的文本,别截图,可能是跟手机的权限限制有关

真机嘛,先插上电脑,在电脑上adb 操作下手机。
比如 adb 查看手机文件夹目录,装个apk之类的。截图看,就是手机权限没给到位。
有些手机厂商,拔掉usb后,调试模式就关闭了,再插上得重新设。都是坑。。

老师,这是appium的报错日志
“”"
[debug] [ADB] Current device property ‘ro.build.version.sdk’: 29
[ADB] Getting device platform version
[debug] [ADB] Running ‘E:\Download\platform-tools\adb.exe -P 5037 -s 030e08d80404 shell getprop ro.build.version.release’
[debug] [ADB] Current device property ‘ro.build.version.release’: 10
[debug] [ADB] Device API level: 29
[UiAutomator2] Relaxing hidden api policy
[debug] [ADB] Running ‘E:\Download\platform-tools\adb.exe -P 5037 -s 030e08d80404 shell ‘settings put global hidden_api_policy_pre_p_apps 1;settings put global hidden_api_policy_p_apps 1;settings put global hidden_api_policy 1’’
[debug] [UiAutomator2] Deleting UiAutomator2 session
[UiAutomator2] Restoring hidden api policy to the device default configuration
[debug] [ADB] Running ‘E:\Download\platform-tools\adb.exe -P 5037 -s 030e08d80404 shell ‘settings delete global hidden_api_policy_pre_p_apps;settings delete global hidden_api_policy_p_apps;settings delete global hidden_api_policy’’
[debug] [BaseDriver] Event ‘newSessionStarted’ logged at 1605169683227 (16:28:03 GMT+0800 (GMT+08:00))
[debug] [W3C] Encountered internal error running command: Error executing adbExec. Original error: ‘Command ‘E:\Download\platform-tools\adb.exe -P 5037 -s 030e08d80404 shell ‘settings delete global hidden_api_policy_pre_p_apps;settings delete global hidden_api_policy_p_apps;settings delete global hidden_api_policy’’ exited with code 255’; Stderr: ‘Security exception: Permission denial: writing to settings requires:android.permission.WRITE_SECURE_SETTINGS
[debug] [W3C]
[debug] [W3C] java.lang.SecurityException: Permission denial: writing to settings requires:android.permission.WRITE_SECURE_SETTINGS
[debug] [W3C] at com.android.providers.settings.SettingsProvider.enforceWritePermission(SettingsProvider.java:2050)
[debug] [W3C] at com.android.providers.settings.SettingsProvider.mutateGlobalSetting(SettingsProvider.java:1256)
[debug] [W3C] at com.android.providers.settings.SettingsProvider.deleteGlobalSetting(SettingsProvider.java:1239)
[debug] [W3C] at com.android.providers.settings.SettingsProvider.call(SettingsProvider.java:476)
[debug] [W3C] at android.content.ContentProvider.call(ContentProvider.java:2177)
[debug] [W3C] at android.content.ContentProvider$Transport.call(ContentProvider.java:477)
[debug] [W3C] at com.android.providers.settings.SettingsService$MyShellCommand.deleteForUser(SettingsService.java:399)[debug] [W3C] at com.android.providers.settings.SettingsService$MyShellCommand.onCommand(SettingsService.java:281)
[debug] [W3C] at android.os.ShellCommand.exec(ShellCommand.java:104)
[debug] [W3C] at com.android.providers.settings.SettingsService.onShellCommand(SettingsService.java:49)
[debug] [W3C] at android.os.Binder.shellCommand(Binder.java:881)
[debug] [W3C] at android.os.Binder.onTransact(Binder.java:765)
[debug] [W3C] at android.os.Binder.execTransactInternal(Binder.java:1021)
[debug] [W3C] at android.os.Binder.execTransact(Binder.java:994)
[debug] [W3C] Security exception: Permission denial: writing to settings requires:android.permission.WRITE_SECURE_SETTINGS
[debug] [W3C]
[debug] [W3C] java.lang.SecurityException: Permission denial: writing to settings requires:android.permission.WRITE_SECURE_SETTINGS
[debug] [W3C] at com.android.providers.settings.SettingsProvider.enforceWritePermission(SettingsProvider.java:2050)
[debug] [W3C] at com.android.providers.settings.SettingsProvider.mutateGlobalSetting(SettingsProvider.java:1256)
[debug] [W3C] at com.android.providers.settings.SettingsProvider.deleteGlobalSetting(SettingsProvider.java:1239)
[debug] [W3C] at com.android.providers.settings.SettingsProvider.call(SettingsProvider.java:476)
[debug] [W3C] at android.content.ContentProvider.call(ContentProvider.java:2177)
[debug] [W3C] at android.content.ContentProvider$Transport.call(ContentProvider.java:477)
[debug] [W3C] at com.android.providers.settings.SettingsService$MyShellCommand.deleteForUser(SettingsService.java:399)[debug] [W3C] at com.android.providers.settings.SettingsService$MyShellCommand.onCommand(SettingsService.java:281)
[debug] [W3C] at android.os.ShellCommand.exec(ShellCommand.java:104)
[debug] [W3C] at com.android.providers.settings.SettingsService.onShellCommand(SettingsService.java:49)
[debug] [W3C] at android.os.Binder.shellCommand(Binder.java:881)
[debug] [W3C] at android.os.Binder.onTransact(Binder.java:765)
[debug] [W3C] at android.os.Binder.execTransactInternal(Binder.java:1021)
[debug] [W3C] at android.os.Binder.execTransact(Binder.java:994)
[debug] [W3C] Security exception: Permission denial: writing to settings requires:android.permission.WRITE_SECURE_SETTINGS
[debug] [W3C]
[debug] [W3C] java.lang.SecurityException: Permission denial: writing to settings requires:android.permission.WRITE_SECURE_SETTINGS
[debug] [W3C] at com.android.providers.settings.SettingsProvider.enforceWritePermission(SettingsProvider.java:2050)
[debug] [W3C] at com.android.providers.settings.SettingsProvider.mutateGlobalSetting(SettingsProvider.java:1256)
[debug] [W3C] at com.android.providers.settings.SettingsProvider.deleteGlobalSetting(SettingsProvider.java:1239)
[debug] [W3C] at com.android.providers.settings.SettingsProvider.call(SettingsProvider.java:476)
[debug] [W3C] at android.content.ContentProvider.call(ContentProvider.java:2177)
[debug] [W3C] at android.content.ContentProvider$Transport.call(ContentProvider.java:477)
[debug] [W3C] at com.android.providers.settings.SettingsService$MyShellCommand.deleteForUser(SettingsService.java:399)[debug] [W3C] at com.android.providers.settings.SettingsService$MyShellCommand.onCommand(SettingsService.java:281)
[debug] [W3C] at android.os.ShellCommand.exec(ShellCommand.java:104)
[debug] [W3C] at com.android.providers.settings.SettingsService.onShellCommand(SettingsService.java:49)
[debug] [W3C] at android.os.Binder.shellCommand(Binder.java:881)
[debug] [W3C] at android.os.Binder.onTransact(Binder.java:765)
[debug] [W3C] at android.os.Binder.execTransactInternal(Binder.java:1021)
[debug] [W3C] at android.os.Binder.execTransact(Binder.java:994)’; Code: ‘255’
[debug] [W3C] Error: Command ‘E:\Download\platform-tools\adb.exe -P 5037 -s 030e08d80404 shell ‘settings delete global hidden_api_policy_pre_p_apps;settings delete global hidden_api_policy_p_apps;settings delete global hidden_api_policy’’ exited with code 255
[debug] [W3C] at ChildProcess. (C:\Users\lixin\AppData\Roaming\npm\node_modules\appium\node_modules_teen_process@1.15.0@teen_process\lib\exec.js:113:19)
[debug] [W3C] at ChildProcess.emit (events.js:315:20)
[debug] [W3C] at maybeClose (internal/child_process.js:1021:16)
[debug] [W3C] at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
[debug] [W3C] Destroying socket connection
[HTTP] <-- POST /wd/hub/session 500 1207 ms - 9605
“”"

你这个我那阵在群里看了,回你了 好像是权限问题
1.你开发者模式设置对不对
2.你的adb有没有多安装,安装多个的话,和appium-doctor查的保持一样,另外一个删除

开发者模式已经开启了,上网搜了一下,好像是需要手机root权限,或者换低版本的手机。