appium / appium-uiautomator2-driver

Appium driver for Android UIAutomator2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ADB permission issue in startup

ollipm opened this issue · comments

Hi,
i have been trying to get my appium to work after updating appium-uiautomator2-driver from 3.0.5 to 3.5.5 but once i try to open any session i get error:
"... shell cmd package list packages' exited with code 255'; Command output: Exception occurred while executing 'list': java.lang.SecurityException: Shell does not have permission to access user 10 ..."

The error comes comes after:
"[ADB] The installed 'io.appium.uiautomator2.server' package is older than '.appium\node_modules\appium-uiautomator2-driver\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v7.0.13.apk' (167 < 175 or '7.0.5' < '7.0.13')'"

The phone used is Samsung Galaxy S23
And here are the capabilities i tried to use in appium inspector:
{
"platformName": "Android",
"appium:automationName": "UIAutomator2",
"appium:platformVersion": "14",
}

Managed to get this working by setting a appium:skipServerInstallation to True but is there any other solution to this?

Please provide the full server log.

I guess the issue might be related to the fact the server package has been installed from another user account. Try to reset the driver install as a possible workaround

Tried resetting it:
C:\Users\Olli>appium driver run uiautomator2 reset
info ADB Found 2 'build-tools' folders under 'C:\Users\Olli\AppData\Local\Android\sdk' (newest first):
info ADB C:\Users\Olli\AppData\Local\Android\sdk\build-tools\35.0.0-rc1
info ADB C:\Users\Olli\AppData\Local\Android\sdk\build-tools\34.0.0
info ADB Using 'adb.exe' from 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe'
dbug ADB Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 start-server'
dbug ADB Getting connected devices
dbug ADB Connected devices: [{"udid":"RFCWA1JHGYL","state":"device"}]
[23:24:13] About to perform reset for the following device: RFCWA1JHGYL
dbug ADB Setting device id to RFCWA1JHGYL
dbug ADB Uninstalling io.appium.uiautomator2.server
dbug ADB Getting install status for io.appium.uiautomator2.server
dbug ADB Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell getprop ro.build.version.sdk'
dbug ADB Uninstalling io.appium.uiautomator2.server.test
dbug ADB Getting install status for io.appium.uiautomator2.server.test
dbug ADB Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell getprop ro.build.version.sdk'
dbug ADB Uninstalling io.appium.settings
dbug ADB Getting install status for io.appium.settings
dbug ADB Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell getprop ro.build.version.sdk'
dbug ADB Current device property 'ro.build.version.sdk': 34
info ADB Getting device platform version
dbug ADB Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell getprop ro.build.version.release'
dbug ADB Current device property 'ro.build.version.sdk': 34
info ADB Getting device platform version
dbug ADB Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell getprop ro.build.version.release'
dbug ADB Current device property 'ro.build.version.sdk': 34
info ADB Getting device platform version
dbug ADB Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell getprop ro.build.version.release'
dbug ADB Current device property 'ro.build.version.release': 14
dbug ADB Device API level: 34
dbug ADB Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell cmd package list packages'
dbug ADB Current device property 'ro.build.version.release': 14
dbug ADB Device API level: 34
dbug ADB Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell cmd package list packages'
dbug ADB Current device property 'ro.build.version.release': 14
dbug ADB Device API level: 34
dbug ADB Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell cmd package list packages'

C:\Users\Olli.appium\node_modules\appium-uiautomator2-driver\node_modules\teen_process\lib\exec.js:128
let err = new Error(Command '${rep}' exited with code ${code});
^
Error: Command 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell cmd package list packages' exited with code 255
at ChildProcess. (C:\Users\Olli.appium\node_modules\appium-uiautomator2-driver\node_modules\teen_process\lib\exec.js:128:19)
at ChildProcess.emit (node:events:518:28)
at maybeClose (node:internal/child_process:1105:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:305:5)
× Encountered an error when running 'reset': Script "reset" exited with code 1

Here is the log from appium server:

