Recently, I wanted to test an old app, and as such, it required me to install it via ADB using adb install --bypass-low-target-sdk-block "apk-path", which worked fine and it was completely usable as expected.
However, I also want the app to be on the work profile, so I did some research, and found that I needed to pass the work user's id to install, like so: adb install --user 10 --bypass-low-target-sdk-block "apk-path"
Sadly, the command yielded an error:
Performing Streamed Install
adb: failed to install apk-path.apk:
Exception occurred while executing 'install':
java.lang.SecurityException: Shell does not have permission to access user 10
com.android.server.am.ActivityManagerService.handleIncomingUser:13963 android.app.ActivityManager.handleIncomingUser:5313 com.android.server.pm.PackageManagerShellCommand.translateUserId:3967
at com.android.server.am.UserController.handleIncomingUser(UserController.java:2932)
at com.android.server.am.ActivityManagerService.handleIncomingUser(ActivityManagerService.java:13963)
at android.app.ActivityManager.handleIncomingUser(ActivityManager.java:5313)
at com.android.server.pm.PackageManagerShellCommand.translateUserId(PackageManagerShellCommand.java:3967)
at com.android.server.pm.PackageManagerShellCommand.doCreateSession(PackageManagerShellCommand.java:3978)
at com.android.server.pm.PackageManagerShellCommand.doRunInstall(PackageManagerShellCommand.java:1628)
at com.android.server.pm.PackageManagerShellCommand.runInstall(PackageManagerShellCommand.java:1564)
at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:248)
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:6705)
at android.os.Binder.shellCommand(Binder.java:1163)
at android.os.Binder.onTransact(Binder.java:965)
at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4891)
at com.android.server.pm.PackageManagerService$IPackageManagerImpl.onTransact(PackageManagerService.java:6689)
at android.os.Binder.execTransactInternal(Binder.java:1470)
at android.os.Binder.execTransact(Binder.java:1404)
I didn't think that this was the issue, but I even attempted installing another app that didn't require --bypass-low-target-sdk-block to the work profile but the same thing happens.
I wonder if there is way to access the work profile via ADB? Apparently, this other person was having similar issues, however that thread has gone cold: