'How to use `adb` to install development apps for one user only?

Android 4.2 on tablets added support for multiple users per device (similar to desktop OSes), each of which can install and remove apps independently. Currently, using adb install /path/to/app.apk installs the app globally; every user can see and launch it (as if every user installed the same app from the Play store for example).

Is there a way to adb install an app onto a device so that only one user can see it in the launcher menu?



Solution 1:[1]

adb install now supports --user USER_ID argument, so in order to install APK for a certain user, use:

adb install --user USER_ID PATH_TO_APK

In order to find out USER_ID, use adb shell pm list users.

See https://source.android.com/devices/tech/admin/multi-user-testing for details.

Solution 2:[2]

It may not have a per-user 'adb install', but it does have a per-user 'start' option when you want actual run the APK for testing. By default the documentation says 'start' will just start for the currently running user, but you can do

adb shell am start --user USER activity...

to start the APK as someone else. To get a list of users, run

adb shell pm list users

Solution 3:[3]

Here is the full documentation of the adb tool: http://developer.android.com/tools/help/adb.html adb install doesn't provide any way to specify the target users.

Solution 4:[4]

I stumbled across this post when I was having issues installing a React Native app on a phone with a separate Work Profile on it. For some reason, it felt like it was randomly choosing which profile to install the app on.

Here's what I did to specify the user manually:

  1. Build the app at least once:

    npx react-native run-android
    
  2. Uninstall if needed:

    adb uninstall <your package name here>
    
  3. Install the app manually. The APK path should be relative to the top level of your project:

    adb install --user 0 ./android/app/build/outputs/apk/debug/app-debug.apk
    

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 petrkotek
Solution 2 Xiao
Solution 3 GareginSargsyan
Solution 4 Chris Pavs