115

I try to install app via adb and get a error:

$ ./adb -d install /Users/dimon/Projects/one-place/myprogram/platforms/android/build/outputs/apk/android-debug.apk -r -g
3704 KB/s (4595985 bytes in 1.211s)
    pkg: /data/local/tmp/android-debug.apk
Failure [INSTALL_CANCELED_BY_USER]

In device I do nothing in this moment. Device is Xiaomi MI5, MIUI 7.2.13, Android 6.0. Developer mode enabled. How to fix this?

The same error I get when try to run "ionic run android" command.

UPD

Here is logs from 'adb logcat' command getting in moment of installation program:

06-06 10:04:20.051   788   903 I DisplayFeatureService: void android::update_watchlist(const prop_info*, void*): sys.boot_completed: 1
06-06 10:04:20.063   788   903 I DisplayFeatureService: void android::update_watchlist(const prop_info*, void*): sys.boot_completed: 1
06-06 10:04:20.078 13397 13397 E ANDR-PERF-MPCTL: Unable to create control service (stage=2, rc=-1)
06-06 10:04:20.082   788   903 I DisplayFeatureService: void android::update_watchlist(const prop_info*, void*): sys.boot_completed: 1
06-06 10:04:20.079 13396 13396 W iop     : type=1400 audit(0.0:527): avc: denied { write } for name="socket" dev="tmpfs" ino=14686 scontext=u:r:dumpstate:s0 tcontext=u:object_r:socket_device:s0 tclass=dir permissive=0
06-06 10:04:20.088   788   903 I DisplayFeatureService: void android::update_watchlist(const prop_info*, void*): sys.boot_completed: 1
06-06 10:04:20.926 13400 13400 D AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 2000 <<<<<<
06-06 10:04:20.930 13400 13400 D AndroidRuntime: CheckJNI is OFF
06-06 10:04:20.966 13400 13400 D ICU     : No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
06-06 10:04:20.995 13400 13400 I Radio-JNI: register_android_hardware_Radio DONE
06-06 10:04:21.004 13400 13400 E         : WFDWhiteListing : library initialized successfully
06-06 10:04:21.020 13400 13400 D AndroidRuntime: Calling main entry com.android.commands.pm.Pm
06-06 10:04:21.027 13400 13400 I Timeline: Timeline: Activity_launch_request time:973226
06-06 10:04:21.028  1497  2996 I ActivityManager: START u0 {act=android.intent.action.VIEW dat=file:///data/local/tmp/android-debug.apk typ=application/vnd.android.package-archive flg=0x18000000 cmp=com.miui.securitycenter/com.miui.permcenter.install.AdbInstallActivity (has extras)} from uid 2000 on display 0
06-06 10:04:21.033  1497  2996 E         : WFDMMServiceClient ctor Context = 0x0, Cb = 0x0
06-06 10:04:21.033  1497  2996 E         : getWFDMMServiceInstance get new Instance
06-06 10:04:21.033  1497  2996 E         : Service not available yet
06-06 10:04:21.034  1497  2996 E         : WFDMMServiceClient::~WFDMMServiceClient
06-06 10:04:21.037  1497  2996 E         : WFDMMServiceClient ctor Context = 0x0, Cb = 0x0
06-06 10:04:21.037  1497  2996 E         : getWFDMMServiceInstance get new Instance
06-06 10:04:21.037  1497  2996 E         : Service not available yet
06-06 10:04:21.037  1497  2996 E         : WFDMMServiceClient::~WFDMMServiceClient
06-06 10:04:21.050  2875  3077 D PowerKeeperEventLogManager: notifyForegroundCompomentChanged ComponentInfo{com.miui.securitycenter/com.miui.permcenter.install.AdbInstallActivity}
06-06 10:04:21.051  2875  3036 D PowerKeeperExecutor: notify state normal_state enter...
06-06 10:04:21.051  2875  3036 D PowerKeeperExecutor: foreground_change:
06-06 10:04:21.051  2875  3036 D PowerKeeperExecutor: set_cpu_powermode(middle)
06-06 10:04:21.051  2875  3036 I PowerKeeperExecutor: no local quick execution method for set_cpu_powermode
06-06 10:04:21.051  2875  3036 D PowerKeeperExecutor: set_lcd_mode(ui)
06-06 10:04:21.051  2875  3036 I PowerKeeperExecutor: no local quick execution method for set_lcd_mode
06-06 10:04:21.049  2887  2887 W EventReader: type=1400 audit(0.0:528): avc: denied { search } for name="756" dev="proc" ino=16099 scontext=u:r:system_app:s0 tcontext=u:r:zygote:s0 tclass=dir permissive=0
06-06 10:04:21.049  2887  2887 W EventReader: type=1400 audit(0.0:529): avc: denied { search } for name="756" dev="proc" ino=16099 scontext=u:r:system_app:s0 tcontext=u:r:zygote:s0 tclass=dir permissive=0
06-06 10:04:21.051  3247  4440 I octvm_power: power mode [normal] start 1465200261
06-06 10:04:21.051  3247  4440 I octvm_power: Action: set_cpu_powermode(middle) for [foreground_change]
06-06 10:04:21.051  3247  4440 I octvm_drv: common drv: platform_set_power_profile -> platform not support
06-06 10:04:21.051  2533  2887 I octvm   : task pid 2113 have been add to group sys_standby.
06-06 10:04:21.051  3247  4440 I octvm_power: Action: set_lcd_mode(ui) for [foreground_change]
06-06 10:04:21.051  3247  4440 I octvm_drv: common drv: platform_set_lcd_mode -> platform not support
06-06 10:04:21.051  2533  2887 I octvm   : task pid 2900 have been add to group sys_standby.
06-06 10:04:21.049  2887  2887 W EventReader: type=1400 audit(0.0:530): avc: denied { search } for name="756" dev="proc" ino=16099 scontext=u:r:system_app:s0 tcontext=u:r:zygote:s0 tclass=dir permissive=0
06-06 10:04:21.051  2533  2887 I octvm   : task pid 4553 have been add to group sys_standby.
06-06 10:04:21.051  2533  2887 I octvm   : [sys_standby]cgroup_add_tasks max single write time: 0ms
06-06 10:04:21.051  2533  2887 I octvm   : [sys_standby]cgroup_add_tasks total time consume: 0ms
06-06 10:04:21.051  3247  4440 I octvm_power: onPowerModeChanged[normal] called
06-06 10:04:21.052  2875  3093 I FirstNotificationController: handleUnlockState: stoped
06-06 10:04:21.055  1497  2996 I Timeline: Timeline: App_transition_ready time:973254
06-06 10:04:21.055  1976  1976 V PhoneStatusBarPolicy: updateManagedProfile: mManagedProfileFocused: false mKeyguardVisible: true
06-06 10:04:21.055  1497  2996 I Timeline: Timeline: App_transition_stopped time:973255
06-06 10:04:21.059  1497  2996 E ActivityManager: Invalid thumbnail dimensions: 0x0
06-06 10:04:21.059  4553  4553 W .securitycenter: type=1400 audit(0.0:531): avc: denied { search } for name="tmp" dev="dm-0" ino=28 scontext=u:r:system_app:s0 tcontext=u:object_r:shell_data_file:s0 tclass=dir permissive=0
06-06 10:04:21.066  4553  4553 W asset   : Asset path /data/local/tmp/android-debug.apk is neither a directory nor file (type=0).
06-06 10:04:21.066  4553  4553 D AdbInstallActivity:  parsePackage is null , path :/data/local/tmp/android-debug.apk
06-06 10:04:21.059  4553  4553 W .securitycenter: type=1400 audit(0.0:532): avc: denied { search } for name="tmp" dev="dm-0" ino=28 scontext=u:r:system_app:s0 tcontext=u:object_r:shell_data_file:s0 tclass=dir permissive=0
06-06 10:04:21.072  1497  2230 E         : WFDMMServiceClient ctor Context = 0x0, Cb = 0x0
06-06 10:04:21.072  1497  2230 E         : getWFDMMServiceInstance get new Instance
06-06 10:04:21.072  1497  2230 E         : Service not available yet
06-06 10:04:21.072  1497  2230 E         : WFDMMServiceClient::~WFDMMServiceClient
06-06 10:04:21.073  1497  2230 E         : WFDMMServiceClient ctor Context = 0x0, Cb = 0x0
06-06 10:04:21.073  1497  2230 E         : getWFDMMServiceInstance get new Instance
06-06 10:04:21.073  1497  2230 E         : Service not available yet
06-06 10:04:21.073  1497  2230 E         : WFDMMServiceClient::~WFDMMServiceClient
06-06 10:04:21.075  1497  2230 E ActivityManager: Invalid thumbnail dimensions: 0x0
06-06 10:04:21.076  2875  3077 D PowerKeeperEventLogManager: notifyForegroundCompomentChanged ComponentInfo{com.android.settings/com.android.settings.Settings$WifiSettingsActivity}
06-06 10:04:21.069  2887  2887 W EventReader: type=1400 audit(0.0:533): avc: denied { search } for name="756" dev="proc" ino=16099 scontext=u:r:system_app:s0 tcontext=u:r:zygote:s0 tclass=dir permissive=0
06-06 10:04:21.076  1497  2230 I Timeline: Timeline: App_transition_ready time:973275
06-06 10:04:21.076  1497  2230 I Timeline: Timeline: App_transition_stopped time:973275
06-06 10:04:21.076  2533  2887 I octvm   : task pid 2060 have been add to group sys_standby.
06-06 10:04:21.076  2533  2887 I octvm   : [sys_standby]cgroup_add_tasks max single write time: 0ms
06-06 10:04:21.076  2533  2887 I octvm   : [sys_standby]cgroup_add_tasks total time consume: 0ms
06-06 10:04:21.077  1976  1976 V PhoneStatusBarPolicy: updateManagedProfile: mManagedProfileFocused: false mKeyguardVisible: true
06-06 10:04:21.090 13400 13400 I art     : System.exit called, status: 1
06-06 10:04:21.090 13400 13400 I AndroidRuntime: VM exiting with result code 1.
06-06 10:04:21.100  2060  2130 V MI_STAT : disabled local event upload

I see when android-debug.apk creates, but I don't understand why it's not installs. Maybe the key strings is:

06-06 10:04:21.066  4553  4553 W asset   : Asset path /data/local/tmp/android-debug.apk is neither a directory nor file (type=0).
06-06 10:04:21.066  4553  4553 D AdbInstallActivity:  parsePackage is null , path :/data/local/tmp/android-debug.apk

but this is not error strings, just warning and debug. Also strange line:

06-06 10:04:21.059  1497  2996 E ActivityManager: Invalid thumbnail dimensions: 0x0

but I don't know if it is a problem.

Also I tried to install via adb some other apps, not only self-written. But no results.

Dmitry Skryabin
  • 1,584
  • 2
  • 10
  • 15
  • 1
    Do you have the app already installed on your phone? If so, uninstall first, and try again. Another option is to use `adb install -r /path/to/apk/file.apk`, which will install over the app if it already exists. – KhoPhi Jun 05 '16 at 13:05
  • I tried to uninstall it, and tried to use adb install -r, but it not helped me. – Dmitry Skryabin Jun 05 '16 at 13:30
  • Were you able to solve this? – gaurav jain Jun 10 '16 at 10:03
  • 1
    Hello Dmitry Skryabin, I have the same phone and have the same problem as you. I cannot adb install anything on the phone. Unknown sources is ON and I can install apps from storage to device, but I cannot debug apps from Android Studio or Xamarin. I feel it is an OS/Xiaomi Mi5 thing. Going to head over to the Xiaomi forums to ask this same question. – Yudhistre Jun 13 '16 at 22:08
  • @Yudhistre, thanks for you comment. I have temporary switched to debug on IPhone emulator, it's enough for my purposes. – Dmitry Skryabin Jun 15 '16 at 07:42
  • Still does not justify not having the ability to deploy and debug right on our new Mi5 device. – Yudhistre Jun 15 '16 at 14:30

23 Answers23

326

The same trouble with same device has been here.

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

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

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

  3. At there switch off "Install via USB" option, which manages 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.

starball
  • 20,030
  • 7
  • 43
  • 238
Yury Bragin
  • 3,376
  • 1
  • 9
  • 3
  • 2
    Yes, it works! Hint for other users: in Russian language (on firmware from xiaomi.eu) this parameter named "Менеджер установки". – Dmitry Skryabin Jul 03 '16 at 06:17
  • 11
    The newer version of the Security app no longer has the option. The answer by Victor Lopez worked for me – Ray Jan 04 '17 at 16:22
  • 10
    In the recent update this turning on install via usb wont work unless you sign into mi account. This is insane!!! Any idea how to bypass this ridiculous feature? – NIPHIN Jul 02 '17 at 06:21
  • Congratulations I have an MI5 and I was having this same problem – William Jan 19 '18 at 20:18
  • 8
    Quiet surprising that there is a need of a SIM card to enable this. Sigh! – Sreekanth Karumanaghat Feb 27 '18 at 06:55
  • 1
    It wants to authorize first and doesn't allow to enable `install via usb` without it. Signing up doesn't send a verification code neither on e-mail nor on mobile. WTF?! – fnc12 Jul 13 '18 at 14:21
  • 1
    Aso if you have latest Redmi devices you should have your mi account.. cant believe it.. – AlexS Nov 08 '18 at 06:49
  • 1
    Good to know: never buy a redmi! – Manuela Feb 26 '19 at 14:12
  • @fnc12 try looking in the spam or junk emails :) (I couldn't find the activation emails until I looked for them in the spam and there they were...) – Manuela Feb 26 '19 at 14:37
  • I also had to check on "USB debugging (Security settings) for Xiaomi Mi 6 MIUI 10.2 – kabaehr Mar 05 '19 at 14:01
  • check also additional settings --> developer options --> USB debugging(security) enable. it show some warnings and accept those. – Vidurajith Darshana Nov 29 '19 at 07:44
  • Disable Turn on MIUI optimization: Setting -> Additional Setting -> Developer Option, near bottom we will get this option. – Ansal Antony Feb 18 '21 at 15:39
88

Faced the same Issue in MI devices and figured out the problem by following these Steps :

1) Go to Setting

