[ADB] cmd: Can't find service: settings [ADB] cmd: Can't find service: settings'; Code: '20'

im trying to run an automation script using appium and im getting the following error, however the emulator is fully booted in headless mode, any idea what could be the issue and how to fix ?

 [UiAutomator2] Unable to force stop app: Error executing adbExec. Original error: 'Command '/Users/runner/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell am force-stop com.horizonswest.app' exited with code 20'; Stderr: 'cmd: Can't find service: activity'; Code: '20'
[UiAutomator2] Restoring hidden api policy to the device default configuration
[debug] [ADB] Running '/Users/runner/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell 'settings delete global hidden_api_policy_pre_p_apps;settings delete global hidden_api_policy_p_apps;settings delete global hidden_api_policy''
[ADB] Failed to delete keys 'hidden_api_policy_pre_p_apps,hidden_api_policy_p_apps,hidden_api_policy'. Original error: Error executing adbExec. Original error: 'Command '/Users/runner/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 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 20'; Stderr: 'cmd: Can't find service: settings
[ADB] cmd: Can't find service: settings
[ADB] cmd: Can't find service: settings'; Code: '20'
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1628767192789 (11:19:52 GMT+0000 (Coordinated Universal Time))
[debug] [W3C] Encountered internal error running command: Error executing adbExec. Original error: 'Command '/Users/runner/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 install -g /Users/runner/hostedtoolcache/node/14.17.4/x64/lib/node_modules/appium/node_modules/io.appium.settings/apks/settings_apk-debug.apk' exited with code 1'; Stderr: 'adb: failed to install /Users/runner/hostedtoolcache/node/14.17.4/x64/lib/node_modules/appium/node_modules/io.appium.settings/apks/settings_apk-debug.apk: cmd: Can't find service: package'; Code: '1'
[debug] [W3C] Error: Command '/Users/runner/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 install -g /Users/runner/hostedtoolcache/node/14.17.4/x64/lib/node_modules/appium/node_modules/io.appium.settings/apks/settings_apk-debug.apk' exited with code 1
[debug] [W3C]     at ChildProcess.<anonymous> (/Users/runner/hostedtoolcache/node/14.17.4/x64/lib/node_modules/appium/node_modules/teen_process/lib/exec.js:113:19)
[debug] [W3C]     at ChildProcess.emit (events.js:400:28)
[debug] [W3C]     at maybeClose (internal/child_process.js:1055:16)
[debug] [W3C]     at Socket.<anonymous> (internal/child_process.js:441:11)
[debug] [W3C]     at Socket.emit (events.js:400:28)
[debug] [W3C]     at Pipe.<anonymous> (net.js:675:12)

Not exactly sure what’s going on, but you could run the command independently of Appium (on the command line):

And see if it gives more information. Seems similar to this issue:

yes this similar issue you post, it was me who post it :smiley:

and unfortunately no use yet

I had this same issue, and after killing the ‘adb’ task in the background it worked just fine. At least I think it was the thing that helped eventually.