[AppiumDriver@9df7] Calling AppiumDriver.createSession() with args: [{"platformName":"Android","appium:automationName":"UIAutomator2","appium:platformVersion":"14","appium:skipServerInstallation":false,"appium:ensureWebviewsHavePages":true,"appium:nativeWebScreenshot":true,"appium:newCommandTimeout":3600,"appium:connectHardwareKeyboard":true},null,{"alwaysMatch":{"platformName":"Android","appium:automationName":"UIAutomator2","appium:platformVersion":"14","appium:skipServerInstallation":false,"appium:ensureWebviewsHavePages":true,"appium:nativeWebScreenshot":true,"appium:newCommandTimeout":3600,"appium:connectHardwareKeyboard":true},"firstMatch":[{}]}]
[AppiumDriver@9df7] Event 'newSessionRequested' logged at 1718740595994 (22:56:35 GMT+0300 (Itä-Euroopan kesäaika))
[Appium] Attempting to find matching driver for automationName 'UIAutomator2' and platformName 'Android'
[Appium] The 'uiautomator2' driver was installed and matched caps.
[Appium] Will require it at C:\Users\Olli.appium\node_modules\appium-uiautomator2-driver
[Appium] Requiring driver at C:\Users\Olli.appium\node_modules\appium-uiautomator2-driver\build\index.js
[AppiumDriver@9df7] Appium v2.10.3 creating new AndroidUiautomator2Driver (v3.5.5) session
[AppiumDriver@9df7] Checking BaseDriver versions for Appium and AndroidUiautomator2Driver
[AppiumDriver@9df7] Appium's BaseDriver version is 9.10.3
[AppiumDriver@9df7] AndroidUiautomator2Driver's BaseDriver version is 9.10.3
[AndroidUiautomator2Driver@e32c] undefined
[AndroidUiautomator2Driver@e32c] Creating session with W3C capabilities: {
"alwaysMatch": {
"platformName": "Android",
"appium:automationName": "UIAutomator2",
"appium:platformVersion": "14",
"appium:skipServerInstallation": false,
"appium:ensureWebviewsHavePages": true,
"appium:nativeWebScreenshot": true,
"appium:newCommandTimeout": 3600,
"appium:connectHardwareKeyboard": true
},
"firstMatch": [
{}
]
}
[AndroidUiautomator2Driver@e32c] The following provided capabilities were not recognized by this driver:
[AndroidUiautomator2Driver@e32c] connectHardwareKeyboard
[AndroidUiautomator2Driver@e32c] Session created with session id: 8ef4591d-224e-4887-8321-7745bc9a6223
[ADB] Using 'adb.exe' from 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe'
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 start-server'
[AndroidUiautomator2Driver@e32c] Retrieving device list
[ADB] Trying to find connected Android devices
[ADB] Getting connected devices
[ADB] Connected devices: [{"udid":"RFCWA1JHGYL","state":"device"}]
[AndroidUiautomator2Driver@e32c] Looking for a device with Android '14.0.0'
[ADB] Setting device id to RFCWA1JHGYL
[ADB] Getting device platform version
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell getprop ro.build.version.release'
[ADB] Current device property 'ro.build.version.release': 14
[AndroidUiautomator2Driver@e32c] Using device: RFCWA1JHGYL
[ADB] Using 'adb.exe' from 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe'
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 start-server'
[ADB] Setting device id to RFCWA1JHGYL
[AndroidUiautomator2Driver@e32c] Neither 'app' nor 'appPackage' was set. Starting UiAutomator2 without the target application
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell getprop ro.build.version.sdk'
[ADB] Current device property 'ro.build.version.sdk': 34
[ADB] Getting device platform version
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell getprop ro.build.version.release'
[ADB] Current device property 'ro.build.version.release': 14
[ADB] Device API level: 34
[AndroidUiautomator2Driver@e32c] Relaxing hidden api policy
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL 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''
[AndroidUiautomator2Driver@e32c] No app sent in, not parsing package/activity
[AndroidUiautomator2Driver@e32c] Pushing settings apk to the device...
[ADB] Getting package info for 'io.appium.settings'
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell dumpsys package io.appium.settings'
[ADB] The version name of the installed 'io.appium.settings' is greater or equal to the application version name ('5.12.3' >= '5.12.3')
[ADB] There is no need to install/upgrade 'C:\Users\Olli.appium\node_modules\appium-uiautomator2-driver\node_modules\io.appium.settings\apks\settings_apk-debug.apk'
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell dumpsys activity services io.appium.settings'
[AndroidUiautomator2Driver@e32c] io.appium.settings is already running. There is no need to reset its permissions.
[Logcat] Starting logs capture with command: C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL logcat -v threadtime
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell appops set io.appium.settings android:mock_location allow'
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell "[ -e '/data/local/tmp/mock_apps.json' ] && echo PASS"'
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell cat /data/local/tmp/mock_apps.json'
[AndroidUiautomator2Driver@e32c] Forwarding UiAutomator2 Server port 6790 to local port 8200
[ADB] Forwarding system: 8200 to device: 6790
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL forward tcp:8200 tcp:6790'
[ADB] Getting package info for 'io.appium.uiautomator2.server'
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell dumpsys package io.appium.uiautomator2.server'
[ADB] Getting install status for io.appium.uiautomator2.server.test
[AndroidUiautomator2Driver@e32c] No app capability. Assuming it is already on the device
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell cmd package list packages'
[AndroidUiautomator2Driver@e32c] Deleting UiAutomator2 session
[AndroidUiautomator2Driver@e32c] Deleting UiAutomator2 server session
[AndroidUiautomator2Driver@e32c] Matched '/' to command name 'deleteSession'
[AndroidUiautomator2Driver@e32c] Did not get confirmation UiAutomator2 deleteSession worked; Error was: UnknownError: An unknown server-side error occurred while processing the command. Original error: Trying to proxy a session command without session id
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell dumpsys activity services io.appium.settings/.recorder.RecorderService'
[Logcat] Stopping logcat capture
[ADB] Removing forwarded port socket connection: 8200
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL forward --remove tcp:8200'
[AndroidUiautomator2Driver@e32c] Restoring hidden api policy to the device default configuration
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL 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] The installed 'io.appium.uiautomator2.server' package is older than 'C:\Users\Olli.appium\node_modules\appium-uiautomator2-driver\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v7.0.13.apk' (167 < 175 or '7.0.5' < '7.0.13')'
[AppiumDriver@9df7] Event 'newSessionStarted' logged at 1718740597021 (22:56:37 GMT+0300 (Itä-Euroopan kesäaika))
[AppiumDriver@9df7] Encountered internal error running command: Error executing adbExec. Original error: 'Command 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell cmd package list packages' exited with code 255'; Command output:
Exception occurred while executing 'list':
java.lang.SecurityException: Shell does not have permission to access user 10
com.android.server.am.ActivityManagerService.handleIncomingUser:15970 android.app.ActivityManager.handleIncomingUser:5152 com.android.server.pm.PackageManagerShellCommand.translateUserId:3733
at com.android.server.am.UserController.handleIncomingUser(UserController.java:2892)
at com.android.server.am.ActivityManagerService.handleIncomingUser(ActivityManagerService.java:15970)
at android.app.ActivityManager.handleIncomingUser(ActivityManager.java:5152)
at com.android.server.pm.PackageManagerShellCommand.translateUserId(PackageManagerShellCommand.java:3733)
at com.android.server.pm.PackageManagerShellCommand.runListPackages(PackageManagerShellCommand.java:1074)
at com.android.server.pm.PackageManagerShellCommand.runListPackages(PackageManagerShellCommand.java:960)
at com.android.server.pm.PackageManagerShellCommand.runList(PackageManagerShellCommand.java:800)
at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:237)
at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
at android.os.ShellCommand.exec(ShellCommand.java:38)
at com.android.server.pm.PackageManagerService$IPackageManagerImpl.onShellCommand(PackageManagerService.java:7119)
at android.os.Binder.shellCommand(Binder.java:1104)
at android.os.Binder.onTransact(Binder.java:914)
at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4905)
at com.android.server.pm.PackageManagerService$IPackageManagerImpl.onTransact(PackageManagerService.java:7103)
at android.os.Binder.execTransactInternal(Binder.java:1380)
at android.os.Binder.execTransact(Binder.java:1311)

