How to Remove Set-Device-Owner in Android Dpm

Disable a device owner app from android terminal

You can use DevicePolicyManager.clearDeviceOwnerApp() from your device owner app.

However note that this method has been deprecated in Android Oreo, you can still use it on Oreo devices but it might be removed in future Android versions.

adb dpm set-device-owner not working when installed outside of android studio

We have finally arrived at the cause of this issue. When running an app from android studio, it gets the testOnly flag set to true, doing so allows for certain things to be allowed that normally would not pass. So up until testing from outside of android studio, we just had no idea there was a problem.

This issue: The SIM card adds an account under com.android.sim package that does not show itself in the accounts settings. So to us the phone appeared to have no accounts because this was hidden.

After removing the SIM card, we were finally able to set device owner.

Thank you to everyone who gave suggestions.

Not allowed to set the device owner because there are already several users 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.

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.



Related Topics



Leave a reply



Submit