简体   繁体   English

不允许设置设备所有者,因为设备上已有多个用户

[英]Not allowed to set the device owner because there are already several users on the device

I was following this tutorial to set the app as device owner.我正在按照本教程将应用程序设置为设备所有者。 In that tutorial, there is a section 'Using adb to set the device owner'.在该教程中,有一节“使用 adb 设置设备所有者”。 The tutorial here says that after installing the Kiosk Mode Demo App, run the following command:这里的教程说安装 Kiosk Mode Demo App 后,运行以下命令:

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

This gave me the 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 the answer of Diego Plascencia Lara helped me to get rid of我遵循了这个SO 链接,Diego Plascencia Lara 的回答帮助我摆脱了

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

But still the following error is occurring after running the adb shell dpm set-device-owner sdg.example.kiosk_mode/.AdminReceiver command:但是在运行adb shell dpm set-device-owner sdg.example.kiosk_mode/.AdminReceiver命令后仍然出现以下错误:

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 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.我早些时候曾尝试将不同的应用程序设置为设备所有者,但我认为我没有设法完全取消它们,并且在完成使应用程序在设备上运行的整个过程时总是出现一些错误。

There is a way out of this problem without Factory-resetting the device.无需将设备恢复出厂设置即可解决此问题。 Just remove all the accounts from your device (In Settings->Accounts).只需从您的设备中删除所有帐户(在“设置”->“帐户”中)。 You may want to sync the data before doing this so that later, you can restore them.您可能希望在执行此操作之前同步数据,以便以后可以恢复它们。 After removing all the accounts, connect your phone to the 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.认为自己成功了。 Now you can add back all the accounts that you removed earlier.现在,您可以重新添加之前删除的所有帐户。

Another way : As pointed out by Steve Miskovetz in the answer, factory reset is one of the ways to set the app as device owner if previously, your phone had accounts (eg Gmail accounts).另一种方式:正如 Steve Miskovetz 在回答中指出的那样,如果之前您的手机有帐户(例如 Gmail 帐户),则恢复出厂设置是将应用程序设置为设备所有者的方法之一。 But in recent versions of Android and/or some phones,after doing a factory reset, they do not allow to move forward unless you have set a google account.但是在最新版本的 Android 和/或某些手机中,在恢复出厂设置后,除非您设置了 google 帐户,否则它们不允许继续前进。 So, in order to solve this, go ahead and register your google account and when your phone is back to normal operable state, delete that account by going in Settings -> Accounts.因此,为了解决此问题,请继续注册您的 Google 帐户,当您的手机恢复正常可操作状态时,请通过进入设置 -> 帐户删除该帐户。 Now all you need is to enable developer mode and then USB debugging .现在您只需要启用开发人员模式,然后启用 USB 调试 After that connect your phone to the computer and run the command adb shell dpm set-device-owner sdg.example.kiosk_mode/.AdminReceiver .之后将您的手机连接到计算机并运行命令adb shell dpm set-device-owner sdg.example.kiosk_mode/.AdminReceiver

This post gives a really good overview on the dpm command: http://florent-dupont.blogspot.fr/2015/01/android-shell-command-dpm-device-policy.html这篇文章很好地概述了 dpm 命令: http : //florent-dupont.blogspot.fr/2015/01/android-shell-command-dpm-device-policy.html

Near the end of the post, this update was added: " Device owner can only be set on an unprovisioned device, unless it was initiated by “adb”, in which case we allow it if no account is associated with the device” says the source code. So, make sure you don't have any account (like Gmail) associated to your current user set before using the dpm command "在帖子的末尾,添加了此更新:“设备所有者只能在未配置的设备上设置,除非它是由“adb”启动的,在这种情况下,如果没有与设备关联的帐户,我们将允许它”说源代码。因此,在使用 dpm 命令之前,请确保您没有与当前用户集关联的任何帐户(如 Gmail)

I recommend installing and setting your app as a device owner using dpm after performing a factory reset, going through Google Wizard without setting up any accounts, enable developer mode from settings, and finally enable "USB debugging"... If that's a viable option for you...我建议执行恢复出厂设置使用 dpm 将您的应用安装和设置为设备所有者,在不设置任何帐户的情况下通过 Google 向导,从设置中启用开发人员模式,最后启用“USB 调试”......如果这是一个可行的选择为你...

I had the same problem with emulator.我在模拟器上遇到了同样的问题。 Then from Android studio's AVD manager, I right clicked on the device-> wipe data.然后从 Android Studio 的 AVD 管理器中,我右键单击设备-> 擦除数据。

I know this is a post from 4 years ago but I was having the same problem and I didn't want to do a factory data reset so I clicked on that and then you will get a confirmation screen showing everything that you have installed and the accounts that are still logged in, even though they don't show up under accounts & backup.我知道这是 4 年前的帖子,但我遇到了同样的问题,我不想重置出厂数据,所以我点击了它,然后您将看到一个确认屏幕,显示您已安装的所有内容以及仍然登录的帐户,即使它们没有显示在帐户和备份下。

You can then proceed to erease those apps and you're set!然后,您可以继续清除这些应用程序,然后就可以了!

*In my case the apps still logged in were reddit and zoho invoice *就我而言,仍然登录的应用程序是 reddit 和 zoho invoice

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM