72

I am trying to create some apps on my xiaomi smartphone (MIUI 8), but when I try to run an app, the error INSTALLATION_CANCELED_BY_USER appears. I found that the problem is that I must enable the "Install via USB" option from developer settings. When I try to do so, I get a screen that says I have to login/signup with an MI account in order to enable this option, which is something I am not willing to do. So, I have 3 questions:

  • Why did they make it neccessary to provide an account for enabling an option like this?
  • Is there any way I can bypass the MI login screen and enable the option?
  • The reason I don't want to connect my phone to an MI account is that I am concerned about personal data being uploaded. Is it a logical concern?
2
  • 4
    Instead of adb install app.apk use adb push app.apk /sdcard/ and then tap the apk from a file manager on the device to follow the usual side-loading install. Of course, Unknown sources must be enabled in settings. Not a solution per se, but a cheap workaround.
    – ccpizza
    Apr 8, 2018 at 13:56
  • Possibly related on Stack Overflow: Install app via USB: The device is temporarily restricted
    – Andrew T.
    Nov 12 at 14:17

8 Answers 8

19

What I didn't want was to continue having an MI account connected to my device. So I just created a temporary account, enabled the "Install via USB" option and then logged out from the MI account. So, now I hope the option stays enabled :)

2
  • 30
    Just want to add that in my attempt to enable Install via USB MIUI v9 asked me to insert SIM card.
    – gavenkoa
    Jan 6, 2018 at 22:43
  • 15
    @ADNow Xiaomi seems to be going further than most other phone manufacturers, though. My Mi Mix 3 is the first phone I've owned requiring me to sign into the company's service to enable usb app-installation, as well as the first requiring a SIM card to be inserted. They must specifically have added those requirements, and I don't see a legitimate reason why.
    – Venryx
    Jul 29, 2019 at 7:43
17

For those who have already inserted their SIM card into the Xiaomi phone, the other answers would work. But, if you are using Xiaomi Redmi 5 only for development purposes, you will need to do as below:

You will need to sign up/sign in for a Mi account before you continue.

  1. Extract the SIM card from your non-Redmi phone. (It should be nano SIM. Contact your telecom provider to get one if you have a micro or normal SIM).

  2. Insert the SIM card into the Redmi phone.

  3. Go to Settings -> Additional Settings -> Developer options.

  4. Under Debugging, click on the 'Install via USB' option.

    The phone will enable this.

  5. Remove the SIM card.

  6. That's it. You should now be able to install your apps via USB from Android Studio.

Please remember not to disable this option, otherwise, you may need to re-insert your SIM card.

PLEASE NOTE: The above steps are guaranteed to work on Xiaomi Redmi 5 phones.


