I am getting following error while executing appium java script

Hello Team,

I am getting an error while executing appium java script on Realme C1, Android 9.0 mobile device. but the same script running fine on Lenovo , Android 5.1.1 mobile device.

following is error
org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: ‘Command ‘C:\Users\win10\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s b990d528 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

java.lang.SecurityException: Permission denial: writing to settings requires:android.permission.WRITE_SECURE_SETTINGS
at com.android.providers.settings.SettingsProvider.enforceWritePermission(SettingsProvider.java:2028)
at com.android.providers.settings.SettingsProvider.mutateGlobalSetting(SettingsProvider.java:1093)
at com.android.providers.settings.SettingsProvider.deleteGlobalSetting(SettingsProvider.java:1076)
at com.android.providers.settings.SettingsProvider.delete(SettingsProvider.java:666)
at android.content.ContentProvider$Transport.delete(ContentProvider.java:408)
at com.android.providers.settings.SettingsService$MyShellCommand.deleteForUser(SettingsService.java:406)
at com.android.providers.settings.SettingsService$MyShellCommand.onCommand(SettingsService.java:289)
at android.os.ShellCommand.exec(ShellCommand.java:103)

The devices from this manufacturer are probably not good for automated testing

  1. go to developer option.
  2. go to last option called --> Disable Permission Monitoring --> enable it.
13 Likes

@Sandeep_Duve Thank you so much. Its working .

1 Like

The same error happens to me but with Xiaomi device, and I can’t find ‘Disable Permission Monitoring’ in my device. Does anyone know the same option in Xiaomi device?

3 Likes

Linking https://github.com/appium/appium/issues/13802

@Sandeep_Duve
Thank you so much, it actually worked

1 Like

thanks, it worked like a charm

1 Like

Thku sir its working. i m @Sandeep_Duve facing some other error. Can you have a solution on it. Need a +ve response.

[ADB] Using ‘apksigner.jar’ from ‘C:\Users\jeebu\AppData\Local\Android\Sdk\build-tools\30.0.2\lib\apksigner.jar’
[debug] [UiAutomator2] Deleting UiAutomator2 session
[debug] [UiAutomator2] Deleting UiAutomator2 server session
[debug] [WD Proxy] Matched ‘/’ to command name ‘deleteSession’
[UiAutomator2] 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
[debug] [ADB] Running ‘C:\Users\jeebu\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s d6abca80 shell am force-stop com.colouros.calculator’
[debug] [Logcat] Stopping logcat capture
[debug] [ADB] Removing forwarded port socket connection: 8200
[debug] [ADB] Running ‘C:\Users\jeebu\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s d6abca80 forward --remove tcp:8200’
[UiAutomator2] Restoring hidden api policy to the device default configuration
[debug] [ADB] Running ‘C:\Users\jeebu\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s d6abca80 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 1606934184300 (00:06:24 GMT+0530 (India Standard Time))
[debug] [W3C] Encountered internal error running command: Error: Cannot verify the signature of ‘C:\Users\jeebu\AppData\Roaming\npm\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v4.15.0.apk’. Original error: The JAVA_HOME environment variable must be set for Android Tools to work properly
[debug] [W3C] at ADB.checkApkCert (C:\Users\jeebu\AppData\Roaming\npm\node_modules\appium\node_modules\appium-adb\lib\tools\apk-signing.js:267:11)
[debug] [W3C] at UiAutomator2Server.installServerApk (C:\Users\jeebu\AppData\Roaming\npm\node_modules\appium\node_modules\appium-uiautomator2-driver\lib\uiautomator2.js:94:13)
[debug] [W3C] at AndroidUiautomator2Driver.initUiAutomator2Server (C:\Users\jeebu\AppData\Roaming\npm\node_modules\appium\node_modules\appium-uiautomator2-driver\lib\driver.js:484:7)
[debug] [W3C] at AndroidUiautomator2Driver.startUiAutomator2Session (C:\Users\jeebu\AppData\Roaming\npm\node_modules\appium\node_modules\appium-uiautomator2-driver\lib\driver.js:379:5)
[debug] [W3C] at AndroidUiautomator2Driver.createSession (C:\Users\jeebu\AppData\Roaming\npm\node_modules\appium\node_modules\appium-uiautomator2-driver\lib\driver.js:224:7)
[debug] [W3C] at AppiumDriver.createSession (C:\Users\jeebu\AppData\Roaming\npm\node_modules\appium\lib\appium.js:366:35)
[debug] [W3C] Destroying socket connection
[HTTP] <-- POST /wd/hub/session 500 6036 ms - 1123

