53

I'm using Android Studio to connect to run app in my Xiaomi Redmi Note 3G device. My device is already found in the Choose Device Dialog, but I keep getting the [INSTALL_CANCELED_BY_USER] error :

Waiting for device.
Target device: xiaomi-hm_note_1w-SSE6Y97PFYQCRK45
Uploading file 
local path: C:\Users\Anthony\AndroidStudioProjects\UASProject\app\build\outputs\apk\app-debug.apk
remote path: /data/local/tmp/com.si.UASPROJECT
Installing com.si.UASPROJECT
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.si.UASPROJECT"   
pkg: /data/local/tmp/com.si.UASPROJECT   
Failure [INSTALL_CANCELED_BY_USER]

I tried looking for solutions online, but there's no mention of Failure [INSTALL_CANCELED_BY_USER] error.

Alex P.
  • 27,029
  • 16
  • 103
  • 156
Anthony.S
  • 535
  • 1
  • 4
  • 5

19 Answers19

125

Happens to my Xiaomi phone after updated it to MIUI 8. Took me hours to figure it out!

Check the followings if you're a victim too:

  1. Go to Settings -> Permissions -> Install via USB: Uncheck your App if it's listed.
  2. Go to Settings -> Additional Settings -> Privacy: Check the Unknown Sources option.
  3. Finally go to Settings -> Additional Settings -> Developer options: Check the Install via USB option.

Update (MIUI 8):

Signin in to MI account is required to enable Install via USB option.

Update 2

For some devices (e.g. Redmi) you might need to turn off MIUI Optimization and reboot your phone.

Settings > Additional Settings > Developer Options > MIUI Optimization

P.S. don't update MIUI unless necessary!

May the victims saved

Jiyeh
  • 4,837
  • 1
  • 26
  • 29
  • 7
    Updated to MIUI 8. Now I need to login into MIUI account to enable 'Install Via USB'. – mohitmun Jan 02 '17 at 10:12
  • 1
    One more possible step that may help is to disable the Instant Run feature.Go to "File -> Settings -> Build, Execution, Deployment -> Instant Run" and disable it. – Beeing Jk May 03 '17 at 03:33
  • Added to what you said, I needed to check off "USB debugging (Security settings) Allow granting persmissions and simulating input via USB debugging" in my Redmi Note 4 in order to be able to run instrumented (Espresso) tests. – Javi Vazquez May 15 '17 at 14:48
  • I have signed in to my MI account. Still, it is not working. It is showing: "the device is temporarily restricted" – Samarth Kejriwal Jul 24 '17 at 08:25
  • Facing the same issue with redmi note 4. This solution solved it :) – Shree Aug 02 '17 at 08:04
  • got solution for this? `inset your SIM card` when trying to enable `install via usb` – softmarshmallow Sep 19 '17 at 00:46
  • MIUI 9 - Mi4c: I had to turn off MIUI Optimization, after that I could enable install via usb – Idered Nov 01 '17 at 15:18
  • For all users of MIUI 8 and above, check my solution. Works seamlessly.. Enjoy!! – Vineet Ravi Dec 15 '17 at 10:16
  • This one still works, saves me a lot of hours. Thanks! – jzarsuelo Jun 12 '18 at 04:21
  • There is an app called "SAI" which is supposed to be able to install APK files. When launching it on Xiaomi, it says it will be fixed on MIUI 20.2.20 . I can't find a reference to this claim. Do you guys know about this? – android developer May 22 '20 at 21:43
29

I have same problem before, here is my solution:

Step 1: Go to "Setting" → find "Developer options" in System, and click.

Step 2: TURN ON "Verify apps over USB" in Debbuging section.

Step 3: Try "Run app" in Android Studio again!

Hannah Cheng
  • 429
  • 4
  • 4
  • 8
    It works for me with the opposite setting on step 2. I got this error when "Verify apps over USB" was on and it was fixed when I turned it off. – hsebastian Jun 09 '16 at 06:26
20

Turn off Miui Optimizations on Developer Settings, then Restart the phone.

Taslim Oseni
  • 4,610
  • 10
  • 34
  • 50
Sujeet Kumar
  • 1,562
  • 15
  • 23
10

Step 1 : Turn on Developer Option (Settings > About Phone > Click 7 Times On "MIUI Version").

Step 2 : Connect Your Device via USB to PC

step 3 : Settings > Additional Settings > Developer Options > Turn On USB Debugging.

Step 4 : Also You Should turn On Settings > Additional Settings > Developer Options > install Via USB

Enjoy Coding ... :-)

Sai Gopi Me
  • 9,800
  • 1
  • 65
  • 43
7

In my case I turn on "Install via USB" and also make sure "USB Debugging" is on.

Win Min Tun
  • 71
  • 1
  • 4
6

if you are at MIUI 8.

Follow the steps

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

Step 2: Settings > Additional Settings > Developer Options > Turn On USB Debugging

Step 3: Settings > Additional Settings > Developer Options > install Via USB

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

Step 5: Restart your Mobile.

Vinesh Goyal
  • 533
  • 3
  • 8
4

I had an error of Session 'app': Error Installing APKs in Redmi 3S 6.0.1 MIUI Global 8.2. After turning OFF Instant Run in Android Studio, the error did not occur again. For this, Go to File Menu->Settings->Build, Execution, Deployment->Instant Run->Check OFF Enable Instant Run.

But I wanted to use Instant Run features, so, Go to Settings-> Additional settings->Developer options->Turn off MIUI optimization. Restart phone.

Both of the above methods worked. If the error still occurs, check to Turn on USB debugging and Install via USB.

