求助!!! appuim建立新session 报错:Original error: 'Command '/Users/sue/Library/Android/sdk/platform-tools/adb -P 5037 -s 9cb912b shell settings delete global hidden_api_policy_pre_p_apps' exited with code 255';

appuim建立session 报错,截图如下

日志信息如下:
[info] e[35m[Appium]e[39m Welcome to Appium v1.17.1
[info] e[35m[Appium]e[39m Non-default server args:
[info] e[35m[Appium]e[39m allowInsecure: {
[info] e[35m[Appium]e[39m }
[info] e[35m[Appium]e[39m denyInsecure: {
[info] e[35m[Appium]e[39m }
[info] e[35m[Appium]e[39m Appium REST http interface listener started on 0.0.0.0:4723[info] e[35m[HTTP]e[39m e[37m–>e[39m e[37mGETe[39m e[37m/wd/hub/sessionse[39m
[info] e[35m[HTTP]e[39m e[90m{}e[39m
[debug] e[35m[GENERIC]e[39m Calling AppiumDriver.getSessions() with args: []
[debug] e[35m[GENERIC]e[39m Responding to client with driver.getSessions() result: []
[info] e[35m[HTTP]e[39m e[37m<-- GET /wd/hub/sessions e[39me[32m200e[39m e[90m5 ms - 40e[39m
[info] e[35m[HTTP]e[39m e[90me[39m[info] e[35m[HTTP]e[39m e[37m–>e[39m e[37mPOSTe[39m e[37m/wd/hub/sessione[39m
[info] e[35m[HTTP]e[39m e[90m{“desiredCapabilities”:{“appActivity”:“com.vonedao/.activity.SplashActivity”,“appPackage”:“com.vonedao”,“deviceName”:“oppo”,“platformName”:“Android”,“newCommandTimeout”:0,“connectHardwareKeyboard”:true}}e[39m
[debug] e[35m[MJSONWP]e[39m Calling AppiumDriver.createSession() with args: [{“appActivity”:“com.vonedao/.activity.SplashActivity”,“appPackage”:“com.vonedao”,“deviceName”:“oppo”,“platformName”:“Android”,“newCommandTimeout”:0,“connectHardwareKeyboard”:true},null,null]
[debug] e[35m[BaseDriver]e[39m Event ‘newSessionRequested’ logged at 1593680855082 (17:07:35 GMT+0800 (中国标准时间))
[warn] e[35m[Appium]e[39m
[warn] e[35m[Appium]e[39m ======================================================================
[warn] e[35m[Appium]e[39m DEPRECATION WARNING:
[warn] e[35m[Appium]e[39m
[warn] e[35m[Appium]e[39m The ‘automationName’ capability was not provided in the desired
[warn] e[35m[Appium]e[39m capabilities for this Android session
[warn] e[35m[Appium]e[39m
[warn] e[35m[Appium]e[39m Setting ‘automationName=UiAutomator2’ by default and using the
[warn] e[35m[Appium]e[39m UiAutomator2 Driver
[warn] e[35m[Appium]e[39m
[warn] e[35m[Appium]e[39m The next major version of Appium (2.x) will require the
[warn] e[35m[Appium]e[39m ‘automationName’ capability to be set for all sessions on all
[warn] e[35m[Appium]e[39m platforms
[warn] e[35m[Appium]e[39m
[warn] e[35m[Appium]e[39m In previous versions (Appium <= 1.13.x), the default was
[warn] e[35m[Appium]e[39m ‘automationName=UiAutomator1’
[warn] e[35m[Appium]e[39m
[warn] e[35m[Appium]e[39m If you wish to use that automation instead of UiAutomator2, please
[warn] e[35m[Appium]e[39m add ‘automationName=UiAutomator1’ to your desired capabilities
[warn] e[35m[Appium]e[39m
[warn] e[35m[Appium]e[39m For more information about drivers, please visit
[warn] e[35m[Appium]e[39m http://appium.io/docs/en/about-appium/intro/ and explore the
[warn] e[35m[Appium]e[39m ‘Drivers’ menu
[warn] e[35m[Appium]e[39m
[warn] e[35m[Appium]e[39m ======================================================================
[warn] e[35m[Appium]e[39m
[info] e[35m[Appium]e[39m Appium v1.17.1 creating new AndroidUiautomator2Driver (v1.44.2) session
[debug] e[35m[BaseDriver]e[39m Creating session with MJSONWP desired capabilities: {
[debug] e[35m[BaseDriver]e[39m “appActivity”: “com.vonedao/.activity.SplashActivity”,
[debug] e[35m[BaseDriver]e[39m “appPackage”: “com.vonedao”,
[debug] e[35m[BaseDriver]e[39m “deviceName”: “oppo”,
[debug] e[35m[BaseDriver]e[39m “platformName”: “Android”,
[debug] e[35m[BaseDriver]e[39m “newCommandTimeout”: 0,
[debug] e[35m[BaseDriver]e[39m “connectHardwareKeyboard”: true
[debug] e[35m[BaseDriver]e[39m }
[warn] e[35m[BaseDriver]e[39m The following capabilities were provided, but are not recognized by Appium:
[warn] e[35m[BaseDriver]e[39m connectHardwareKeyboard
[info] e[35m[BaseDriver]e[39m Session created with session id: 1df8adde-2e96-453a-88c9-0b6cfc51428c
[info] e[35m[UiAutomator2]e[39m Starting ‘com.vonedao’ directly on the device[info] e[35m[ADB]e[39m Using ‘adb’ from ‘/Users/sue/Library/Android/sdk/platform-tools/adb’
[info] e[35m[AndroidDriver]e[39m Retrieving device list
[debug] e[35m[ADB]e[39m Trying to find a connected android device
[debug] e[35m[ADB]e[39m Getting connected devices…
[debug] e[35m[ADB]e[39m Connected devices: [{“udid”:“9cb912b”,“state”:“device”}]
[info] e[35m[AndroidDriver]e[39m Using device: 9cb912b
[info] e[35m[ADB]e[39m Using ‘adb’ from ‘/Users/sue/Library/Android/sdk/platform-tools/adb’
[debug] e[35m[ADB]e[39m Setting device id to 9cb912b
[debug] e[35m[ADB]e[39m Running ‘/Users/sue/Library/Android/sdk/platform-tools/adb -P 5037 -s 9cb912b shell getprop ro.build.version.sdk’
[debug] e[35m[ADB]e[39m Current device property ‘ro.build.version.sdk’: 28
[info] e[35m[ADB]e[39m Getting device platform version
[debug] e[35m[ADB]e[39m Running ‘/Users/sue/Library/Android/sdk/platform-tools/adb -P 5037 -s 9cb912b shell getprop ro.build.version.release’
[debug] e[35m[ADB]e[39m Current device property ‘ro.build.version.release’: 9
[debug] e[35m[ADB]e[39m Device API level: 28
[warn] e[35m[UiAutomator2]e[39m Relaxing hidden api policy
[debug] e[35m[ADB]e[39m Running ‘/Users/sue/Library/Android/sdk/platform-tools/adb -P 5037 -s 9cb912b shell settings put global hidden_api_policy_pre_p_apps 1’[info] e[35m[UiAutomator2]e[39m Restoring hidden api policy to the device default configuration
[debug] e[35m[ADB]e[39m Running ‘/Users/sue/Library/Android/sdk/platform-tools/adb -P 5037 -s 9cb912b shell settings delete global hidden_api_policy_pre_p_apps’[debug] e[35m[BaseDriver]e[39m Event ‘newSessionStarted’ logged at 1593680856063 (17:07:36 GMT+0800 (中国标准时间))
[debug] e[35m[MJSONWP]e[39m Encountered internal error running command: Error executing adbExec. Original error: ‘Command ‘/Users/sue/Library/Android/sdk/platform-tools/adb -P 5037 -s 9cb912b shell settings delete global hidden_api_policy_pre_p_apps’ exited with code 255’; Stderr: ‘Security exception: Permission denial: writing to settings requires:android.permission.WRITE_SECURE_SETTINGS
[debug] e[35m[MJSONWP]e[39m
[debug] e[35m[MJSONWP]e[39m java.lang.SecurityException: Permission denial: writing to settings requires:android.permission.WRITE_SECURE_SETTINGS
[debug] e[35m[MJSONWP]e[39m at com.android.providers.settings.SettingsProvider.enforceWritePermission(SettingsProvider.java:2055)
[debug] e[35m[MJSONWP]e[39m at com.android.providers.settings.SettingsProvider.mutateGlobalSetting(SettingsProvider.java:1114)
[debug] e[35m[MJSONWP]e[39m at com.android.providers.settings.SettingsProvider.deleteGlobalSetting(SettingsProvider.java:1097)
[debug] e[35m[MJSONWP]e[39m at com.android.providers.settings.SettingsProvider.delete(SettingsProvider.java:679)
[debug] e[35m[MJSONWP]e[39m at android.content.ContentProvider$Transport.delete(ContentProvider.java:405)
[debug] e[35m[MJSONWP]e[39m at com.android.providers.settings.SettingsService$MyShellCommand.deleteForUser(SettingsService.java:406)
[debug] e[35m[MJSONWP]e[39m at com.android.providers.settings.SettingsService$MyShellCommand.onCommand(SettingsService.java:289)
[debug] e[35m[MJSONWP]e[39m at android.os.ShellCommand.exec(ShellCommand.java:103)
[debug] e[35m[MJSONWP]e[39m at com.android.providers.settings.SettingsService.onShellCommand(SettingsService.java:51)
[debug] e[35m[MJSONWP]e[39m at android.os.Binder.shellCommand(Binder.java:634)
[debug] e[35m[MJSONWP]e[39m at android.os.Binder.onTransact(Binder.java:532)
[debug] e[35m[MJSONWP]e[39m at android.os.Binder.execTransact(Binder.java:731)’; Code: ‘255’
[debug] e[35m[MJSONWP]e[39m Error: Command ‘/Users/sue/Library/Android/sdk/platform-tools/adb -P 5037 -s 9cb912b shell settings delete global hidden_api_policy_pre_p_apps’ exited with code 255
[debug] e[35m[MJSONWP]e[39m at ChildProcess. (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/teen_process/lib/exec.js:113:19)
[debug] e[35m[MJSONWP]e[39m at ChildProcess.emit (events.js:203:13)
[debug] e[35m[MJSONWP]e[39m at maybeClose (internal/child_process.js:1021:16)
[debug] e[35m[MJSONWP]e[39m at Socket. (internal/child_process.js:430:11)
[debug] e[35m[MJSONWP]e[39m at Socket.emit (events.js:203:13)
[debug] e[35m[MJSONWP]e[39m at Pipe. (net.js:588:12)
[debug] e[35m[MJSONWP]e[39m Destroying socket connection
[info] e[35m[HTTP]e[39m e[37m<-- POST /wd/hub/session e[39me[31m500e[39m e[90m986 ms - 1592e[39m
[info] e[35m[HTTP]e[39m e[90me[39m
[info] e[35m[HTTP]e[39m e[37m–>e[39m e[37mDELETEe[39m e[37m/wd/hub/sessione[39m
[info] e[35m[HTTP]e[39m e[90m{}e[39m
[debug] e[35m[HTTP]e[39m No route found. Setting content type to ‘text/plain’
[info] e[35m[HTTP]e[39m e[37m<-- DELETE /wd/hub/session e[39me[33m404e[39m e[90m8 ms - 57e[39m
[info] e[35m[HTTP]e[39m e[90me[39m

真机需要root,可以检查下是否root

关闭