Not allowed to set the device owner because there are already several users on the device : <p>I was following this <a href="https://sdgsystems.com/blog/implementing-kiosk-mode-android-part-3-android-lollipop" rel="noreferrer">tutorial</a> to set the app as device owner. In that tutorial, there is a section 'Using adb to set the device owner'. The tutorial here says that after installing the Kiosk Mode Demo App, run the following command:</p>

<pre><code>adb shell dpm set-device-owner sdg.example.kiosk_mode/.AdminReceiver
</code></pre>

<p>This gave me the error:</p>

<pre><code>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)
</code></pre>

<p>I followed this <a href="https://stackoverflow.com/questions/36731277/adb-server-is-out-of-date-killing">SO link</a> and the answer of Diego Plascencia Lara helped me to get rid of </p>

<pre><code>adb server is out of date.  killing...
* daemon started successfully *
</code></pre>

<p>But still the following error is occurring after running the <code>adb shell dpm set-device-owner sdg.example.kiosk_mode/.AdminReceiver</code> command:</p>

<pre><code>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)
</code></pre>

<p>Why is this error happening and how can I remove this? I had earlier tried to set different apps as device owner but I think I did not manage to pull them off entirely and there were always some errors while completing the entire procedure of getting the app running on the device.</p>