2) Click on Additional Settings

3) Click on Developer Options

4) Click toggle of Install via USB to enable it

and the issue will be resolved.

enter image description here

Kapil Rajput
  • 11,429
  • 9
  • 50
  • 65
54

In MIUI 8 go to Developer Settings and toggle "Install over USB" to enable it.

Víctor López
  • 669
  • 5
  • 5
30

For Redmi and Mi devices turn off MIUI Optimization

Settings > Additional Settings > Developer Options > MIUI Optimization

Chirag Shah
  • 942
  • 8
  • 3
  • Wow i so hate MIUI os, this is an example of "the way to hell is paved with good intentions" This "MIUI Optimization" wasted me too much time . Thank you – Rami Loiferman Jul 21 '17 at 15:18
  • Indeed, if You disable the mentioned option, there is no need to enable "Install apps via USB" option and log in to Mi account - adb installation "just works". Thank You so much for the advice! – Mateusz Falkowski Sep 26 '20 at 20:37
15

For Mi or Xiaomi Device

1) Setting

2) Additional Setting

3) Developer option

4) Install via USB: Toggle On

It is working fine for me.

Note: Not working then try following options also

1) Sign to MI account (Not applicable to all devices)

2) Also Disable Turn on MIUI optimization: Setting -> Additional Setting -> Developer Option, near bottom we will get this option.