Also works on (based on the commenters' feedback): Redmi 6, Redmi 6A, Redmi 8, Mi 9 Lite, Redmi Note 9.

0
15

These steps worked for me for Redmi 8 Pro. Follow them in the exact same order.

  1. Enable Developer Options.
  2. Settings -> Additional Settings -> Developer Options -> Disable MIUI Optimizations
  3. Reboot Phone
  4. Settings -> Additional Settings -> Developer Options -> Allow USB Debugging
  5. Security (system app) -> Manage apps -> Permissions -> Gear icon (in top right) -> Install via USB (true)
  6. Reboot Phone
  7. Settings -> Additional Settings -> Developer Options -> Enable Install via USB

It will ask for MIUI account. Don't close it and reboot from there. From next run onwards you can install apps either using adb install or via Android Studio.


Also works on (based on the commenters' feedback): Redmi 8 Pro, Redmi Note 5 Pro, Redmi Note 10, Mi 10T Pro,

4
  • Didn't work for me on Redmi S2. I rebooted after 7th step and Install via USB option is still unchecked. And adb install filename still results in the same error, [INSTALL_FAILED_USER_RESTRICTED: Install canceled by user]. Sep 7, 2020 at 18:18
  • 2
    Thank you, worked for my Redmi Note 10 Pro as well. Even though "Install via USB" is still unchecked after completing the steps, I could install an app via Android Studio.
    – guglhupf
    Sep 29, 2021 at 12:20
  • 1
    On a Redmi 9, in order to have "Disable MIUI Optimizations" switch, I had to click multiple times on "Restore default values" in developer menu.
    – Grubshka
    May 12, 2022 at 10:21
  • On Xiaomi Mi Pad 6 (Tablet) Android 13, MIUI 14.0.2: Already signed with Xiaomi account, still can't install apps through ADB. 1: I can't find "Disable MIUI Optimizations" under Developers Options, 2: Permissions -> Gear icon (in top right) is missing; There's "Install via USB" entry but there's nothing to enable/disable there, 3: USB Debugging and Enable install via USB are enabled. If anyone got a working solutions, please message me. Thanks. Jun 27, 2023
    – Jags
    Jun 27 at 13:47
13

None of the other solutions floating around the internet worked for me (Chinese VPN, Disabling MIUI optimization...). I also could not temporarily sign into a Mi account, since I'd uninstalled as many MIUI system apps as I could and thus sign-in wasn't working anymore (and I just didn't want to sign in to begin with).

YMMV - it worked for me when I did it in early 2019, but it may not work any more if they changed something. I changed to custom ROM and can't test it anymore.

If you want to change it back, just re-run the commands with a 0 at the end and remove what you added to the text files.


This requires root, shell access with su, and a way to edit text files as root. I used Termux and and an android root file manager that can edit text files.

First, run the following command (su first, to switch to root):

setprop persist.security.adbinstall 1

If you also want to enable "USB debugging (Security settings)", for granting permissions, simulating UI input, etc. via ADB, run the following command too:

setprop persist.security.adbinput 1

Next, we need to edit the file

/data/data/com.miui.securitycenter/shared_prefs/remote_provider_preferences.xml

so that MIUI actually lets us do these things:

Add the following line to the XML file (with all the other ones, before the closing tag, or change it to true if the line is already there):

<boolean name="security_adb_install_enable" value="true" />

Or, if the line is already there, you can can use sed to change it from false to true:

sed -i 's,"perm_adb_install_notify" value="true","perm_adb_install_notify" value="false",' /data/data/com.miui.securitycenter/shared_prefs/remote_provider_preferences.xml

No reboot necessary. MIUI annoyingness circumvented :-)

8
  • 1
    I get Security Center crashed message, when trying to install apk after these actions. Feb 15, 2019 at 14:32
  • @ArtemMostyaev Hmm, maybe this doesn't work for everyone then.. If you can upload a logcat somewhere, I could have a look at it and see if I can figure out why it's crashing. Feb 15, 2019 at 16:39
  • Here is the logcat pastebin.com/XAjmqAWq I also deteted miaccount app, maybe I touched something else too.. Feb 18, 2019 at 13:16
  • @ArtemMostyaev It looks like the system can't start the part of the "security center" app that handles this. Did you uninstall the "security center" app, or one of the other "security" apps / components ? Or perhaps you uninstalled some other system app that I didn't, hence it works for me. Feb 18, 2019 at 14:56
  • Yes, now I remember. I uninstalled some 'security' app in hope to get rid of that, but the 'security center' still presents on the phone. Looks like ROM reinstall is the only choice for me. Feb 19, 2019 at 7:26
6

"Install via USB" wont work if your Xiaomi phone is running MIUI 8 or above. Looks like when you try to Enable this option, your phone trys to connect to some chinese server and fails.

I got a work around and it worked for me. Idea is to connect to Chinese-Shanghai server through VPN. Try the following:

  1. Install PlexVPN from Playstore and login into it. You will a 24 hr free VPN service.
  2. Select China-Shanghai server and connect.
  3. From developer option in your Xiaomi phone, Enable "Install via USB".

You can then disconnect the VPN and logout from PlexVPN.

Enjoy!!

1
  • I tried this, it still ask me to sign into MI account. Dec 20, 2018 at 12:40
5

First question: I think it's a bug

Second: The are some workarounds (suggested in Mi forums)

Try the following steps to bypass mi account requirement for USB installation:

  1. Settings > Additional Settings > Privacy: Check the Unknown Sources option.

  2. Settings > Additional Settings > Developer Options > Turn On USB Debugging

  3. Settings > Additional Settings > Developer Options > install Via USB

  4. Settings > Additional Settings > Developer Options > Turn off MIUI Optimization.

  5. Restart your Mobile.

Third: Yes is completely logical and justified to protect your privacy, you never know the 'intruders'

Acknowledgements

  1. Install Via USB not working - The device is temporarily restricted
  2. Android Install on Device Failure [INSTALL_CANCELED_BY_USER]
3
  • 3
    Thank you for your answer, but my main problem (bypassing MI sign in) wasn't solved. When I try to check the install via USB I still get the sign in page. I checked the links you provided but I did'n manage to enable install via USB. Nov 5, 2017 at 17:31
  • This solved the problem - Was able to enable installation via usb this way without network access or SIM card. Device: Pocophone running MIUI Global 11.0.5. adb install my.apk now works as intended. Nov 30, 2019 at 22:09
  • On a Redmi 9, in order to have "Disable MIUI Optimizations" switch, I had to click multiple times on "Restore default values" in developer menu.
    – Grubshka
    May 12, 2022 at 10:22
1

I managed to enable Install via USB on MIUI 14, device: Redmi K60.

The problem: The option to enable "Install via USB" in Developer mode requires a Xiaomi account.

Solution: Go to Settings -> Apps -> Permissions -> Click the icon settings on the top right corner. Here, you can see the option to enable "Install via USB" without any Xiaomi account request.

This method is similar to the solution other users already posted. However, the steps are a little different because MIUI changed the layout.

2
  • I have a Redmi 10C with MIUI 14 and can follow Settings -> Apps -> Permissions but not Click the icon settings on the top right corner - can you add a screenshot of what it should look like? Aug 2 at 6:09
  • Awesome, this fixed the problem for my Pad 6! :) Oct 3 at 22:04
-1

I had this problem with my Xiaomi Mi 5 in India. I did some RnD over it and finally got its core reason and one solution which is working on all devices.

You would have noticed that to toggle the ‘Install via USB’ option on Mi phones, you need to be connected to the internet and logged in to Mi account. Due to some reason, requests triggering from India are getting rejected by Mi servers. So, I connected my phone to an open VPN in China and made a request again and it got SOLVED.

You can refer to my video for detailed information: https://youtu.be/MeKUJlD-Ke4

1
  • 2
    -1: answers are meant to answer, not to redirect to a third-party resource which may or may not address the question. Please describe the procedure in detail, and keep in mind that links are to be used as mere references.
    – Grimoire
    Dec 18, 2017 at 16:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .