When I run my app from Android Studio and install it on the primary user on a device, I notice that it gets installed on the secondary user as well.
In the first place, why is this happening? The android:requiredForAllUsers
flag is false
by default, and in any case can only be used by system apps or pre-installed apps.
Or is it the case that this happens only for debug-mode apps installed via Android Studio?
How can I prevent this from happening?
It is critical for my app that it be installed on one user only. I have already read the following documents:
Supporting Multiple Users
Manage multiple users
Neither of those documents has any explanation of whether and how the installation process is affected by the multi-user feature.
There must surely be some manifest or build setting that permits or prevents installation on multiple users. Why isn't it easier to find? And why isn't this question more common on SO?
You don't prevent it, you do what you need to do: in this case it would be defining your run configuration so the app gets only installed where you want, because per default it gets installed everywhere I suppose. You can do this by specifying the flag --user user_id. You can get the id with adb shell pm list users
Reference: Android Studio 2.3.2 Launching the app under a work profile or another user account on the target device will result in a crash
The easiest way is to add the --user current
flag to launch configs.
Select Launch Configurations
The under Install Flags, add the flag --user current
. This will ensure the app is only installed on the current user and not on any guest acconuts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With