adb – Android Install on Device Failure [INSTALL_CANCELED_BY_USER]-ThrowExceptions

Exception or error:

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.

How to solve:

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

###

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!

###

Turn off Miui Optimizations on Developer Settings, then Restart the
phone.
it worked for me.
happy coding …

###

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 … 🙂

###

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

###

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.

###

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.

###

  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.

###

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.

###

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.

###

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

###

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

###

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

###

  • Go to “Setting” → find “Developer options” in System
  • TURN OFF “Verify apps over USB” in Debbuging section.

###

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.

###

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

###

for check, sometime just need go to:

  • Settings
  • Permissions
  • Install via USB (turn off your app if exist)
    It was my case. Thanks @Jiyeh

###

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;

###

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.

Leave a Reply

Your email address will not be published. Required fields are marked *