Skip to main content

How to Fix "INSTALL_FAILED_USER_RESTRICTED" via ADB in HyperOS

 Mobile developers deploying to Xiaomi devices frequently encounter a silent pipeline failure. You initiate a build, the compilation succeeds, but the deployment halts with a specific error: Failure [INSTALL_FAILED_USER_RESTRICTED: Install canceled by user].

The device screen remains completely blank. No confirmation popup appears, and no manual cancellation occurred. This silent rejection completely blocks standard Android mobile app development tools, preventing local testing for Flutter, React Native, and native Android applications.

The Root Cause of the Denial

To understand this HyperOS ADB install error, you must look at how Xiaomi modifies the Android Open Source Project (AOSP) framework. HyperOS and MIUI implement a proprietary security layer on top of the standard Android Package Manager (PackageManagerService).

When an IDE or terminal invokes an adb install command, AOSP normally routes this directly to the package manager. HyperOS intercepts this request and attempts to render an overlay UI via a system app called com.miui.securitycenter.

If the specific "Install via USB" flag is not explicitly authenticated and enabled in the device settings, the security center suppresses the overlay. Because the ADB daemon (adbd) is waiting for an asynchronous callback from the UI that never renders, the system enforces a default timeout or crash fallback. It interprets the lack of interaction as a user cancellation, returning the false [1.9] denial code back to your IDE.

The Complete Solution

Fixing this requires satisfying HyperOS's strict telemetry and authentication prerequisites before it will unlock the internal package manager for ADB sideloading. You cannot bypass this via standard ADB commands; it must be authenticated on the device.

Step 1: Network and Account Authentication

HyperOS requires server-side validation to enable USB installation. This is the most common point of failure.

  1. Disconnect the device from Wi-Fi.
  2. Ensure a valid SIM card is inserted into the device.
  3. Enable Mobile Data.
  4. Navigate to Settings > Xiaomi Account and sign in. (The system uses the cellular connection to verify the account region and device binding).

Step 2: Configure Developer Options

With the device authenticated via cellular data, you must enable three specific flags in the Developer Options.

  1. Navigate to Settings > Additional Settings > Developer Options.
  2. Enable USB Debugging. Accept the 10-second warning prompt.
  3. Enable Install via USB. The system will authenticate with Xiaomi servers over mobile data. If this fails, verify your SIM has an active data connection.
  4. Enable USB Debugging (Security settings). This is critically important. Without it, the OS will block subsequent permission grants and input simulations required by Flutter and React Native.

Step 3: Verify via ADB Sideload

Once the device settings are configured, verify the fix by bypassing your IDE and running a direct ADB installation. Open your terminal and navigate to your compiled APK directory.

Run the following command, utilizing flags designed for testing environments:

# -r: Replace existing application
# -t: Allow test packages
# -g: Grant all runtime permissions automatically
adb install -r -t -g build/app/outputs/flutter-apk/app-debug.apk

If successful, the console will output Success without requiring interaction on the device screen.

Deep Dive: Why Flutter and React Native Fail Differently

While native Android developers might occasionally see the permission popup, cross-platform frameworks often fail immediately. This discrepancy comes down to how these frameworks manage state and background processes during hot reloads.

When utilizing Flutter Xiaomi USB debugging, the Flutter toolchain requires the ability to inject touch events and restart the Dart VM programmatically. HyperOS views this rapid background activity as a malicious automation attempt.

If USB Debugging (Security settings) is disabled, HyperOS silently drops the connection to adbd during the hot restart phase. This leaves the Flutter daemon waiting for a socket response that will never arrive, resulting in a zombie process on your development machine.

React Native experiences a similar bottleneck. The Metro bundler attempts to establish a reverse TCP proxy via adb reverse tcp:8081 tcp:8081. The HyperOS security center frequently blocks this port mapping if the "Install via USB" prerequisite isn't fully authenticated, leading to white screens upon app launch.

Common Pitfalls and Edge Cases

The "Insert SIM Card" Error

If you are developing on a test device without a cellular plan, you cannot enable "Install via USB" through the UI. As a temporary workaround, you can insert your primary SIM card, toggle the setting on, and then remove the SIM. The permission state generally persists until the device is factory reset or the Xiaomi account is removed.

MIUI Optimization Conflicts

On older devices running MIUI or early builds of HyperOS, a hidden setting called Turn on MIUI Optimization sits at the very bottom of the Developer Options.

If you have followed all previous steps and still receive the INSTALL_FAILED_USER_RESTRICTED error, you must disable this feature.

  1. Go to Developer Options and scroll to the absolute bottom.
  2. If "Turn on MIUI optimization" is missing, tap the "Reset to default values" button repeatedly until the hidden optimization toggle appears.
  3. Disable the toggle. Note that this resets all application permissions across the device and alters the system UI slightly, as it reverts the OS closer to stock AOSP behavior.

Handling Stateful Downgrades

If you are attempting to install an older version of your application over a newer version, HyperOS will block the transaction regardless of USB settings. You must explicitly instruct ADB to allow the downgrade.

# Add the -d flag to permit version code downgrades
adb install -r -t -d -g path/to/your/app.apk

By ensuring your device is properly authenticated with Xiaomi's network and configuring the specific security overrides, you can restore a stable, uninterrupted deployment pipeline for modern application development.