68

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?
1
  • 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

7 Answers 7

18

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
  • 29
    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
16

For those who have already inserted their SIM card into the Xiaomi phone, the above answers all 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 SIM card into Redmi phone.

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

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

The phone will enable this.

Remove the SIM card.

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 phone. Please improve this answer if the steps are different for other models of Xiaomi.

5
  • 1
    this works with Redmi 6 too
    – mgear
    Nov 20, 2018 at 11:26
  • This works with Redmi 6A too
    – ARiF
    May 12, 2019 at 7:17
  • This works for me on a Redmi 8 phone. It doesn't have to be a sim card from a non-Redmi phone.
    – Yster
    Dec 6, 2019 at 10:02
  • Also works on Mi 9 Lite!! Apr 30, 2020 at 19:23
  • This works on Redmi Note 9 as well!
    – JangoCG
    Sep 8, 2020 at 14:35
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:

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 :-)

7
  • 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
12

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.

6
  • 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
  • Great. Worked also for my new Redmi 8 Pro (Begonia). Thanks.
    – Juergen
    Apr 26, 2021 at 13:01
  • 1
    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
  • Worked on a Xiaomi 10T Pro
    – aguaviva
    Dec 28, 2021 at 15:35
  • Awesome solution. Worked on Redmi Note 5 Pro. We can install apps via USB, even when Install Via USB remains disabled after all these steps are complete. Thanks
    – Nithin
    Feb 18, 2022 at 12:17
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 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

2
  • 1
    -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
  • Hi, looks like you're affiliated with the linked YouTube channel. While it's okay to refer to your channel, please note that explicit disclosure is required on the post itself. Consider reading How to not be a spammer.
    – Andrew T.
    May 31, 2022 at 11:24

You must log in to answer this question.

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