Reputation: 1699
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
Reputation: 952
For Redmi and Mi devices turn off MIUI Optimization and reboot your phone.
Settings > Developer Options > MIUI Optimization
Upvotes: 61
Reputation: 1207
I solved my problem by following the steps bellow
After following the steps I run from android studio and it was installed my app successfully.
Upvotes: 1
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
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
Upvotes: 42