3) Developer option must be enabled and Link for enabling developer option: Description here

Still not working?

-> signed out from Mi Account and then created new account and enable USB Debugging.

Thanks

Revansiddappa
  • 708
  • 1
  • 7
  • 16
  • 2
    Disabling **Turn on MIUI optimization** allowed me to skip signing into Mi Account - I still could not enable **Install via USB** setting, but it wasn't necessary anymore, `adb install` worked without it. Thank you! – Marchyello Jan 30 '21 at 14:23
10

The problem seems to be with Instant Run feature.Go to "File -> Settings -> Build, Execution, Deployment -> Instant Run" and just disable it.

Hope this works if above answers doesnt work..

antman
  • 317
  • 6
  • 16
10

1 Settings

2 Additional Settings

3 Developer Options

4 Developer options: Check the Install via USB option.

enter image description here

Keshav Gera
  • 10,807
  • 1
  • 75
  • 53
7

Turn off Miui Optimizations on Developer Settings, then Restart the phone. it worked for me. Settings > Additional Settings > Developer Options > MIUI Optimization

Vinay Rathod
  • 91
  • 1
  • 2
6

I had the same problem before. Here was my solution:

  1. Go to Setting → find Developer options in System, and click.
  2. TURN ON install via USB in the Debuging section.
  3. Try Run app in Android Studio again!
