Getting Error io.appium.settings could not be assigned a valid UID

Hi I am getting issue: INSTALL_FAILED_INSUFFICIENT_STORAGE: Package io.appium.settings could not be assigned a valid UID

Operating system: Windows 10
Appium CLI Version: 1.22.3
Appium Java Client: 8.2.0
Platform: Android
Real Device: Motorola Edge 20 Fusion
Android version: 12

Till now everything was fine, but suddenly getting INSTALL_FAILED_INSUFFICIENT_STORAGE: Package io.appium.settings could not be assigned a valid UID

After restarting application is working once and on next launch getting the same error.

Below is the server Logs
2022-11-01 19:01:18:115 [Appium] Welcome to Appium v1.22.3
2022-11-01 19:01:18:116 [Appium] Non-default server args:
2022-11-01 19:01:18:116 [Appium] basePath: wd/hub/
2022-11-01 19:01:18:116 [Appium] sessionOverride: true
2022-11-01 19:01:18:117 [Appium] logFile: D:\Workspace\Project\MyCard\mycard\Logs\Android_Motorola Edge 20 Fusion\Server.log
2022-11-01 19:01:18:117 [Appium] loglevel: info:debug
2022-11-01 19:01:18:117 [Appium] relaxedSecurityEnabled: true
2022-11-01 19:01:18:142 [Appium] Appium REST http interface listener started on 0.0.0.0:4723
2022-11-01 19:01:18:503 [HTTP] --> GET /wd/hub/status
2022-11-01 19:01:18:504 [HTTP] {}
2022-11-01 19:01:18:506 [GENERIC] Calling AppiumDriver.getStatus() with args: []
2022-11-01 19:01:18:507 [GENERIC] Responding to client with driver.getStatus() result: {“build”:{“version”:“1.22.3”}}
2022-11-01 19:01:18:515 [HTTP] <-- GET /wd/hub/status 200 9 ms - 68
2022-11-01 19:01:18:515 [HTTP]
2022-11-01 19:01:18:522 [HTTP] --> GET /wd/hub/status
2022-11-01 19:01:18:522 [HTTP] {}
2022-11-01 19:01:18:523 [GENERIC] Calling AppiumDriver.getStatus() with args: []
2022-11-01 19:01:18:523 [GENERIC] Responding to client with driver.getStatus() result: {“build”:{“version”:“1.22.3”}}
2022-11-01 19:01:18:524 [HTTP] <-- GET /wd/hub/status 200 2 ms - 68
2022-11-01 19:01:18:525 [HTTP]
2022-11-01 19:01:20:317 [HTTP] Request idempotency key: 0e2dd7c8-838f-4e4a-8253-876ec3368799
2022-11-01 19:01:20:341 [HTTP] --> POST /wd/hub/session
2022-11-01 19:01:20:341 [HTTP] {“capabilities”:{“firstMatch”:[{}],“alwaysMatch”:{“appium:adbExecTimeout”:60000,“appium:app”:“D:\Workspace\Project\MyCard\mycard\apps\android\Demo.apk”,“appium:appActivity”:“com.demo.LauncherActivity”,“appium:appPackage”:“com.demo”,“appium:appWaitActivity”:"",“appium:appWaitForLaunch”:false,“appium:autoGrantPermissions”:true,“appium:automationName”:“UIAutomator2”,“appium:clearDeviceLogsOnStart”:true,“appium:clearSystemFiles”:true,“appium:deviceName”:“Motorola Edge 20 Fusion”,“appium:ensureWebviewsHavePages”:true,“appium:fullReset”:false,“appium:newCommandTimeout”:200,“appium:noReset”:true,“appium:resetKeyboard”:true,“appium:showChromedriverLog”:true,“appium:systemPort”:10013,“appium:udid”:“ZD2222ZKDN”,“appium:unicodeKeyboard”:true,“platformName”:“android”}}}
2022-11-01 19:01:20:342 [W3C] Calling AppiumDriver.createSession() with args: [null,null,{“firstMatch”:[{}],“alwaysMatch”:{“appium:adbExecTimeout”:60000,“appium:app”:“D:\Workspace\Project\MyCard\mycard\apps\android\Demo.apk”,“appium:appActivity”:“com.rblbank.mycard.LauncherActivity”,“appium:appPackage”:“com.demo”,“appium:appWaitActivity”:"
",“appium:appWaitForLaunch”:false,“appium:autoGrantPermissions”:true,“appium:automationName”:“UIAutomator2”,“appium:clearDeviceLogsOnStart”:true,“appium:clearSystemFiles”:true,“appium:deviceName”:“Motorola Edge 20 Fusion”,“appium:ensureWebviewsHavePages”:true,“appium:fullReset”:false,“appium:newCommandTimeout”:200,“appium:noReset”:true,“appium:resetKeyboard”:true,“appium:showChromedriverLog”:true,“appium:systemPort”:10013,“appium:udid”:“ZD2222ZKDN”,“appium:unicodeKeyboard”:true,“platformName”:“android”}}]
2022-11-01 19:01:20:343 [BaseDriver] Event ‘newSessionRequested’ logged at 1667329280342 (00:31:20 GMT+0530 (India Standard Time))
2022-11-01 19:01:20:753 [Appium] Appium v1.22.3 creating new AndroidUiautomator2Driver (v1.70.1) session
2022-11-01 19:01:20:753 [Appium] There are no active sessions for cleanup
2022-11-01 19:01:20:754 [Appium] Applying relaxed security to ‘AndroidUiautomator2Driver’ as per server command line argument. All insecure features will be enabled unless explicitly disabled by --deny-insecure
2022-11-01 19:01:20:755 [BaseDriver] Creating session with W3C capabilities: {
2022-11-01 19:01:20:755 [BaseDriver] “alwaysMatch”: {
2022-11-01 19:01:20:756 [BaseDriver] “platformName”: “android”,
2022-11-01 19:01:20:756 [BaseDriver] “appium:adbExecTimeout”: 60000,
2022-11-01 19:01:20:756 [BaseDriver] “appium:app”: “D:\Workspace\Project\MyCard\mycard\apps\android\Demo.apk”,
2022-11-01 19:01:20:756 [BaseDriver] “appium:appActivity”: “com.rblbank.mycard.LauncherActivity”,
2022-11-01 19:01:20:756 [BaseDriver] “appium:appPackage”: “com.demo”,
2022-11-01 19:01:20:756 [BaseDriver] “appium:appWaitActivity”: “*”,
2022-11-01 19:01:20:756 [BaseDriver] “appium:appWaitForLaunch”: false,
2022-11-01 19:01:20:756 [BaseDriver] “appium:autoGrantPermissions”: true,
2022-11-01 19:01:20:756 [BaseDriver] “appium:automationName”: “UIAutomator2”,
2022-11-01 19:01:20:756 [BaseDriver] “appium:clearDeviceLogsOnStart”: true,
2022-11-01 19:01:20:756 [BaseDriver] “appium:clearSystemFiles”: true,
2022-11-01 19:01:20:756 [BaseDriver] “appium:deviceName”: “Motorola Edge 20 Fusion”,
2022-11-01 19:01:20:758 [BaseDriver] “appium:ensureWebviewsHavePages”: true,
2022-11-01 19:01:20:759 [BaseDriver] “appium:fullReset”: false,
2022-11-01 19:01:20:759 [BaseDriver] “appium:newCommandTimeout”: 200,
2022-11-01 19:01:20:759 [BaseDriver] “appium:noReset”: true,
2022-11-01 19:01:20:759 [BaseDriver] “appium:resetKeyboard”: true,
2022-11-01 19:01:20:759 [BaseDriver] “appium:showChromedriverLog”: true,
2022-11-01 19:01:20:759 [BaseDriver] “appium:systemPort”: 10013,
2022-11-01 19:01:20:759 [BaseDriver] “appium:udid”: “ZD2222ZKDN”,
2022-11-01 19:01:20:759 [BaseDriver] “appium:unicodeKeyboard”: true
2022-11-01 19:01:20:759 [BaseDriver] },
2022-11-01 19:01:20:759 [BaseDriver] “firstMatch”: [
2022-11-01 19:01:20:759 [BaseDriver] {}
2022-11-01 19:01:20:759 [BaseDriver] ]
2022-11-01 19:01:20:759 [BaseDriver] }
2022-11-01 19:01:20:766 [BaseDriver] Session created with session id: 19ff654b-4242-4f44-bf38-2106a1703f4d
2022-11-01 19:01:20:768 [BaseDriver] Using local app ‘D:\Workspace\Project\MyCard\mycard\apps\android\Demo.apk’
2022-11-01 19:01:20:768 [UiAutomator2] Checking whether app is actually present
2022-11-01 19:01:20:785 [ADB] Found 2 ‘build-tools’ folders under ‘D:\Software_Installed\Android\Sdk’ (newest first):
2022-11-01 19:01:20:785 [ADB] D:/Software_Installed/Android/Sdk/build-tools/33.0.0
2022-11-01 19:01:20:785 [ADB] D:/Software_Installed/Android/Sdk/build-tools/32.0.0
2022-11-01 19:01:20:785 [ADB] Using ‘adb.exe’ from ‘D:\Software_Installed\Android\Sdk\platform-tools\adb.exe’
2022-11-01 19:01:20:786 [ADB] Running ‘D:\Software_Installed\Android\Sdk\platform-tools\adb.exe -P 5037 start-server’
2022-11-01 19:01:20:980 [AndroidDriver] Retrieving device list
2022-11-01 19:01:20:980 [ADB] Trying to find a connected android device
2022-11-01 19:01:20:981 [ADB] Getting connected devices
2022-11-01 19:01:21:131 [ADB] Connected devices: [{“udid”:“ZD2222ZKDN”,“state”:“device”}]
2022-11-01 19:01:21:131 [AndroidDriver] Using device: ZD2222ZKDN
2022-11-01 19:01:21:132 [ADB] Using ‘adb.exe’ from ‘D:\Software_Installed\Android\Sdk\platform-tools\adb.exe’
2022-11-01 19:01:21:132 [ADB] Running ‘D:\Software_Installed\Android\Sdk\platform-tools\adb.exe -P 5037 start-server’
2022-11-01 19:01:21:282 [ADB] Setting device id to ZD2222ZKDN
2022-11-01 19:01:21:282 [ADB] Running ‘D:\Software_Installed\Android\Sdk\platform-tools\adb.exe -P 5037 -s ZD2222ZKDN shell getprop ro.build.version.sdk’
2022-11-01 19:01:21:469 [ADB] Current device property ‘ro.build.version.sdk’: 31
2022-11-01 19:01:21:470 [ADB] Getting device platform version
2022-11-01 19:01:21:470 [ADB] Running ‘D:\Software_Installed\Android\Sdk\platform-tools\adb.exe -P 5037 -s ZD2222ZKDN shell getprop ro.build.version.release’
2022-11-01 19:01:21:659 [ADB] Current device property ‘ro.build.version.release’: 12
2022-11-01 19:01:21:659 [ADB] Device API level: 31
2022-11-01 19:01:21:660 [UiAutomator2] Relaxing hidden api policy
2022-11-01 19:01:21:660 [ADB] Running ‘D:\Software_Installed\Android\Sdk\platform-tools\adb.exe -P 5037 -s ZD2222ZKDN 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’’
2022-11-01 19:01:21:959 [ADB] Running ‘D:\Software_Installed\Android\Sdk\platform-tools\adb.exe -P 5037 -s ZD2222ZKDN wait-for-device’
2022-11-01 19:01:22:102 [ADB] Running ‘D:\Software_Installed\Android\Sdk\platform-tools\adb.exe -P 5037 -s ZD2222ZKDN shell echo ping’
2022-11-01 19:01:22:272 [AndroidDriver] Pushing settings apk to device…
2022-11-01 19:01:22:273 [ADB] Getting install status for io.appium.settings
2022-11-01 19:01:22:273 [ADB] Running ‘D:\Software_Installed\Android\Sdk\platform-tools\adb.exe -P 5037 -s ZD2222ZKDN shell dumpsys package io.appium.settings’
2022-11-01 19:01:22:575 [ADB] ‘io.appium.settings’ is not installed
2022-11-01 19:01:22:576 [ADB] App ‘C:\Users\deepakv\AppData\Roaming\npm\node_modules\appium\node_modules\io.appium.settings\apks\settings_apk-debug.apk’ is not installed
2022-11-01 19:01:22:576 [ADB] Installing ‘C:\Users\deepakv\AppData\Roaming\npm\node_modules\appium\node_modules\io.appium.settings\apks\settings_apk-debug.apk’
2022-11-01 19:01:22:577 [ADB] Running ‘D:\Software_Installed\Android\Sdk\platform-tools\adb.exe -P 5037 -s ZD2222ZKDN help’
2022-11-01 19:01:22:731 [ADB] Running ‘D:\Software_Installed\Android\Sdk\platform-tools\adb.exe -P 5037 -s ZD2222ZKDN features’
2022-11-01 19:01:22:870 [ADB] The application at ‘C:\Users\deepakv\AppData\Roaming\npm\node_modules\appium\node_modules\io.appium.settings\apks\settings_apk-debug.apk’ will not be cached, because the device under test has confirmed the support of streamed installs
2022-11-01 19:01:22:870 [ADB] Running ‘D:\Software_Installed\Android\Sdk\platform-tools\adb.exe -P 5037 -s ZD2222ZKDN install -g C:\Users\deepakv\AppData\Roaming\npm\node_modules\appium\node_modules\io.appium.settings\apks\settings_apk-debug.apk’
2022-11-01 19:01:23:749 [ADB] Getting install status for io.appium.settings
2022-11-01 19:01:23:750 [ADB] Running ‘D:\Software_Installed\Android\Sdk\platform-tools\adb.exe -P 5037 -s ZD2222ZKDN shell dumpsys package io.appium.settings’
2022-11-01 19:01:24:005 [ADB] ‘io.appium.settings’ is not installed
2022-11-01 19:01:24:005 [ADB] App ‘C:\Users\deepakv\AppData\Roaming\npm\node_modules\appium\node_modules\io.appium.settings\apks\settings_apk-debug.apk’ is not installed
2022-11-01 19:01:24:005 [ADB] Installing ‘C:\Users\deepakv\AppData\Roaming\npm\node_modules\appium\node_modules\io.appium.settings\apks\settings_apk-debug.apk’
2022-11-01 19:01:24:006 [ADB] The application at ‘C:\Users\deepakv\AppData\Roaming\npm\node_modules\appium\node_modules\io.appium.settings\apks\settings_apk-debug.apk’ will not be cached, because the device under test has confirmed the support of streamed installs
2022-11-01 19:01:24:006 [ADB] Running ‘D:\Software_Installed\Android\Sdk\platform-tools\adb.exe -P 5037 -s ZD2222ZKDN install -g C:\Users\deepakv\AppData\Roaming\npm\node_modules\appium\node_modules\io.appium.settings\apks\settings_apk-debug.apk’
2022-11-01 19:01:24:773 [UiAutomator2] Deleting UiAutomator2 session
2022-11-01 19:01:24:773 [ADB] Running ‘D:\Software_Installed\Android\Sdk\platform-tools\adb.exe -P 5037 -s ZD2222ZKDN shell am force-stop com.demo’
2022-11-01 19:01:25:051 [ADB] Removing forwarded port socket connection: 10013
2022-11-01 19:01:25:051 [ADB] Running ‘D:\Software_Installed\Android\Sdk\platform-tools\adb.exe -P 5037 -s ZD2222ZKDN forward --remove tcp:10013’
2022-11-01 19:01:25:255 [UiAutomator2] Unable to remove system port forward: Error executing adbExec. Original error: ‘Command ‘D:\Software_Installed\Android\Sdk\platform-tools\adb.exe -P 5037 -s ZD2222ZKDN forward --remove tcp:10013’ exited with code 1’; Command output: adb.exe: error: listener ‘tcp:10013’ not found

2022-11-01 19:01:25:255 [UiAutomator2] 
2022-11-01 19:01:25:255 [UiAutomator2] Restoring hidden api policy to the device default configuration
2022-11-01 19:01:25:255 [ADB] Running 'D:\Software_Installed\Android\Sdk\platform-tools\adb.exe -P 5037 -s ZD2222ZKDN shell 'settings delete global hidden_api_policy_pre_p_apps;settings delete global hidden_api_policy_p_apps;settings delete global hidden_api_policy''
2022-11-01 19:01:25:561 [BaseDriver] Event 'newSessionStarted' logged at 1667329285561 (00:31:25 GMT+0530 (India Standard Time))
2022-11-01 19:01:25:561 [W3C] Encountered internal error running command: Error executing adbExec. Original error: 'Command 'D:\\Software_Installed\\Android\\Sdk\\platform-tools\\adb.exe -P 5037 -s ZD2222ZKDN install -g C:\\Users\\deepakv\\AppData\\Roaming\\npm\\node_modules\\appium\\node_modules\\io.appium.settings\\apks\\settings_apk-debug.apk' exited with code 1'; Command output: adb: failed to install C:\Users\deepakv\AppData\Roaming\npm\node_modules\appium\node_modules\io.appium.settings\apks\settings_apk-debug.apk: Failure [INSTALL_FAILED_INSUFFICIENT_STORAGE: Scanning Failed.: Package io.appium.settings could not be assigned a valid UID]

2022-11-01 19:01:25:561 [W3C] 
2022-11-01 19:01:25:561 [W3C] Error: Command 'D:\\Software_Installed\\Android\\Sdk\\platform-tools\\adb.exe -P 5037 -s ZD2222ZKDN install -g C:\\Users\\deepakv\\AppData\\Roaming\\npm\\node_modules\\appium\\node_modules\\io.appium.settings\\apks\\settings_apk-debug.apk' exited with code 1
2022-11-01 19:01:25:561 [W3C]     at ChildProcess.<anonymous> (C:\Users\deepakv\AppData\Roaming\npm\node_modules\appium\node_modules\teen_process\lib\exec.js:113:19)
2022-11-01 19:01:25:561 [W3C]     at ChildProcess.emit (events.js:400:28)
2022-11-01 19:01:25:562 [W3C]     at maybeClose (internal/child_process.js:1058:16)
2022-11-01 19:01:25:562 [W3C]     at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5)
2022-11-01 19:01:25:594 [HTTP] <-- POST /wd/hub/session 500 5252 ms - 1815
2022-11-01 19:01:25:594 [HTTP]

Reboot your device. Android allows up to 10000 application reinstalls within single boot session

1 Like

After Reboot now the application is working fine.

Just started seeing this on a device for the first time. Rebooted, and it happened again 3 days later, so I’m going to swap out the phone. The same phone has been standing in my test rig for about 6 months, and hardly ever gets rebooted. Never had this issue until last week, I removed loads of files and rebooted, which worked for literally 2 days. Did this re-occur for anyone?

Did you figure it out? I have the same problem. Reboot doesn’t help.

In my case I encountered the following error:

.....tings\apks\settings_apk-debug.apk: Failure [INSTALL_FAILED_INSUFFICIENT_STORAGE: Scanning Failed.: Package io.appium.settings could not be assigned a valid UID]

So, to address this, I forcefully clear the App Storage and Cache for the Settings APK just before executing driver.quit() .

// Clear App Storage and Cache for io.appium.settings
Map<String, Object> args = new HashMap<>();
args.put("command", "pm");
args.put("args", List.of("clear", "io.appium.settings"));
args.put("timeout", 30000);
args.put("includeStderr", true);
Map<String, Object> result = (Map<String, Object>) ((AppiumDriver) webDriver).executeScript("mobile: shell", args);
System.out.println("clearAppStorageAndCache " + result);
// Force-stop io.appium.settings
args = new HashMap<>();
args.put("command", "am");
args.put("args", List.of("force-stop", "io.appium.settings"));
args.put("timeout", 30000);
args.put("includeStderr", true);
result = (Map<String, Object>) ((AppiumDriver) webDriver).executeScript("mobile: shell", args);

I applied the same procedure for io.appium.uiautomator2.server and io.appium.uiautomator2.server.test.

For me, we swapped out to a more updated model of phone and not had issue - perhaps the device constraints play a part if in this re-occurring, but not had issue come back after dropping in a newer phone.

1 Like