Not allowed to set device owner because there are already multiple users on the device

I followed this tutorial to set the app as device owner. This tutorial has a section titled "Using adb to set a device owner". This tutorial says that after installing the Kiosk Mode demo application, run the following command:

adb shell dpm set-device-owner sdg.example.kiosk_mode/.AdminReceiver

      

This gave me an error:

adb server is out of date.  killing...
* daemon started successfully *
java.lang.IllegalStateException: Not allowed to set the device owner because there are already several users on the device
    at android.os.Parcel.readException(Parcel.java:1629)
    at android.os.Parcel.readException(Parcel.java:1574)
    at android.app.admin.IDevicePolicyManager$Stub$Proxy.setDeviceOwner(IDevicePolicyManager.java:5146)
    at com.android.commands.dpm.Dpm.runSetDeviceOwner(Dpm.java:114)
    at com.android.commands.dpm.Dpm.onRun(Dpm.java:82)
    at com.android.internal.os.BaseCommand.run(BaseCommand.java:47)
    at com.android.commands.dpm.Dpm.main(Dpm.java:38)
    at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
    at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:257)

      

I followed this SO link> and Diego Plasencia Lara's answer helped me get rid of

adb server is out of date.  killing...
* daemon started successfully *

      

But after executing the command adb shell dpm set-device-owner sdg.example.kiosk_mode/.AdminReceiver

, the following error occurs:

java.lang.IllegalStateException: Not allowed to set the device owner because there are already several users on the device
    at android.os.Parcel.readException(Parcel.java:1629)
    at android.os.Parcel.readException(Parcel.java:1574)
    at android.app.admin.IDevicePolicyManager$Stub$Proxy.setDeviceOwner(IDevicePolicyManager.java:5146)
    at com.android.commands.dpm.Dpm.runSetDeviceOwner(Dpm.java:114)
    at com.android.commands.dpm.Dpm.onRun(Dpm.java:82)
    at com.android.internal.os.BaseCommand.run(BaseCommand.java:47)
    at com.android.commands.dpm.Dpm.main(Dpm.java:38)
    at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
    at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:257)

      

Why is this error happening and how can I remove it? I used to try to install different apps as the device owner, but I think I was unable to disable them completely and there were always some errors while doing the whole app launch procedure on the device.

+3


source to share


2 answers


This post gives a really good overview of the dpm command: http://florent-dupont.blogspot.fr/2015/01/android-shell-command-dpm-device-policy.html

At the end of the post this update has been added: "The device owner can only be installed on a non-produced device, unless it was initiated by 'adb', in which case we allow it if there is no account associated with the device," the source says. So make sure you don't have an account (like Gmail) associated with your current user before using the dpm command "



I recommend installing and installing the app as device owner using dpm after doing a factory reset, going through the Google Wizard without setting up accounts, enabling developer mode from settings, and finally enabling "USB debugging" ... If this is a viable option for you...

+2


source


There is a way out of this problem without Factory - device recovery. Just delete all accounts from your device (in settings -> accounts). You can sync your data before doing so, so you can restore it later. After deleting all accounts, connect your phone to your computer and run the command:

adb shell dpm set-device-owner sdg.example.kiosk_mode/.AdminReceiver

If you get a message like this:



Success: Device owner set to package ComponentInfo{org.bluetooth.bledemo/org.bluetooth.bledemo.AdminReceiver}
Active admin set to component {org.bluetooth.bledemo/org.bluetooth.bledemo.AdminReceiver}

      

consider yourself successful. You can now add back all the accounts that you deleted earlier.

Another way . As Steve Miskovets pointed out in his answer, factory reset is one way to set an app as the owner of the device if your phone previously had accounts (like Gmail). But in recent versions of Android and / or some phones, after doing a factory reset, they do not allow you to move forward unless you have set up a google account. So to fix this problem, sign up and register your google account, and when your phone is back to normal working state, delete that account by going to Settings β†’ Accounts. Now you need to enable developer mode and then debug USB . After that, connect your phone to your computer and run the command adb shell dpm set-device-owner sdg.example.kiosk_mode/.AdminReceiver

.

+4


source







All Articles