Error: Command 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell cmd package list packages' exited with code 255
at ChildProcess. (C:\Users\Olli.appium\node_modules\appium-uiautomator2-driver\node_modules\teen_process\lib\exec.js:128:19)
at ChildProcess.emit (node:events:518:28)
at maybeClose (node:internal/child_process:1105:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:305:5)
at Process.callbackTrampoline (node:internal/async_hooks:130:17)
[HTTP] <-- POST /session 500 1028 ms - 4744
[Appium] Received SIGINT - shutting down
[AppiumDriver@9df7] There are no active sessions for cleanup
[HTTP] Waiting until the server is closed
[HTTP] Received server close event

it looks like the reset script uses the same logic that the driver itself.
You may still remove components manually:

adb uninstall io.appium.uiautomator2.server
adb uninstall io.appium.uiautomator2.server.test
adb uninstall io.appium.settings

Removing those components and then trying again had no effect and the logs:
[AppiumDriver@c698] Calling AppiumDriver.createSession() with args: [{"platformName":"Android","appium:automationName":"UIAutomator2","appium:platformVersion":"14","appium:skipServerInstallation":false,"appium:ensureWebviewsHavePages":true,"appium:nativeWebScreenshot":true,"appium:newCommandTimeout":3600,"appium:connectHardwareKeyboard":true},null,{"alwaysMatch":{"platformName":"Android","appium:automationName":"UIAutomator2","appium:platformVersion":"14","appium:skipServerInstallation":false,"appium:ensureWebviewsHavePages":true,"appium:nativeWebScreenshot":true,"appium:newCommandTimeout":3600,"appium:connectHardwareKeyboard":true},"firstMatch":[{}]}]
[AppiumDriver@c698] Event 'newSessionRequested' logged at 1718743502127 (23:45:02 GMT+0300 (Itä-Euroopan kesäaika))
[Appium] Attempting to find matching driver for automationName 'UIAutomator2' and platformName 'Android'
[Appium] The 'uiautomator2' driver was installed and matched caps.
[Appium] Will require it at C:\Users\Olli.appium\node_modules\appium-uiautomator2-driver
[Appium] Requiring driver at C:\Users\Olli.appium\node_modules\appium-uiautomator2-driver\build\index.js
[AppiumDriver@c698] Appium v2.10.3 creating new AndroidUiautomator2Driver (v3.5.5) session
[AppiumDriver@c698] Checking BaseDriver versions for Appium and AndroidUiautomator2Driver
[AppiumDriver@c698] Appium's BaseDriver version is 9.10.3
[AppiumDriver@c698] AndroidUiautomator2Driver's BaseDriver version is 9.10.3
[AndroidUiautomator2Driver@ecbc] undefined
[AndroidUiautomator2Driver@ecbc] Creating session with W3C capabilities: {
"alwaysMatch": {
"platformName": "Android",
"appium:automationName": "UIAutomator2",
"appium:platformVersion": "14",
"appium:skipServerInstallation": false,
"appium:ensureWebviewsHavePages": true,
"appium:nativeWebScreenshot": true,
"appium:newCommandTimeout": 3600,
"appium:connectHardwareKeyboard": true
},
"firstMatch": [
{}
]
}
[AndroidUiautomator2Driver@ecbc] The following provided capabilities were not recognized by this driver:
[AndroidUiautomator2Driver@ecbc] connectHardwareKeyboard
[AndroidUiautomator2Driver@ecbc] Session created with session id: 9b812ea6-ada4-4919-981b-22d2777c7b41
[ADB] Found 2 'build-tools' folders under 'C:\Users\Olli\AppData\Local\Android\sdk' (newest first):
[ADB] C:\Users\Olli\AppData\Local\Android\sdk\build-tools\35.0.0-rc1
[ADB] C:\Users\Olli\AppData\Local\Android\sdk\build-tools\34.0.0
[ADB] Using 'adb.exe' from 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe'
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 start-server'
[AndroidUiautomator2Driver@ecbc] Retrieving device list
[ADB] Trying to find connected Android devices
[ADB] Getting connected devices
[ADB] Connected devices: [{"udid":"RFCWA1JHGYL","state":"device"}]
[AndroidUiautomator2Driver@ecbc] Looking for a device with Android '14.0.0'
[ADB] Setting device id to RFCWA1JHGYL
[ADB] Getting device platform version
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell getprop ro.build.version.release'
[ADB] Current device property 'ro.build.version.release': 14
[AndroidUiautomator2Driver@ecbc] Using device: RFCWA1JHGYL
[ADB] Using 'adb.exe' from 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe'
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 start-server'
[ADB] Setting device id to RFCWA1JHGYL
[AndroidUiautomator2Driver@ecbc] Neither 'app' nor 'appPackage' was set. Starting UiAutomator2 without the target application
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell getprop ro.build.version.sdk'
[ADB] Current device property 'ro.build.version.sdk': 34
[ADB] Getting device platform version
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell getprop ro.build.version.release'
[ADB] Current device property 'ro.build.version.release': 14
[ADB] Device API level: 34
[AndroidUiautomator2Driver@ecbc] Relaxing hidden api policy
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL 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''
[AndroidUiautomator2Driver@ecbc] No app sent in, not parsing package/activity
[AndroidUiautomator2Driver@ecbc] Pushing settings apk to the device...
[ADB] Getting package info for 'io.appium.settings'
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell dumpsys package io.appium.settings'
[ADB] The version name of the installed 'io.appium.settings' is greater or equal to the application version name ('5.12.3' >= '5.12.3')
[ADB] There is no need to install/upgrade 'C:\Users\Olli.appium\node_modules\appium-uiautomator2-driver\node_modules\io.appium.settings\apks\settings_apk-debug.apk'
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell dumpsys activity services io.appium.settings'
[AndroidUiautomator2Driver@ecbc] io.appium.settings is already running. There is no need to reset its permissions.
[Logcat] Starting logs capture with command: C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL logcat -v threadtime
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell appops set io.appium.settings android:mock_location allow'
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell "[ -e '/data/local/tmp/mock_apps.json' ] && echo PASS"'
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell cat /data/local/tmp/mock_apps.json'
[AndroidUiautomator2Driver@ecbc] Forwarding UiAutomator2 Server port 6790 to local port 8200
[ADB] Forwarding system: 8200 to device: 6790
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL forward tcp:8200 tcp:6790'
[ADB] Getting package info for 'io.appium.uiautomator2.server'
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell dumpsys package io.appium.uiautomator2.server'
[ADB] Getting install status for io.appium.uiautomator2.server.test
[AndroidUiautomator2Driver@ecbc] No app capability. Assuming it is already on the device
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell cmd package list packages'
[ADB] App 'C:\Users\Olli.appium\node_modules\appium-uiautomator2-driver\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v7.0.13.apk' is not installed
[AndroidUiautomator2Driver@ecbc] Deleting UiAutomator2 session
[AndroidUiautomator2Driver@ecbc] Deleting UiAutomator2 server session
[AndroidUiautomator2Driver@ecbc] Matched '/' to command name 'deleteSession'
[AndroidUiautomator2Driver@ecbc] Did not get confirmation UiAutomator2 deleteSession worked; Error was: UnknownError: An unknown server-side error occurred while processing the command. Original error: Trying to proxy a session command without session id
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell dumpsys activity services io.appium.settings/.recorder.RecorderService'
[Logcat] Stopping logcat capture
[ADB] Removing forwarded port socket connection: 8200
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL forward --remove tcp:8200'
[AndroidUiautomator2Driver@ecbc] Restoring hidden api policy to the device default configuration
[ADB] Running 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell 'settings delete global hidden_api_policy_pre_p_apps;settings delete global hidden_api_policy_p_apps;settings delete global hidden_api_policy''
[AppiumDriver@c698] Event 'newSessionStarted' logged at 1718743502996 (23:45:02 GMT+0300 (Itä-Euroopan kesäaika))
[AppiumDriver@c698] Encountered internal error running command: Error executing adbExec. Original error: 'Command 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell cmd package list packages' exited with code 255'; Command output:

