Failure [INSTALL_CANCELED_BY_USER] on Xiaomi device
Asked Answered
H

9

22

I bought a Xiaomi Redmi 4x yesterday and I can't debug my apps in this device.

I already enabled the Developer Options in the device, switch on to USB Debugging, install the USB Drivers and accepted the RSA debugging fingerprint pop that appears when I plug it on USB port for the first time.

So, I select the "Xiaomi Redmi 4X (Android 6.0 - API 23)" in devices list of Visual Studio, click in Run (or deploy) and see this error:

>Detecting installed packages...
>Removing old runtime: Mono.Android.DebugRuntime...
>Target device is arm64-v8a.
>Installing the Mono shared runtime (debug - 1505313604)...
>10% ... 3520kb of 35035kb copied
>20% ... 7040kb of 35035kb copied
>30% ... 10560kb of 35035kb copied
>40% ... 14016kb of 35035kb copied
>50% ... 17536kb of 35035kb copied
>60% ... 21056kb of 35035kb copied
>70% ... 24576kb of 35035kb copied
>80% ... 28032kb of 35035kb copied
>90% ... 31552kb of 35035kb copied
>100% ... 35035kb of 35035kb copied
> Deployment failed
>Mono.AndroidTools.InstallFailedException: Unexpected install output:   pkg: /data/local/tmp/Mono.Android.DebugRuntime-debug.apk
>Failure [INSTALL_CANCELED_BY_USER]
>
>   at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName)
>   at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass94_0.<InstallPackage>b__0(Task`1 t)
>   at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
>   at System.Threading.Tasks.Task.Execute()
>Unexpected install output:     pkg: /data/local/tmp/Mono.Android.DebugRuntime-debug.apk
>Failure [INSTALL_CANCELED_BY_USER]
>
>Creating "obj\Debug\upload.flag" because "AlwaysCreate" was specified.
>Creating directory "obj\.cache\".
>Done building project "MyTestApp.csproj".
>Build succeeded.
>An error occured. See full exception on logs for more details.
>Unexpected install output:     pkg: /data/local/tmp/Mono.Android.DebugRuntime-debug.apk
>Failure [INSTALL_CANCELED_BY_USER]
>
>
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========

This occurs with all my apps and just in this Xiaomi device. In other brand devices and emulators, the debug works normally.

Just to complement, I have this problem http://en.miui.com/thread-544718-1-1.html and even following the instructions, I can't make the "Install via USB" works.

There is any solution to debug in this device?

Homopolar answered 30/9, 2017 at 5:1 Comment(5)
You should look at your device because xiaomi will ask you whether to install apk or not if you do not agree to continue to install apk , it will fail.Prostitution
Xiaomi asks before installation... if you did not timly pressed yes or ok then it cancels by itselfDonelu
@Rafael de Andrade Do you have tired the suggestion that LiJianixn and Ashish John provided? If the problem still exist, please feel free to let us know.Fluorene
Hi, thanks for the help guys, but I discover that the problem was entirely related to the "Install via UBS" option, that MIUI would not let me activate. After numerous attempts and reboots of the device, it finally activated and the deploy worked at the same time. I will include this as answer, to help other people with the same problem.Homopolar
@Rafael de Andrade, Since this issue has been resolved, you could mark your solution as the answer. Thanks for your sharing.Royden
H
35

Just to help anyone who have the same problem: it was entirely related to the "Install via USB" option in the Developer mode, that MIUI would not let me activate. After numerous attempts and reboots of the device, it finally activated and the deploy worked at the same time.

Homopolar answered 2/10, 2017 at 3:25 Comment(4)
Yes had same issue, xiomi redmi note 4, after rebooting once and trying to enable "Install via USB" thrice, on the third time it got activatedCytokinesis
Is there a way to activate this option without having a MIUI account? I don't like to send user data to them when I'm always logged in...Dextrality
@Dextrality have you found any solution to that? I am facing the same. ThanksUrbanist
@Gauranga: Unfortunately not.Dextrality
P
19

In MIUI the UI does some of the optimization for some reason, but this comes out to be an error while running the app on the phone through Android Studio. We need to stop the optimization:

Go to -> Settings -> Switch on the developer option (hope you know) -> Go to developer settings -> Turn off MIUI optimization

I hope this works for you. ;)

Phenosafranine answered 11/7, 2018 at 17:34 Comment(1)
This worked, and i only did it one time. After the first debug, i turned the option on again and continue to debug without any problem after thatNaphthalene
D
8

Do step by step:

  1. Turn on Install via USBin Settings>Additional Settings>Developer Options>Install Via USB(Under Debugging Section) --> Need active Mi account.

  2. Deploy app.

  3. Wait for several seconds, a notification on your Xiaomi phone will display Install via USB, then you need touch Install to allow the app to be deployed on your device. You can choose to remember this option.

Disgust answered 27/11, 2018 at 7:37 Comment(0)
T
3

Inside the developer option of Xiaomi device click on install via USB. It works without any reboot

Thionic answered 4/10, 2018 at 4:36 Comment(0)
C
3

Good afternoon,

I had the same problem, I have a Xiaomi mi 8 lite phone. I solved this problem by disabling MIUI optimization.

I haven't tested on many models / brands to see if this will work.

Clayton answered 23/1, 2020 at 20:13 Comment(0)
C
3

I had solved this by turning off the MIUI Optimization. In case you did not get the MIUI Optimization option in your developer settings, just you need to reset the default values option by tapping it multiple times.

Clip answered 19/10, 2021 at 3:22 Comment(0)
O
1

Search for Install via USB and select the security option, probably your application is blocked from installing:

enter image description here

Overglaze answered 3/3, 2023 at 17:11 Comment(0)
I
1

I had same problem with POCO F1. I found that if you insert a SIM it will allow you to enable USB Debugging.

Improbable answered 19/6, 2023 at 6:1 Comment(0)
K
-1

I had the same problem. Additionaly activate OEM unlocking

Keeshakeeshond answered 25/4, 2022 at 15:15 Comment(3)
OEM Unlocking is not required for debugging. This operation can cause security issues.Lully
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From ReviewCorinnacorinne
@Corinnacorinne This way of linking a picture does not qualify as a link-only.Presentational

© 2022 - 2025 — McMap. All rights reserved.