← all articles

Fixing INSTALL_FAILED_USER_RESTRICTED on Xiaomi and Redmi adb installs

You plug in a Redmi, run adb install app.apk or hit Run in Android Studio, and get this:

adb: failed to install app.apk: Failure [INSTALL_FAILED_USER_RESTRICTED: Install canceled by user]

Sometimes the wording ends in “Invalid apk” instead. The phone may flash a dialog for a second, or show nothing at all. USB debugging is on, adb devices says device, and yet nothing installs. This is the exact situation people ask about in this Stack Overflow question, and the short answer is: it is not an adb bug. Xiaomi’s Android skin (MIUI, and HyperOS on newer phones) has a second, separate switch for installing over USB, and it sits behind a verification step that stock Android does not have.

This guide is for anyone who installs apps onto Xiaomi, Redmi or POCO phones from a computer: developers, QA people, and operators with a shelf of test handsets. By the end you will have the toggle enabled, know what the verification step wants, and have a checklist for when the toggle alone does not fix it. Menu names are from MIUI 12 to 14 and HyperOS 1.x, as of October 2026. Xiaomi moves things around, so use the search box in Settings if a label is missing.

what you need

  • a Xiaomi, Redmi or POCO phone running MIUI or HyperOS, with a USB cable that carries data (many charge-only cables pass adb devices never showing the phone)
  • a computer with Android platform-tools installed. Google publishes them on the platform-tools release page, free, no account needed
  • a Mi account you can sign in to on the phone. This is the part people skip, and it is required for the toggle
  • a working SIM card in the phone on many builds, with mobile data or at least a signal
  • wifi or mobile data on the phone during setup, because the toggle checks in with Xiaomi’s servers
  • the APK you want to install, and a note of whether it is yours or one you are authorised to test

Cost: nothing, unless you need a SIM. Carriers change prices, so I will not quote one.

step by step

1. confirm adb sees the phone

Start by proving the problem is the install and not the connection.

adb kill-server
adb start-server
adb devices

Expected output:

List of devices attached
R5CT1234ABC     device

If it says unauthorized, look at the phone for the RSA fingerprint prompt and tick “always allow”. If the list is empty, it is a cable, driver or USB mode problem, not this error.

If it breaks: if the USB debugging switch itself is greyed out or flips back off, stop here and read fixing a greyed-out USB debugging toggle on Android first. Xiaomi restrictions overlap with that one.

2. reproduce the error and read the exact message

Run the install with replace so you have a baseline:

adb install -r app.apk

Note the full failure line. INSTALL_FAILED_USER_RESTRICTED means the system refused on policy grounds, not because the APK is broken. A corrupt file gives INSTALL_FAILED_INVALID_APK or a parse error instead. People waste an hour re-downloading APKs that were never the problem.

If it breaks: if you get INSTALL_FAILED_UPDATE_INCOMPATIBLE or INSTALL_FAILED_VERSION_DOWNGRADE, that is a different error with a different fix. The downgrade case is covered in downgrading an installed Android app with adb install -d.

3. turn on developer options

If you have not already: Settings, About phone, then tap “MIUI version” (or “OS version” on HyperOS) seven times. You will see a toast saying you are now a developer. Google documents the general process in Configure on-device developer options, and Xiaomi follows it, except the tap target is the MIUI or HyperOS version line rather than the Android build number.

Then go to Settings, Additional settings, Developer options. On HyperOS you can also just search “developer” at the top of Settings.

If it breaks: if tapping does nothing, you may be tapping “Android version”. Tap the MIUI or HyperOS line.

4. enable USB debugging and Install via USB

Inside Developer options, scroll down to the USB section. You want three switches:

  • USB debugging: on
  • Install via USB: on
  • USB debugging (Security settings): on, where present. This one allows granting permissions and simulating input over USB, and is useful for UI automation later

“Install via USB” is the answer to the Stack Overflow question. On stock Android, USB debugging alone lets adb install. On MIUI and HyperOS, the package installer applies its own policy to installs that arrive over USB, and this switch controls it. With it off, adb’s install is refused at the policy layer and you see INSTALL_FAILED_USER_RESTRICTED.

If it breaks: if you cannot tap Install via USB, or it snaps back to off, go to step 5.

5. pass the verification step

This is the step that stops silent installs. When you try to turn on Install via USB (and sometimes Security settings debugging), the phone does not just flip the switch. It shows a dialog asking you to sign in to a Mi account, and on many builds it also wants a SIM card inserted. The exact wording varies by ROM version and region, so treat mine as a description and not a quote.

The practical checklist:

  • sign in to a Mi account: Settings, then the account banner at the top. Create one at account.xiaomi.com if you do not have one
  • insert a SIM with a signal: a SIM with no credit is often enough for the check, but I cannot promise that for every region or build
  • keep data or wifi on while you flip the switch
  • toggle Install via USB again and accept the warning dialog

Once it succeeds, the switch stays on. You usually only do this once per phone, though a factory reset or a long period offline can make it ask again.

If it breaks: no SIM to hand, or a Mi account that will not sign in? Try wifi only first. Some China-ROM phones insist on a SIM, and global ROMs are often more relaxed. I have not found a reliable way around the check, and I am not going to suggest tricks to bypass it. It exists as a Xiaomi security control.

