63

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

6 Answers 6

17

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

6
  • 28
    Just want to add that in my attempt to enable Install via USB MIUI v9 asked me to insert SIM card. Why Chinese companies collect such information about developers - I can't imagine ))
    – gavenkoa
    Jan 6, 2018 at 22:43
  • 1
    Same as American or any other companies collect information. Whether it is theft of your personal data or improvement of services is up to you to decide.
    – ADNow
    Jan 28, 2018 at 16:52
  • 12
    @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
  • 3
    stup** xiaomi phone which causing all this problem.never get a xiaomi phone ever again
    – ken
    Dec 20, 2020 at 13:30
  • 5
    it need a Mi account, then need a Sim card in order for me to do my work using the phone I buy with my own money!!! I dont want a Mi account, I dont want to use a Mi account, but I cant, it need to make a Mi account for you to track me in my phone. F*** xiaomi, never buy this F***king phone again. Totally no respect
    – ken
    Dec 20, 2020 at 14:04
15

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 per below:

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

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

6
  • 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:

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

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

Reboot your device. MIUI annoyingness circumvented :-)

6
  • 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.
    – JonasCz
    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.
    – JonasCz
    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
9

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

  1. Enable Developer Options.
  2. Settings -> Additional Settings -> 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.

7
  • 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
  • Same on my Mi 10T Pro. Well, I was thinking about switching to Xiaomi for my personal phone too, not anymore.
    – soger
    Feb 1 at 14:06
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.
    – JonasCz
    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 at 10:22

You must log in to answer this question.

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