Stuti Verma
  • 931
  • 11
  • 29
4
  1. Open Security App pre-installed in MIUI
  2. Then click Optimize. Try to achieve 100% score.
  3. Activate developer's option by clicking multiple times on MIUI version. (Everyone knows how to do this)
  4. Then Disable WiFi and switch on install via USB under Developers option while you are connected through Mobile data and under your Xiaomi account.
  • What do you mean by under Xiomi account? – Pratz Jul 28 '17 at 13:57
  • You should be signed in to your Xiaomi Account – Pankaj Rane Jul 28 '17 at 14:48
  • I am already signed into my xiomi account in settings --> accounts --> Mi Account But still can not enable install via USB. Getting same error device temporarily restricted. Tried turning off MIUI optimization but no help. – Pratz Jul 29 '17 at 02:19
  • You should turn mobile data on and off the wifi. that worked for me.. should also worked for you – Pankaj Rane Jul 30 '17 at 19:24
  • Tried same steps you mentioned.. not working for me :( could it be because of MIUI version? I have MIUI 8.5.3.0 and Android 6.0.1 – Pratz Jul 31 '17 at 02:16
  • Can u give me device detail?. cause i also have Redmi note 3 same MIUI and android 6.0.1 . – Pankaj Rane Aug 02 '17 at 06:46
  • And also my MIUI optimization is on. Still it is working – Pankaj Rane Aug 02 '17 at 06:49
  • 1
    Try this: @Pratz 1. Open **Security** App pre-installed in MIUI 2. Then click **Optimize** . Try to achieve 100% score. 3. Activate developer's option by clicking multiple times on MIUI version. _(Everyone knows how to do this)_ 4. Then **Disable WiFi** and switch on install via USB under Developers option while you are connected through Mobile data and under your Xiaomi account. – Pankaj Rane Aug 02 '17 at 06:53
  • @Pratz yes app mostly controls all the security. Don't know if you noticed or not when you optimize your developer option also gets reset and USB debugging is off. – Pankaj Rane Aug 03 '17 at 20:13
  • Yes I saw that. Thanks for the help. Its working now :) – Pratz Aug 04 '17 at 02:52
3

"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!!

Vineet Ravi
  • 1,370
  • 1
  • 11
  • 23
3

IF YOU HAVE TRIED EVERYTHING, TRY THESE STEPS ALSO

Step 0: Turn On MIUI Optimization & Restart.

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

Step 2: Settings > Additional Settings > Developer Options > Turn On USB Debugging

Step 3: Settings > Additional Settings > Developer Options > install Via USB

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

Step 5: Restart your Mobile.

Prashanth
  • 317
  • 3
  • 17
2

Sometimes it happens because the user does not accept the installation in time. You can turn off "Monitor apps installed by USB" to override user confirmation.

2

Go to Settings-> Additional settings->Developer options->Turn off MIUI optimization You must Turn on USB debugging and Install via USB Hope it help

2

Follow the steps

  1. Go to settings -> Additional Settings -> Developer Options(if not found then tap MIUI version in About phone multiple times) -> Turn off MIUI optimization.

  2. GO to settings -> Mi Account -> Sign out(if signed in)-> developer options->turn on Install via USB(sign in page will open) -> Sign in to your mi Account

It should work, if still these steps doesn't work for you then reboot your phone after these two steps

Deepak Kataria
  • 484
  • 3
  • 10
0
  • Go to "Setting" → find "Developer options" in System
  • TURN OFF "Verify apps over USB" in Debbuging section.
Nikunj
  • 2,639
  • 8
  • 25
0

I too faced similar issue after updating of Redmi to 8.5.7 OS but none of them mentioned above are worked. When I am trying to turn on Install via USB in developer options it is restricting.. So I did like following

Simply I did:

  1. Logout from Redmi account
  2. Relogin again
  3. Turn on Install via USB in developer options

Update: if you still unable to tun on just switch off Wi-Fi and turn on mobile data and try to switch it on.

This solved my issue.

Shailendra Madda
  • 16,925
  • 14
  • 71
  • 115
0

in miui 9 u must have access to the INTERNET to make it work

Step 1 : Turn on Developer Option (Settings > About Phone > Click 7 Times On "MIUI Version").

Step 2 : Connect Your Device via USB to PC

step 3 : Settings > Additional Settings > Developer Options > Turn On USB Debugging.

Step 4 : Also You Should turn On Settings > Additional Settings > Developer Options > install Via USB

0

for check, sometime just need go to:

  • Settings
  • Permissions
  • Install via USB (turn off your app if exist) It was my case. Thanks @Jiyeh
nicolas asinovich
  • 2,120
  • 1
  • 19
  • 31
0

You have to in able the install via USB mode, to do that

1.go to Settings=>Aditional setting=>Developer Options=>Install via USB tuggle it on, If you are having trouble tuggeling the option on,

2.You will have to insert a sim in and use a chineese VPN; You can use a vpn of following setting: tpye: L2TP/IPSec PSK server address: vpn959922015.opengw.net IPSec pre-sared key: vpn username: vpn password: vpn

3.And remember to turn on OEM unlocking in the developer options and then appempt to turn on Install via USB;

0

All the above instructions should work but if you're using MI Redmi Note 5A or later versions, you'll see that toggling "install via USB" toggles back off.

That's because the new versions somehow requires you to be in China. To fix this, download Windscribe VPN from playstore(it's free to use). Off your wifi and on mobile data. Connect to HongKong.

Go back and toggle "Install via USB". It'll work now. Disconnect the VPN.