rghome
  • 8,529
  • 8
  • 43
  • 62
4

I tried all the steps described above but failed.

Like, connect to the internet with Data connection, Turning off the MIUI optimization and reboot, Turning on Install via USB from Security settings etc.

Then I found a solution.

Steps:

  • Install PlexVPN.
  • set China-Shanghai server
  • Try turning on Install via USB from Developer option.

That's all.

Sudarshan
  • 938
  • 14
  • 27
2
  1. Disable "Verify apps over USB" option under developer mode and try to install again .It should work as pointed out in link https://stackoverflow.com/a/29742394/2559990.
Abhishek
  • 306
  • 2
  • 8
  • I saw this link, but it not helped me. I tried to disable it, enable it, and rebooted device after changing it, but not results :( Also I tried to reenable developer mode in device - all without success. I updated main post, added more logs from device. – Dmitry Skryabin Jun 06 '16 at 08:26
2

For MIUI OS Device

1) Go to Setting

2) Scroll down to Additional Setting

3) You will find Developer option at bottom

4) Turn this on - Install via USB: Toggle On

By turning this on, It is working charm in my MIUI8 device.

Kuls
  • 2,047
  • 21
  • 39
2

On Xiaomi Mi5s with MIUI8.3 (Android 6) Xiaomi.EU Rom:

