412

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

0

32 Answers 32

906

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

Sign up to request clarification or add additional context in comments.

11 Comments

for those who can't enable "Install via USB", turn off your wifi, enable your celular data transfer and try again
This solution worked for me after I did these two steps beforehand: 1. Insert a SIM-Card. 2. Turn off Mock SD-Card optimization
Mi 9T Pro Just Turn on "USB Debugging" and "Install via USB"
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?
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.
|
109

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

4 Comments

Ensure that you've SIM card inserted. they don't work on wifi only.
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???
I followed this instructions when trying wifi debuging but didn't work. So I changed to cable usb debug and it worked.
this solution solved my problem in installing and running app in android device
74

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.

2 Comments

* then enable the option "Install via USB"* But where is this option
Install via USB option is present under developer options
57

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

5 Comments

i accedentally revoke the permission to download my app on my xaomi poco device..and since then i couldn't install any app on it again. This answer worked perfectly!!
This answer worked for me on Xiaomi Tablet with MIUI 14. Thanks a lot.
I don't think that "Reset to default values" option would have any effect on the actual issue
Life saver! Works on MIUI Global 14 too.
Life saver <3 thankss
41

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

5 Comments

LIFE SAVER! I did the same mistake and ticked the "Do not ask again" checkbox... Thanks.
Settings->Additional Settings->Privacy->Unknown Sources -- was helpful
Install via USB requires an account which is stupid
Settings->Permissions->Install via USB => I then deselected my app and it worked.
On Redmi Note 7 (Miui 12.5.3), the option "Install via USB" migrated to: Settings -> Apps -> Permissions
22

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.

5 Comments

Can you please mention what error you are getting from Google play?
INSTALL_FAILED_USER_RESTRICTED & my OS is MIUI 10 global ,device redmi 7s, app play.google.com/store/apps/…
it needs sim card
Install via USB requires an account
In my case I just had to turn off wifi and turn on mobile data with USB debugging, Install via USB and USB Debugging (Security settings) all turned on. I was on MIUI 14.x.
22

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.

Comments

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 

1 Comment

where is MIUI optimization?
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!

5 Comments

Is there any way to remove/bypass that confirmation msg every time I install app?
Did you ask about point 4? I did not check it but I think it is MIUI extra security. I have not tried to change it.
Thanks for Install via USB. Permission confirmation was not asked (Xiaomi Mi 8).
On Redmi Note 4(x) I had to create MI account on step 3.
After entering MI account it also writes: "Insert your SIM card", if you haven't inserted already.
15

Xiaomi MIUI.

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

Comments

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

2 Comments

I don't have a sim, I bought this phone for development only. Is there no way to use it without a sim?
@Hackeron try this solution stackoverflow.com/a/72994292/12838877 You have to turn off MUI Optimization , but its hide by default.
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.

Comments

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

Comments

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

Comments

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

1 Comment

The more reason to root the phone and get rid of the crappy OS. Why do they want to collect your information just so you can install an app via USB?
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

Comments

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

Comments

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)

Comments

2

Updated MIUI 12:

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

1 Comment

This is a dangerous option. Do not carry it out to debug applications, you just have to follow the method to bring up the "Turn on MIUI optimizations" option explained by Robert Robinson.
2

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

Comments

2

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

Comments

2

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

Comments

2

if none of these solution works above then got to App>Permissions>Install via USB> here you see you app name with toggle btn ,just off the toggle

Comments

2

My solution:

  1. Go to "Setting" → find "Developer options" in System, tap it.
  2. TURN OFF "Verify apps over USB" in Debugging section.

Profit!

Comments

2

I accidentally clicked on "Deny" and also "Remember my choice". None of the above fixed my issue on MIUI 14. What I did to fix it was clear the data of "Security" app. Android asked for the permission again and app installed successfully.

Comments

1
  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.

Comments

1

I had the same problem using another device from China.

It turned out that I had to install the app manually the first time:

I had to copy the .apk file to the device and install it by selecting the .apk file in the device's file manager.

(Installing apps from "third party sources" had to be enabled, of course.)

Once the app was installed, I could debug the app and AndroidStudio was able to update the installed app when I modified and re-compiled it (so it was not necessary to manually copy the .apk file again after modifying it).

Comments

1

here is :

  • Xiaomi 8: MIUI 12.5.2, Android 10
    • enabled: Developer Mode, USB Debugging
      • try enable Install via USB, (has login Xiaomi Account) but popup: Please insert SIM card

then error:

➜ apk adb install xxx.apk Performing Streamed Install adb: failed to install xxx.apk: Failure [INSTALL_FAILED_USER_RESTRICTED: Install canceled by user] 

Solution:

  • Disable: MIUI Optimization
    • disabled MIUI Optimization

Comments

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

... ...

Comments

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.