You can use the dpm command line tool from adb shell.
Application:
usage: dpm [subcommand] [options] usage: dpm set-device-owner <COMPONENT> usage: dpm set-profile-owner <COMPONENT> <USER_ID> dpm set-device-owner: Sets the given component as active admin, and its package as device owner. dpm set-profile-owner: Sets the given component as active admin and profile owner for an existing user.
For more information check: dpm shell command
Note. Before using this command, make sure that the device is not provided. If the device is prepared and you get a message like "The device is already prepared", try to run the command after deleting all accounts from the device or try after factory reset the device.
source share