Exception occurred while executing 'list':
java.lang.SecurityException: Shell does not have permission to access user 10
com.android.server.am.ActivityManagerService.handleIncomingUser:15970 android.app.ActivityManager.handleIncomingUser:5152 com.android.server.pm.PackageManagerShellCommand.translateUserId:3733
at com.android.server.am.UserController.handleIncomingUser(UserController.java:2892)
at com.android.server.am.ActivityManagerService.handleIncomingUser(ActivityManagerService.java:15970)
at android.app.ActivityManager.handleIncomingUser(ActivityManager.java:5152)
at com.android.server.pm.PackageManagerShellCommand.translateUserId(PackageManagerShellCommand.java:3733)
at com.android.server.pm.PackageManagerShellCommand.runListPackages(PackageManagerShellCommand.java:1074)
at com.android.server.pm.PackageManagerShellCommand.runListPackages(PackageManagerShellCommand.java:960)
at com.android.server.pm.PackageManagerShellCommand.runList(PackageManagerShellCommand.java:800)
at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:237)
at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
at android.os.ShellCommand.exec(ShellCommand.java:38)
at com.android.server.pm.PackageManagerService$IPackageManagerImpl.onShellCommand(PackageManagerService.java:7119)
at android.os.Binder.shellCommand(Binder.java:1104)
at android.os.Binder.onTransact(Binder.java:914)
at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4905)
at com.android.server.pm.PackageManagerService$IPackageManagerImpl.onTransact(PackageManagerService.java:7103)
at android.os.Binder.execTransactInternal(Binder.java:1380)
at android.os.Binder.execTransact(Binder.java:1311)