Settings/ Other Settings / Developer Options / Switch on: Allow USB Debug, Allow USB install and Allow USB Debug (Security options)

{Sorry for the translation, my device has spanish}

ieselisra
  • 387
  • 4
  • 16
2

In addition, any app lock password should be removed by SETTINGS>APP LOCK ,enter the set password and remove the lock. This worked for me on REDMI 4A

2

For anyone on MIUI 13 and above - MIUI Optimization option is hidden, so you have to go to Developer Options -> Reset to default values and press it multiple times so that MIUI Optimization appears - only then you can disable it.

1

One more thing: after some updates of MIUI developer mode becomes disabled. I was sure, that is was turned on, but i couldn't start the application. So i reenabled developer mode and everything started to work. I've encountered this problem several times. Hope it helps.

porfirion
  • 1,619
  • 1
  • 16
  • 23
1

Im using Xiaomi Redmi Prime 3S, Non of the above method worked for me. This frustrated me

what i tried was, i signed out from Mi Account and then created new account. tada... after that i can enable USB Debugging. Hope this helps.

yoweeslah
  • 11
  • 3
1

If your switch Install by USB on and you are getting "the device is temporarily restricted" error, then apply any of the default mobile themes. If any other developer theme is applied then it will not Allow you to switch Install by USB on. This works for me.

user3766149
  • 56
  • 1
  • 9
1

In my case I had once denied the installation by mistake. Then I had to deactivate the app in the phone settings under Apps -> Permissions -> Install via USB (my smartphone at that time: Xiaomi, MIUI version 13.0.2)

0

Sometimes the application is bad generated: bad signed or bad aligned and report a mistake.

Check your jarsigner and zipaligned commands.

Virako
  • 650
  • 10
  • 18
0

This is my case (using react-native) I press Ctr+C to interrupt while installing and after that this error occured. - solution:

cd android
./gradlew clean
nightdog
  • 1
  • 2
0

I have a Xiaomi 8 when I go to settings > Additional Settings > Developer Options > activated USB debugging and activated install via USB and activated USB debugging (security setting) and activated verify apps over USB. and you can verify if you are activated Turn on MIUI optimisation, if don't activated so active. And you reboot your device and your can run your application for me it ok.

lejlun
  • 4,140
  • 2
  • 15
  • 31
-2

Its a Xiaomi's issue If possible update MIUI to latest version then go to Settings > Additional Settings > Developer Options > Developer options: Check the Install via USB option.

This solved my issue hope it will also solve yours good luck!

  • 1
    how is this different from https://stackoverflow.com/a/40971196/1778421 or https://stackoverflow.com/a/41674530/1778421 – Alex P. Aug 22 '18 at 20:21