Trying to set the device owner, but device owner is already set.解决方法

在测试CTS Verifier 中Device Owner Test 的时候报错:

$ adb shell dpm set-device-owner 'com.android.cts.emptydeviceowner/.EmptyDeviceAdmin'
$ adb shell dpm set-device-owner 'com.android.cts.verifier/com.android.cts.verifier.managedprovisioning.DeviceAdminTestReceiver'

java.lang.IllegalStateException: Trying to set the device owner, but device owner is already set.
	at android.os.Parcel.createException(Parcel.java:1958)
	at android.os.Parcel.readException(Parcel.java:1918)
	at android.os.Parcel.readException(Parcel.java:1868)
	at android.app.admin.IDevicePolicyManager$Stub$Proxy.setDeviceOwner(IDevicePolicyManager.java:5863)
	at com.android.commands.dpm.Dpm.runSetDeviceOwner(Dpm.java:176)
	at com.android.commands.dpm.Dpm.onRun(Dpm.java:106)
	at com.android.internal.os.BaseCommand.run(BaseCommand.java:54)
	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:351)
Caused by: android.os.RemoteException: Remote stack trace:
	at com.android.server.devicepolicy.DevicePolicyManagerService.enforceCanSetDeviceOwnerLocked(DevicePolicyManagerService.java:7881)
	at com.android.server.devicepolicy.DevicePolicyManagerService.setDeviceOwner(DevicePolicyManagerService.java:7187)
	at android.app.admin.IDevicePolicyManager$Stub.onTransact(IDevicePolicyManager.java:1095)
	at android.os.Binder.execTransact(Binder.java:756)


解决方法:移除admin

$ adb shell dpm remove-active-admin  'com.android.cts.emptydeviceowner/.EmptyDeviceAdmin'
$ adb shell dpm remove-active-admin  'com.android.cts.verifier/com.android.cts.verifier.managedprovisioning.DeviceAdminTestReceiver'

推荐一个脚本:
runDevice.sh

#!/bin/sh
echo "use it  by : runDevice.sh -s series_number &  runDevice.sh"
adb_options=" "
if [ "$1" = "-s" ]; then
  adb_options=""$1" "$2""
fi
#adb $adb_options shell dpm remove-active-admin 'com.android.cts.verifier/com.android.cts.verifier.managedprovisioning.DeviceAdminTestReceiver'
#adb $adb_options shell dpm set-device-owner 'com.android.cts.verifier/com.android.cts.verifier.managedprovisioning.DeviceAdminTestReceiver'
#adb $adb_options shell dpm remove-active-admin  'com.android.cts.emptydeviceowner/.EmptyDeviceAdmin'
adb $adb_options shell dpm set-device-owner  'com.android.cts.emptydeviceowner/.EmptyDeviceAdmin'
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值