Android app installation: Unknown failure (Failure

2019-02-03 02:24发布

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.

标签: android adb
4条回答
甜甜的少女心
2楼-- · 2019-02-03 02:39

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

查看更多
再贱就再见
3楼-- · 2019-02-03 02:39

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.

查看更多
Summer. ? 凉城
4楼-- · 2019-02-03 02:41

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

Settings > Additional Settings > Developer Options > MIUI Optimization

查看更多
叛逆
5楼-- · 2019-02-03 02:44

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.

查看更多
登录 后发表回答