0

I am trying to make an application device-admin, for that I'm following Developing a Device Administration Application
And when I try to run below command
./adb shell dpm set-device-owner com.example.app/.receiver.AdminReceiver

it gives SecurityException

java.lang.SecurityException: Neither user 2000 nor current process has android.permission.MANAGE_DEVICE_ADMINS.
    at android.os.Parcel.readException(Parcel.java:1683)
    at android.os.Parcel.readException(Parcel.java:1636)
    at android.app.admin.IDevicePolicyManager$Stub$Proxy.setActiveAdmin(IDevicePolicyManager.java:4278)
    at com.android.commands.dpm.Dpm.runSetDeviceOwner(Dpm.java:145)
    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:343)

Can anybody please help to get out of this problem, I have removed all the accounts from mobile. I'm using redmi note 4 mobile

umesh
  • 1,148
  • 1
  • 12
  • 25

1 Answers1

0

Having active accounts would result in different error, so it's not the case.

Please try to type in full path to receiver's package, e.g. com.example.app/com.example.app.receiver.AdminReceiver

  • thanks for the suggestion, I tried that but no luck, I came to know one more finding that on Android Lollipop & Marshmallow phone it works, but on Nougat doesn't – umesh Feb 09 '18 at 19:32