21

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

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

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:

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.

4

5 回答 5

30

无需恢复出厂设置即可解决此问题。只需从您的设备中删除所有帐户(在“设置”->“帐户”中)。您可能希望在执行此操作之前同步数据,以便稍后恢复它们。删除所有帐户后,将手机连接到计算机并运行命令:

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

如果您收到这样的消息:

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}

认为自己是成功的。现在您可以重新添加之前删除的所有帐户。

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

于 2017-05-26T05:26:38.443 回答
4

这篇文章对 dpm 命令进行了很好的概述:http: //florent-dupont.blogspot.fr/2015/01/android-shell-command-dpm-device-policy.html

在帖子接近尾声时,添加了此更新:“设备所有者只能在未配置的设备上设置,除非它是由“adb”启动的,在这种情况下,如果没有帐户与设备关联,我们将允许它”说源代码。因此,在使用 dpm 命令之前,请确保您没有与当前用户集关联的任何帐户(如 Gmail)

我建议在执行出厂重置后使用 dpm 将您的应用安装和设置为设备所有者,在不设置任何帐户的情况下通过 Google 向导,从设置中启用开发人员模式,最后启用“USB 调试”......如果这是一个可行的选项为你...

于 2017-05-24T17:11:29.100 回答
0

请按照以下说明解决问题:

  1. 删除设置->帐户中的所有帐户
  2. 使用命令:(adb shell dumpsys account它会列出所有的账户,但不列出之前的,卸载所有的应用程序)
  3. 再试一次
于 2021-10-09T06:04:00.610 回答
0

我对模拟器有同样的问题。然后从 Android Studio 的 AVD 管理器中,我右键单击设备-> 擦除数据。

于 2019-12-06T13:35:29.487 回答
0

我知道这是 4 年前的帖子,但我遇到了同样的问题,我不想重置出厂数据,所以我点击了它,然后您将看到一个确认屏幕,显示您已安装的所有内容以及仍然登录的帐户,即使它们没有显示在帐户和备份下。

然后,您可以继续擦除这些应用程序,您就可以设置了!

*在我的情况下,仍然登录的应用是 reddit 和 zoho invoice

于 2021-01-03T20:12:04.053 回答