Android Install on Device Failure [INSTALL_CANCELED_BY_USER]

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.


Solution 1:

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

Solution 2:

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!

Solution 3:

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