Error: Command 'C:\Users\Olli\AppData\Local\Android\sdk\platform-tools\adb.exe -P 5037 -s RFCWA1JHGYL shell cmd package list packages' exited with code 255
at ChildProcess. (C:\Users\Olli.appium\node_modules\appium-uiautomator2-driver\node_modules\teen_process\lib\exec.js:128:19)
at ChildProcess.emit (node:events:518:28)
at maybeClose (node:internal/child_process:1105:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:305:5)
at Process.callbackTrampoline (node:internal/async_hooks:130:17)
[HTTP] <-- POST /session 500 878 ms - 4744

Checked google for similar issues and it looks like the issue has to do with profiles that are installed/activated on the device.

You may try to switch the profile to the default one (user 0) or use a different device that does not have such restrictions to run automated tests.

Yes i have a work profile set, i tried to use the uiautomator2 capability appium:userProfile and set it to 0 but no effect

Interesting met similar with update appium server and uiautomator on half phones. Removing Meraki Work profile helps. But still wonder why it worked before about 3 month old appium and uiAutomator driver....

I got the same issue with both versions 3.0.5 to 3.5.5. Do we have any way to pass the --user 0 to the appium configuration?

Seems similar to #810 . Please try to test with the driver version 3.7.6 that was just released which resolved this issue by appending --user 0.

Thanks to PR from @mykola-mokhnach

Seems similar to #810 . Please try to test with the driver version 3.7.6 that was just released which resolved this issue by appending --user 0.

Thanks to PR from @mykola-mokhnach

It works now. Thank you!