porfirion
porfirion

Reputation: 1699

Android app installation: Unknown failure (Failure - not installed for 0)

Application works fine on emulator, but I can't launch application on my device (Xiaomi Mi4). At first i seed dialog with such text:

Installation failed with message Failed to establish session.
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?

But after I agree - i see in log this message:

Launching app
$ adb install-multiple -r <....>
$ adb shell pm uninstall com.example.app.debug
Unknown failure (Failure - not installed for 0)
Error while Installing APKs

I've rebooted device several times and plugged/unplugged it to computer, but nothing helped.

Upvotes: 29

Views: 43035

Answers (4)

Chirag Shah
Chirag Shah

Reputation: 952

For Redmi and Mi devices turn off MIUI Optimization and reboot your phone.

Settings > Developer Options > MIUI Optimization

Upvotes: 61

Zenith
Zenith

Reputation: 1207

I solved my problem by following the steps bellow

  1. Turn off Developer options.
  2. Turn on Developer options again.
  3. Turn on USB debugging
  4. Turn on Install via USB

After following the steps I run from android studio and it was installed my app successfully.

Upvotes: 1

Amit Bhatt
Amit Bhatt

Reputation: 11

Only Turning on "Install via USB" in Developer options did the work for me. Otherwise you may need to turn off MIUI Optimization and reboot again, but try the USB option first.

Upvotes: 1

porfirion
porfirion

Reputation: 1699

Problem is in Instant Run.

As Chirag Shah said - on Xiaomi devices you can disable MIU optimization - it worked for me too when I tried.

Another solution is to disable Instant Run in android studio settings. I've remembered - I had this problem some time ago on windows, but now it occured on linux(ubuntu). I've wrote bug report to google, but problem is still here (first time it was Android studio 2.2.3 and now it is 2.3).

For convenience: To disable Instant Run go to

File->Settings->Build, Execution, Deployment->Instant Run 

enter image description here

Upvotes: 42

Related Questions