androidadbandroid-for-work

Install APK in Work Profile via ADB in Android


Let's say we have a Work Profile (Android For Work) enabled in Android device. Does anyone know how to install an APK via ADB in Work Profile rather than personal profile.

I have seen the ADB documentation and there's a way to get the User ID but using the same ID I am unable to install an APK.

To get ID : adb shell pm list users Install command : adb install -r --user 12 app_name.apk

Error message :

Performing Streamed Install
adb: failed to install app-prodDebug.apk: Security exception: Shell does not have permission to access user 12
 com.android.server.am.ActivityManagerService.handleIncomingUser:22541 android.app.ActivityManager.handleIncomingUser:3989 com.android.server.pm.PackageManagerShellCommand.translateUserId:2434

java.lang.SecurityException: Shell does not have permission to access user 12
 com.android.server.am.ActivityManagerService.handleIncomingUser:22541 android.app.ActivityManager.handleIncomingUser:3989 com.android.server.pm.PackageManagerShellComma

Any way to get around this ? My use case here is to replace an App with debug option enabled so that I can troubleshoot any issue that is happening with that specific app which is installed in work profile.


Solution

  • adb push android.apk /data/local/tmp
    adb shell pm install --user 12 /data/local/tmp/android.apk