I am having an issue with trying to set the device owner on my android device. If I install the app onto the physical device from within android studio by hitting the play button, I am able to add and remove device owner with adb shell dpm set-device-owner package/.receiver
without any issues. I can do this from within android studio or via cmd.
When I install the app from using the apk and manually installed or using adb outside of android studio, I can no longer set the device owner. I always get the error Not allowed to set the device owner because there are already some accounts on the device
This is what makes no sense, as there are no accounts on the device. I can go back into android studio, install the app over the top of it and run the adb command again and it works just fine without doing anything else.
I am lost here because there error seems incorrect, but I have no idea why installing from the apk outside of android studio is not working.
Edit: Some notes
- I am not testing with an emulator. When I say installing from android studio, I mean installing directly to the phone, not an emulator
- I have the manifest pointing to the xml with properly defined
- The app works fine when installing from android studio and setting device owner, I am getting all the expected permissions
- When I install from the output apk, I am no longer able to set device owner (previous was cleared, even tried on a fresh recovery of the phone. Accounts settings is empty with no accounts listed)