For MIUI or POCO users there are additional 2 options which needs disabled to make it work and those are:

  1. Verify apps over USB.
  2. Verify bytecode of debuggable apps.

Hope this helps. Happy automation!!

Best,
Sachin

thankyou Sandeep_Duve
its working for me in OPPO A74 5G android 11

Hi Rajeev,
Today i got same error ,could you plz tell me , what is the problem and how to slove this [quote=“Rajeev_singh1, post:9, topic:29904, full:true”]
Thku sir its working. i m @Sandeep_Duve facing some other error. Can you have a solution on it. Need a +ve response.

[ADB] Using ‘apksigner.jar’ from ‘C:\Users\jeebu\AppData\Local\Android\Sdk\build-tools\30.0.2\lib\apksigner.jar’
[debug] [UiAutomator2] Deleting UiAutomator2 session
[debug] [UiAutomator2] Deleting UiAutomator2 server session
[debug] [WD Proxy] Matched ‘/’ to command name ‘deleteSession’
[UiAutomator2] 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
[debug] [ADB] Running ‘C:\Users\jeebu\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s d6abca80 shell am force-stop com.colouros.calculator’
[debug] [Logcat] Stopping logcat capture
[debug] [ADB] Removing forwarded port socket connection: 8200
[debug] [ADB] Running ‘C:\Users\jeebu\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s d6abca80 forward --remove tcp:8200’
[UiAutomator2] Restoring hidden api policy to the device default configuration
[debug] [ADB] Running ‘C:\Users\jeebu\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s d6abca80 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 1606934184300 (00:06:24 GMT+0530 (India Standard Time))
[debug] [W3C] Encountered internal error running command: Error: Cannot verify the signature of ‘C:\Users\jeebu\AppData\Roaming\npm\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v4.15.0.apk’. Original error: The JAVA_HOME environment variable must be set for Android Tools to work properly
[debug] [W3C] at ADB.checkApkCert (C:\Users\jeebu\AppData\Roaming\npm\node_modules\appium\node_modules\appium-adb\lib\tools\apk-signing.js:267:11)
[debug] [W3C] at UiAutomator2Server.installServerApk (C:\Users\jeebu\AppData\Roaming\npm\node_modules\appium\node_modules\appium-uiautomator2-driver\lib\uiautomator2.js:94:13)
[debug] [W3C] at AndroidUiautomator2Driver.initUiAutomator2Server (C:\Users\jeebu\AppData\Roaming\npm\node_modules\appium\node_modules\appium-uiautomator2-driver\lib\driver.js:484:7)
[debug] [W3C] at AndroidUiautomator2Driver.startUiAutomator2Session (C:\Users\jeebu\AppData\Roaming\npm\node_modules\appium\node_modules\appium-uiautomator2-driver\lib\driver.js:379:5)
[debug] [W3C] at AndroidUiautomator2Driver.createSession (C:\Users\jeebu\AppData\Roaming\npm\node_modules\appium\node_modules\appium-uiautomator2-driver\lib\driver.js:224:7)
[debug] [W3C] at AppiumDriver.createSession (C:\Users\jeebu\AppData\Roaming\npm\node_modules\appium\lib\appium.js:366:35)
[debug] [W3C] Destroying socket connection
[HTTP] <-- POST /wd/hub/session 500 6036 ms - 1123
[/quote]

Hi , i am getting this error , what is the problem and how to slove this , could you plz tell me