6. retry the install and watch the phone screen

With the switch on, run the install again and keep the phone unlocked and in your hand:

adb install -r app.apk

On some Xiaomi builds a confirmation dialog appears on the phone (“Install via USB: allow this app?”). Tap Install. If you wait too long, the dialog times out and adb reports the same user-restricted or “canceled by user” failure, which looks identical to the original problem and fools people.

Expected output:

Performing Streamed Install
Success

If it breaks: if the failure returns instantly with no dialog, go back and confirm Install via USB is actually on. Some builds silently reset it after a reboot. If a dialog appears and you tap Install but it still fails, continue to step 7.

7. check the user and profile you are installing into

MIUI and HyperOS have “Second space” and a dual apps feature. If the active user is not user 0, installs can be restricted. Check:

adb shell pm list users

Expected output on a normal phone:

Users:
    UserInfo{0:Owner:c13} running

If you see more than one user, or the current one is not 0, install explicitly into the main user:

adb install -r --user 0 app.apk

If it breaks: if Second space is on and you do not need it, turn it off in Settings and retry. If a work profile is managed by an organisation’s device policy, the restriction may be deliberate. Ask whoever manages the device, and do not try to work around it.

8. try the optional Play Protect and verifier checks

Two more settings can produce a prompt that looks like a failure. Google Play Protect may show a scan dialog on the phone for adb installs, and Android has a package verifier setting for adb installs. You can read it with:

adb shell settings get global verifier_verify_adb_installs

On a development phone that you own, setting it to 0 skips the scan for adb installs:

adb shell settings put global verifier_verify_adb_installs 0

This does not bypass the Xiaomi toggle, and I only do it on handsets dedicated to testing, not on my daily phone.

If it breaks: if settings put is refused, your build blocks it. Leave it alone. The Play Protect prompt can simply be dismissed on the phone.

9. make it repeatable

Once you have one good install, script it so the next phone takes a minute. Android Studio and Gradle use the same path, so this helps them too. Google’s adb documentation lists every flag, including -g to grant runtime permissions at install time.

adb -s R5CT1234ABC install -r -g app.apk
adb -s R5CT1234ABC shell monkey -p com.example.app -c android.intent.category.LAUNCHER 1

The second line launches the app so you know it really installed.

If it breaks: if Android Studio still fails while the command line works, check that Studio is pointed at the same platform-tools version. Running adb version in a terminal and comparing it to the SDK Manager entry catches this.

common pitfalls

  • flipping only USB debugging: on Xiaomi, USB debugging and Install via USB are separate switches, and you need both
  • not noticing the phone dialog: adb reports a timeout as “canceled by user”, so be fast on the screen the first time
  • skipping the Mi account: the toggle will not stay on without sign-in on most builds
  • a charge-only cable or a hub: the phone shows up intermittently and installs fail halfway. Use a short data cable direct to the computer
  • forgetting Second space: if someone on the team turned it on, user 0 is not active and installs are restricted for reasons that look unrelated

scaling this

At 10 phones you can do this by hand. Budget about five minutes per phone for the first setup, and keep a written list of which ones already have Install via USB enabled. Buy one good multi-port powered USB hub with real data lines, label the cables, and use adb -s <serial> everywhere so you do not install to the wrong device.

At 100 phones the manual toggle becomes the bottleneck. Every phone needs a Mi account, and Xiaomi ties the account to the device, so think about account ownership before you buy: a shared account for test handsets is easier to manage than personal ones, but check Xiaomi’s terms for your region and use only accounts you are allowed to use. A pre-provisioned phone that has already passed verification is worth more than a fresh box. Read best open source Android device farm tools before you build your own rack, because something like STF or a similar tool will handle device inventory for you.

At 1000 phones you are running a device farm, and Xiaomi’s per-device verification will not scale by hand. Most teams at that size either standardise on handsets that have no such gate, or provision at a depot once and never reset the phones. If your need is a real Android handset in Singapore rather than a shelf of hardware, cloudf.one rents real Android phones in Singapore on dedicated hardware, each with a persistent Singapore mobile IP, controlled from the browser. To be clear on the adb side: cloudf.one has no self-service adb. adb and Appium reach a rented phone only through a WireGuard tunnel that we set up on request, by emailing [email protected]. It is Singapore only, and it will not replace a Xiaomi-specific test matrix if you need exact MIUI behaviour on a particular model.

Whatever the size, only automate apps and devices you own or are authorised to test.

where to go next

Written by Xavier Fok

disclosure: this article may contain affiliate links. if you buy through them we may earn a commission at no extra cost to you. verdicts are independent of payouts. last reviewed by Xavier Fok on 2026-10-01.

free download
The adb and scrcpy command cheat sheet

The commands we reach for on a rack of real phones, on one printable page. Leave your email and we will also tell you when we publish a new guide, a few times a month at most.

from the team behind cloudf.one
Passes on the emulator, fails on a real phone?

cloudf.one rents real Android phones in Singapore that you control from the browser, each on a persistent Singapore mobile IP. Real hardware, a real OEM build and a real carrier network, without buying and racking the phones yourself.

test on a real phone →
read on
More from ADB Handbook

adb commands, scrcpy flags, automation frameworks, and why a test passes on one phone and fails on the next.

browse all articles →