不允许设置设备所有者,因为设备上已有多个用户 [英] Not allowed to set the device owner because there are already several users on the device

查看:35
本文介绍了不允许设置设备所有者,因为设备上已有多个用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注这个教程将应用程序设置为设备所有者.在该教程中,有一节使用 adb 设置设备所有者".这里的教程说安装 Kiosk Mode Demo App 后,运行以下命令:

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'. The tutorial here says that after installing the Kiosk Mode Demo App, run the following command:

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

这给了我错误:

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)

我关注了这个SO链接和Diego Plascencia的回答劳拉帮我摆脱了

I followed this SO link and the answer of Diego Plascencia Lara helped me to get rid of

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

但是在运行 adb shell dpm set-device-owner sdg.example.kiosk_mode/.AdminReceiver 命令后仍然出现以下错误:

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

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.

另一种方式:正如 Steve Miskovetz 在回答中指出的那样,如果之前您的手机有帐户(例如 Gmail 帐户),则恢复出厂设置是将应用设置为设备所有者的方法之一.但是在最新版本的 Android 和/或某些手机中,在恢复出厂设置后,除非您设置了 google 帐户,否则它们不允许继续前进.因此,为了解决此问题,请继续注册您的 Google 帐户,当您的手机恢复正常可操作状态时,请通过进入设置 -> 帐户删除该帐户.现在您只需要 启用开发者模式,然后 USB 调试.然后将手机连接到计算机并运行命令adb shell dpm set-device-owner sdg.example.kiosk_mode/.AdminReceiver.

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 (e.g. Gmail accounts). 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. 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. Now all you need is to enable developer mode and then USB debugging. After that connect your phone to the computer and run the command adb shell dpm set-device-owner sdg.example.kiosk_mode/.AdminReceiver.

这篇关于不允许设置设备所有者,因为设备上已有多个用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