# ADB (/docs/activation/adb)

<Callout title="Requirements" type="warning">
This activation method requires your device to not have multiple users or any accounts registered.

For **Android 12+**, you can avoid removing users/accounts and freezing apps by
following this [XDA guide](https://xdaforums.com/t/how-i-got-device-owner-without-factory-reset.4745834/#post-90768446).
Alternatively, consider the automated [Shizuku Activation Method](/docs/activation/shizuku) (recommended).
</Callout>

## 1. Prepare the device [#prepare]

<Steps>
<Step>
Install {APP_NAME} from your chosen [download source](/docs/installation).
</Step>

<Step>
Install [Android Platform Tools](https://developer.android.com/tools/releases/platform-tools)
on your computer and enable USB debugging on the device.
</Step>

<Step>
Connect by USB, allow the debugging prompt, and run `adb devices` to confirm
the connection.
</Step>

<Step>
Identify the full user you want to manage. Its ID is typically `0` on most
devices. The Profile Owner examples below use `--user 0`. Replace `0` with
the intended full user's ID if it is different. Device Owner enrollment must
follow your device's supported user and provisioning requirements.

```sh
adb shell pm list users
```
</Step>
</Steps>

## 2. Choose the role and installed app [#assign-owner]

Run **one** of the two owner commands in the tab matching your installation.
Choose [Profile Owner (Full User)](/docs/activation#optional-work-profile)
if you also want to use a work profile. Choose Device Owner for a dedicated kiosk.

<Tabs items={["GitHub / F-Droid / IzzyOnDroid","Google Play / Aurora Store","Debug APK"]}>
<Tab value="GitHub / F-Droid / IzzyOnDroid">
Device Owner:

```sh
adb shell dpm set-device-owner --user 0 uk.nktnet.webviewkiosk/.WebviewKioskAdminReceiver
```

Profile Owner:

```sh
adb shell dpm set-profile-owner --user 0 uk.nktnet.webviewkiosk/.WebviewKioskAdminReceiver
```
</Tab>

<Tab value="Google Play / Aurora Store">
Device Owner:

```sh
adb shell dpm set-device-owner --user 0 com.nktnet.webview_kiosk/uk.nktnet.webviewkiosk.WebviewKioskAdminReceiver
```

Profile Owner:

```sh
adb shell dpm set-profile-owner --user 0 com.nktnet.webview_kiosk/uk.nktnet.webviewkiosk.WebviewKioskAdminReceiver
```
</Tab>

<Tab value="Debug APK">
Device Owner:

```sh
adb shell dpm set-device-owner --user 0 uk.nktnet.webviewkiosk.debug/uk.nktnet.webviewkiosk.WebviewKioskAdminReceiver
```

Profile Owner:

```sh
adb shell dpm set-profile-owner --user 0 uk.nktnet.webviewkiosk.debug/uk.nktnet.webviewkiosk.WebviewKioskAdminReceiver
```
</Tab>
</Tabs>

## 3. Check activation [#check-activation]

Open **Settings → Device → Device Policies**. Confirm the expected owner
role, full-user scope, and available policies.

## 4. Troubleshooting [#troubleshooting]

If you encounter activation issues regarding existing accounts, proceed with
the following steps:

<Steps>
<Step>
Remove all
[additional users](https://source.android.com/docs/devices/admin/multi-user)
on your device. You can view existing users using the command:

```sh
adb shell dumpsys user | grep 'UserInfo{.*}'
```

The goal is to only have a single full user:

```
UserInfo{0:null:4c13} serialNo=0 isPrimary=true
```
</Step>

<Step>
Find all
[accounts](https://source.android.com/docs/automotive/users_accounts/accounts)
on your device, e.g. in your device settings or using an application like
[AndroidAccounts](https://github.com/iamr0s/AndroidAccounts). To also detect
accounts in disabled applications, it's recommended that you run the command:

```sh
adb shell dumpsys account list
```

Our goal is to have the following in the output:

```
User UserInfo{0:User:4c13}:
  Accounts: 0

  ...

  Active Sessions: 0
```
</Step>

<Step>
Remove the listed accounts using your device settings. If an account belongs
to a disabled app, temporarily re-enable that app so you can remove its
account.
</Step>

<Step>
If apps keep re-creating accounts, temporarily disable those apps (for
example, using [Hail](https://github.com/aistra0528/Hail/blob/master/README_EN.md)).
Do not disable essential system apps. Run `adb shell dumpsys account list`
again and confirm it reports no accounts. Re-enable any apps you disabled
after activation.
</Step>

<Step>
Attempt to set {APP_NAME} as the device owner or profile owner again.
</Step>
</Steps>

It is also worth taking a look at the
[Dhizuku activation guide](https://github.com/iamr0s/Dhizuku/discussions/19),
which includes other helpful debugging steps when setting up a device owner
application.