Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to Set Device Policy Android Phone

Tags:

android

I am encountering an error setting the device owner on an android device using the steps below. This has worked in the past on other devices:

  1. Perform Factory reset
  2. Enable debug mode on device
  3. From command line run the following on the connected device:

    adb install -r myapp.apk
    adb shell "dpm set-device-owner com.mydomain.myapp/.ServiceDeviceAdminReceiver"
    

The following error occurs:

java.lang.IllegalStateException: Not allowed to set the device owner because there are already some accounts on the device

Under Settings > Accounts (there are no accounts listed)

Under Settings > Security > Device Administrators (there are 2 apps and both are unchecked): Android Device Manager

Myapp

I then ran the following commands and received the following output:

adb shell pm list users
Users:
    UserInfo{0:Owner:13} running


adb shell dumpsys device_policy
Current Device Policy Manager state:
    Enabled Device Admins (User 0):

    mPasswordOwner=-1

Any suggestions on what I can do to set the device owner?

like image 243
ronelle Avatar asked Mar 01 '18 21:03

ronelle


People also ask

How do I enable Device Policy?

Open the Settings app and tap Accounts. Add the work account again and set up Android Device Policy. During enrollment, you must set up a work profile because it's required for Android Device Policy.

How do I add a device to my Android Device Policy?

DPC identifier methodFollow the setup wizard on a new or factory-reset device. Enter Wi-Fi login details to connect the device to the internet. When prompted to sign in, enter afw#setup, which downloads Android Device Policy. Scan a QR code or manually enter an enrollment token to provision the device.

Can't set up device can't use the admin app?

To avoid this issue, make sure your WiFi connection signal is strong in the place where you setup devices. Note: if you see this error message, do not click Reset, but reboot the device. If you aren't able to enter the QR code scanner after reboot by tapping the welcome screen 6 times, reboot the device again.


1 Answers

You need to remove all accounts from the device too, that means no sign in of any sort, even google, skip that step after factory reset

like image 75
Bhavya Shah Avatar answered Oct 16 '22 19:10

Bhavya Shah