367

Android Studio with Failed Error

Got this freaky error

Installation failed with message Failed to finalize session : INSTALL_FAILED_USER_RESTRICTED: Install canceled by user.
It is possible that this issue is resolved by uninstalling an existing version of the `apk` if it is present, and then re-installing.

WARNING: Uninstalling will remove the application data!

Do you want to uninstall the existing application?

When trying to run the apk in my redmi 4 MIUI 8.5.4.0

OEM unlocking enabled

Solution Tried

  • MIUI optimization turned off
  • USB debugging turned on
  • Verify apps over USB turned on

NOTE: while turning on install via USB a pop up saying The device is temporarily restricted

Aniruddh Parihar
  • 3,072
  • 3
  • 21
  • 39
brainLoop
  • 3,810
  • 2
  • 10
  • 13
  • 3
    Possible duplicate of [Android Studio: Failure \[INSTALL\_FAILED\_USER\_RESTRICTED\]](https://stackoverflow.com/questions/40534271/android-studio-failure-install-failed-user-restricted) – GoRoS Nov 11 '17 at 15:11
  • When I get this error, I press 'Cancel' and re-upload the APK. It always works the second time – Spikatrix Mar 30 '19 at 05:01

31 Answers31

815

Steps for MIUI 9 and Above:

Settings -> Additional Settings -> Developer options ->

  1. Turn off "MIUI optimization" and Restart

  2. Turn On "USB Debugging"

  3. Turn On "Install via USB"

    MTP(Media Transfer Protocol) is the default mode.
    Works even in MTP in some cases

  4. Set USB Configuration to Charging

Gladis Wilson
  • 8,400
  • 1
  • 12
  • 12
  • for those who can't enable "Install via USB", turn off your wifi, enable your celular data transfer and try again – Gabriel Espinoza May 21 '18 at 02:11
  • This solution worked for me after I did these two steps beforehand: 1. Insert a SIM-Card. 2. Turn off Mock SD-Card optimization – Henning Jul 10 '18 at 11:16
  • It works But Set USB Configuration to MTP ( Media Transfer Protocol ) otherwise your Device will not be there in the Select Device to run menu – Mr. Suryaa Jha Jul 26 '18 at 16:49
  • 5
    Works on Redmi Note 7, i only needed to turn of MIUI Optimization, if i do all of those steps, i can turn on the optimization again? – Ricardo Dias Morais Apr 10 '19 at 11:07
  • all worked except charging for last one, i set it to MTP to work – Ehsan Sajjad Jun 27 '19 at 21:39
  • 17
    Step 1 is most important – Bibaswann Bandyopadhyay Jun 28 '19 at 07:06
  • step 1, turn off MIUI optimization was enough to debug our apps. "install via usb" now requires Mi Account, which is I never create one :D – mochadwi Jan 07 '20 at 05:58
  • For me, turning on "Install via USB" was enough :) – lunesco Feb 02 '20 at 23:31
  • 8
    Mi 9T Pro Just Turn on "USB Debugging" and "Install via USB" – Billy Mar 08 '20 at 07:29
  • The first step and the restart of the device was enough. Thanks a lot. – Christian Blanco May 17 '20 at 05:53
  • New to Xiami, with Redmi 7A and Android 9.0. I already had `Developer Options`. `USB Debugging` and `Install via USB` enabled, as normal pre-requisites. Then when I tried to install with AndroidStudio I got the Xiami (?) message "INSTALL_FAILED_USER_RESTRICTED". As instructed by this answer I un-clicked "Turn on MIUI optimisation" (at the bottom of developer settings), but did NOT restart. My apk then installed and ran. Thankyou! CAVEAT: My device is already unlocked, as per @Shivani Rastogi's answer below. Maybe this was also necessary? – Stephen Hosking Jul 08 '20 at 02:23
  • Don't turn off MIUI optimization, instead check this https://stackoverflow.com/a/52328849/10085274 this works for me – Hamed Rahimvand Jul 13 '21 at 07:56
  • still works in 2022 :3 – Niaz Palak Aug 25 '22 at 15:23
  • Worked for my on Redmi Device. – Mohit Nov 06 '22 at 07:18
  • If you don't see MIUI Optimization option. You have to go to Developers Options and select "Reset to default values" at the very bottom under AUTOFILL. And then press it multiple times(one time didn't work for me). Then you'll see MIUI Optimization option. – Thomsheer Ahamed Mar 07 '23 at 11:48
  • I had issues because of a bad type C cable :) – Chen Apr 24 '23 at 14:43
  • These phones are the worst I've ever worked with... constant pain for everything. – samzmann Jun 15 '23 at 15:39
  • Heads up. I couldn't turn on "Install via USB" until I'd created and logged in with a xiaomi account. There's no "Turn off MIUI optimisation" option (on MIUI 14.0.3) – powlo Aug 11 '23 at 20:04
84

In your mobile device,make sure you have enabled the following buttons.

