使我的应用成为设备所有者不起作用

时间:2019-10-21 15:22:49

标签: android adb device-owner samsung-knox

我需要静默更新我的应用程序(如here所述)。

因此,我需要使我的应用成为手机SAMSUNG S6的设备所有者。我通过adb shell命令使用dpm命令,因此我配置了我的设备(从“设置”->“帐户”中删除所有帐户),启用开发人员模式,启用调试,像往常一样安装我的应用程序(例如,与Android Studio一起安装),然后运行命令:

adb shell dpm set-device-owner <PACKAGE-NAME>/.DeviceAdminComponent

但是我遇到下一个错误:

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:1701)
        at android.os.Parcel.readException(Parcel.java:1646)
        at android.app.admin.IDevicePolicyManager$Stub$Proxy.setDeviceOwner(IDevicePolicyManager.java:6123)
        at com.android.commands.dpm.Dpm.runSetDeviceOwner(Dpm.java:148)
        at com.android.commands.dpm.Dpm.onRun(Dpm.java:96)
        at com.android.internal.os.BaseCommand.run(BaseCommand.java:51)
        at com.android.commands.dpm.Dpm.main(Dpm.java:41)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:301)

这很奇怪。如果我运行以下命令:

adb shell dpm set-profile-owner <PACKAGE-NAME>/.DeviceAdminComponent

对我来说很好。

有人可以帮助我解决这个问题吗?也许是由于三星KNOX发生了? (通过设备管理员-我的Knox策略管理员,我无法禁用它)。

1 个答案:

答案 0 :(得分:0)

要在手机上设置设备拥有者应用,需要恢复出厂设置,然后您可以使用adb命令。