Settings > Additional Settings > Developer options

  1. Install via USB
  2. USB Debugging (Security settings)

enter image description here

Prashant Abdare
  • 2,175
  • 14
  • 24
  • 8
    Ensure that you've SIM card inserted. they don't work on wifi only. – AnswerDroid Sep 10 '18 at 06:42
  • 7
    What utter stupidity is this? Why would I need a SIM card (and a Xiaomi-Account, for that matter) to enable installation over USB? I mean, you are right, it fails without a SIM, but why??? – david.mihola Jan 23 '23 at 11:55
69

The device is temporarily restricted error appears in MIUI 8.5. To resolve the error you need to make WIFI off and make mobile data on and then enable the option “Install via USB” under "Developer Options" in "Settings". it will work for you.

Ehsan Sajjad
  • 61,834
  • 16
  • 105
  • 160
Aarif Aslam
  • 1,077
  • 10
  • 15
26

In my case, I pressed Deny unfortunately during first time installation. So I was getting INSTALL_FAILED_USER_RESTRICTED.

You can get modify this permission for app under permissions.

Settings->Permissions->Install via USB->{Your App}

You should have enabled below options too.

Settings->Additional Settings->Privacy->Unknown Sources

Settings->Additional Settings->Developer Options->Install via USB

Suryavel TR
  • 3,576
  • 1
  • 22
  • 25
21

For me none of the above solutions worked. Instead i do following steps that solved the issue :

  1. Developer Options > Mi Unlock Status > Add account and device. (A success message will appear)
  2. Turn on USB Debugging.
  3. Turn on Install via USB.

Note : This is checked on Redmi MIUI Global 8.5 version.

This solution will specifically solve the issue if you have recently logged out of Mi account & again logged in.

Hope it may help someone.

Shivani Rastogi
  • 740
  • 7
  • 14
21

For MIUI 12:

  • Developer options (On)
  • USB debugging (On)
  • Install via USB (On).
  • Allowed "Android System" to install from Unknown apps. (Try "More/Show system" if you can't see it in the list.)

This worked for me but got an android security warning.

seanf
  • 6,504
  • 3
  • 42
  • 52
Owen Alikula
  • 408
  • 3
  • 11
19

Settings->Additional Settings->Developer Options

1) Turn ON Developer Options
2) Turn ON USB Debugging
3) Turn OFF MIUI optimization
4) Turn ON Install via USB
Ajay
  • 917
  • 3
  • 12
  • 26
18

For MIUI 9.6 works:
1. Become a developer: Settings >> About phone >> MIUI version tap 7 times.

2. Again Settings >> Additional settings >> Developer options (turn on) >> USB debugging (turn on) >> Install via USB (turn on).

3. You will be asked for permission through your MI account. Confirm permission.

4. Note: During the installation of the application, your device will give you 7 seconds to confirm the installation. Don't miss it!

SportAtomDroid
  • 389
  • 3
  • 10
18

For MIUI global 13 and above to turn off MIUI optimization

  • go to the developer option
  • go down where button one was "Reset to default values"
  • press it 5 times or more,
  • then the turn-off MIUI optimization is visible

enter image description here

enter image description here

enter image description here

enter image description here

Robert Robinson
  • 407
  • 5
  • 14
14

Xiaomi MIUI.

Options - Permissions - Install via USB (not the same item in Developers options!) then uncheck your disabled app

7

You have to enable developer mode then

settings -> additional settings ->

  • USB debugging: sets ON

  • Install via USB: sets ON (to do this you have to insert a sim card otherwise you'll not be able to enable it)

[![enter image description here][1]][1]

[![enter image description here][2]][2]enter image description here

Osahady
  • 439
  • 7
  • 16
7
  1. Turn off MIUI optimization from Developer options
  2. install the app
  3. turn it back on.

next installs of this apk(and its updates) wont give this error anymore.

Ali80
  • 6,333
  • 2
  • 43
  • 33
5

Reference

The same trouble with the same device has been here.

So, it's Xiaomi trouble, and here is a solution to this problem:

  • Go to the "Security" application and tap "Options" at top right corner

  • Scroll down to "Feature Settings" group, and look for "Permissions"

  • At there switch off "Install via USB" option, which manages the installation of the apps via USB and doesn't allow it.

On Latest Redmi Device:

Settings > Additional Settings > Developer Options > Developer options: Check the Install via USB option.

enter image description here

Md Imran Choudhury
  • 9,343
  • 4
  • 62
  • 60
4

If above answer didn't work for you as it didn't work for me on my Xiaomi Mi5.I tried to figure out the Core reason behind it and solve it. In MIUI, in order to change "Install via USB" option, you must be connected to the internet and signed in your Mi account. Due to some reason, requests from out of the China servers are getting rejected, so I connected to one open China VPN and tried again to enable 'Install via USB' and I got success. For detailed solution and VPN details, see this useful Youtube video: https://youtu.be/MeKUJlD-Ke4

Perry
  • 244
  • 3
  • 15
4
  1. Just Disable Mock SD card optimization in the developer options
  2. Turn off "Turn on MIUI optimization"
  3. Mark force-closed apps

These Settings worked for me.Cheers!

Patrick Prakash
  • 500
  • 1
  • 7
  • 17
3

For me, this works only Steps for MIUI 9 and Above:

Settings -> Additional Settings -> Developer options ->

Turn off "MIUI optimization" and Restart

Turn On "USB Debugging"

Turn On "Install via USB"

Set USB Configuration to Charging

MTP(Media Transfer Protocol) is the default mode. Works even in MTP in some cases

Rahul
  • 3,293
  • 2
  • 31
  • 43
3

Failure [INSTALL_FAILED_USER_RESTRICTED: Install canceled by user]:

Go to Settings->Additional Settings->Developer options->Developer Option(Need to enable)->USB debugging(Need to enable)->Install via USB (Need to enable)->USB debugging (Security settings)(Need to enable)

Perfectly working in the above steps.

Enjoy your coding...

Mahendren Mahisha
  • 1,072
  • 11
  • 9
2

To turn on "Install via USB" and "USB Debugging(Security changes)" need to sign in to xiaomi account then these 2 can be turned on and work with redmi as developer

Note:When turning on USB Debugging(Security changes) few security alerts will be poped up all need to be accepted to work on developer mode

Mithun C.N
  • 21
  • 2
2

How to Fix Install Failed User Restricted Failure in Android Studio - For Xiaomi Redmi Note 4X (100% worked for me) Settings=>Additional settings=>Developer Options

  1. Mock SD card optimization = OFF
  2. USB debugging = ON
  3. Install via USB = ON
  4. USB debugging (Security settings) = ON
  5. Verify apps over USB = ON
  6. Force-closed apps = ON
  7. Turn on MIUI optimization = OFF
2

With Xiaomi Redmi note 8 pro (MIUI 10.4.4), Android 9 -

While connecting to Vysor (2.1.2) from Windows PC (via USB cable), received the error message:

"Error installing APK: Failure [INSTALL_FAILED_USER_RESTRICTED]"

even after turning "USB Debugging" On.

So the following settings were required -

  • Developer options (On)
  • USB debugging (On)
  • Install via USB (On)

Leave the following,

  • Turn on MIUI optimization (On)
  • Verify apps over USB (On)
nbs
  • 311
  • 1
  • 12
2
  1. Turn on usb debugging
  2. Turn on Install via USB :-> While turning on it asks for mi account sign in you can get instant otp vis sms service to sign in quickly.
  3. Turn off MIUI optimization.
Shiva Yadav
  • 72
  • 1
  • 9
2

Updated MIUI 12:

I have to turn on "OEM unlocking" beside other settings. (I don't need to change "Mi Unlock status"

SLyHuy
  • 565
  • 6
  • 12
2

If it's still not working try adding android:exported="true" and upgrade your dependencies

Rohit Lalwani
  • 529
  • 7
  • 14
1

It's simple, in MIUI 9.x you need developer settings ON and then

  • Settings -> (system & device section) Additional Settings -> Developer options

(Debugging section)

  • Turn On "USB Debugging"
  • Turn On "Install via USB"

Then in Android select Runb app and choose your Xiaome phone

EDIT: you will also need allow installation from unknown sources

blackgreen
  • 34,072
  • 23
  • 111
  • 129
xchiltonx
  • 1,946
  • 3
  • 20
  • 18
1

For me it is:

Settings->Apps->Permissions->Install via USB->uncheck app

Renetik
  • 5,887
  • 1
  • 47
  • 66
0

what worked for me

  1. goto Settings -> Additional Settings -> Developer options -> Revoke USB Debugging Authorizations.

  2. Kill adb.exe in the taskmanager (CTRL + SHIFT + ESCAPE)

  3. Install again, watch for popups (accept RSA signature and install) Everything will work now

... ...

Jack
  • 1,545
  • 2
  • 11
  • 20
0

first, check your USB debussing options all mandatory should be enabled. then uninstall the application from the device and then try to reinstall again. this works for me.

Zeeshan Akhtar
  • 441
  • 1
  • 4
  • 9
0

Another possible reason in case if you have accidentally denied installing specific application - remove it from blacklisted.

It is under Security > Install via USB.

Note: You may not simply find it from Security. Instead search for "USB" from Settings search and look or that option in Security.

If your app is there - simply remove from the list. If not - then it's some other problem.

0

If you are still facing INSTALL_FAILED_USER_RESTRICTED issue try this this methods works for me in miui 13 Setting->Permissions->Install via USB->untick your app

Mohit jain
  • 59
  • 4
0

for more detail video

1) Turn ON Developer Options
2) Turn ON USB Debugging
3) Turn OFF MIUI optimization
4) Turn ON Install via USB

youtube video for more visual understanding

Sourabh Gera
  • 862
  • 7
  • 7
-4

For me only installing from Google drive worked.

user3193413
  • 575
  • 7
  • 10