Yesterday my app was running perfect from Android Studio but today when I started working on my app and running it i am getting error message continuously

Installation failed with message Failed to establish session.

Screen :

enter image description here

On click OK getting error message

Session 'app':Error Installing APKs

And App is not exist(already Uninstalled) in device. Please suggest me what to do ?

Ответы (33)

Again in this issue also I found Instant Run buggy. When I disable the Instant run and run the app again App starts successfully installing in the Device without showing any error Window. I hope google will sort out these Issues with Instant run soon.

Steps to disable Instant Run from Android Studio:

File > Settings > Build,Execution,Deployment > Instant Run > Un-check (Enable Instant Run to hot swap code)

For me I had to close the emulator and then select cold boot when re-opening it.

Sometime app doesn't show on home screen,So Check your apps by going to setting - > apps -> and then uninstall from app setting might this work.

Your APK file is missing . So , Clean Project >> Build APK >> Run the project .

In my case Instant Run hided the real cause of the problem which was INSUFFICIENT_SPACE due to small data partition and I also got "failed to establish session" error. After disabling Instant Run, the real problem was revealed and after fixing it and enabling Instant Run it worked.

In my case, it was very a silly and funny mistake. I, accidentally without actually knowing, checked "Android Debug Bridge, Use libUsb backend". Actually it should stay unchecked..

In Mac Pro, Go Preferences - > Build, Execution,Deployment -> Debugger.enter image description here

Если вы используете MIUI ROM

Go to the developer option and in that disable MIUI optimization.You will be asked to reboot your phone. Reboot it and then run the app.

Easily can be solved this problem.

Ex:- in Huawei GR3 mobile,

Goto Setting in your mobile -> Storage -> Storage Cleaner

One problem in MAC(or may be other operating systems) can also be solved with this You need disable "Use libusb backend" in preferences--> debugger

enter image description here

Please tell others if this was useful for you. Thanks to the following user and their answer:

У меня была такая же проблема в MIUI. Включение OEM-разблокировки сработало у меня без отключения оптимизации MIUI.

Below is a screenshot of my Redmi 3s prime developer options setting:

screenshot of my Redmi 3s prime developer options setting

Change your applicationId in the android/app/build.gradle file.

For example:

// Change this
applicationId "com.example.myAndroidApp"
// to this
applicationId "com.example.somethingElse"

Then Sync your gradle then you can able to install your app, if the previous applicationId is your production id the again change it the previous one now the device will allow to install the app.

Hope this may help you....

I was using the in-built emulator and kept encountering this problem.

Починить это:

  • Go to: Run > Edit Configurations
  • Click your device in the dropdown near "Preferred Android Virtual Device" and press Shift + Enter
  • Close the config screen, and focus the new window with the AVDs.
  • On the emulator you use choose the menu option on the right, and choose "stop" and "wipe data".
  • For good measure: Build > Clean Project

Some of this might be unnecessary but I can't replicate the problem deliberately in order to trial a minimum amount of steps

For those who uses Xiaomi phones, follow these steps:

  1. Settings-> Additional Settings-> Developer options

  2. Turn off MIUI Optimization and reboot your phone

  3. Last Disable verify app over USB

Your device will respond properly.

Also enable install via USB

**** For MAC OSX/Windows ****

Goto *

Android Studio - Preferences (In OSX)

Android Studio - File -> Settings (In Windows)

  • in the menu bar then select

Build,Execution,Deployment - Instant run

  • затем снимите флажок и восстановите его, он будет работать

Finally I've SOLVED it!

Below a temporary solution. Issue was reported to Google.

First of all I found in Run log that Android Studion 2.3 tries to install app-debug.apk from many slices, like this:

$ adb install-multiple -r E:\Android_Projects\ActivityLifecycle\app\build\intermediates\split-apk\debug\slices\slice_1.apk E:\Android_Projects\ActivityLifecycle\app\build\intermediates\split-apk\debug\dep\dependencies.apk E:\Android_Projects\ActivityLifecycle\app\build\intermediates\split-apk\debug\slices\slice_0.apk E:\Android_Projects\ActivityLifecycle\app\build\intermediates\split-apk\debug\slices\slice_2.apk E:\Android_Projects\ActivityLifecycle\app\build\intermediates\split-apk\debug\slices\slice_9.apk E:\Android_Projects\ActivityLifecycle\app\build\intermediates\split-apk\debug\slices\slice_4.apk E:\Android_Projects\ActivityLifecycle\app\build\intermediates\split-apk\debug\slices\slice_3.apk E:\Android_Projects\ActivityLifecycle\app\build\intermediates\split-apk\debug\slices\slice_5.apk E:\Android_Projects\ActivityLifecycle\app\build\intermediates\split-apk\debug\slices\slice_8.apk E:\Android_Projects\ActivityLifecycle\app\build\intermediates\split-apk\debug\slices\slice_7.apk E:\Android_Projects\ActivityLifecycle\app\build\intermediates\split-apk\debug\slices\slice_6.apk E:\Android_Projects\ActivityLifecycle\app\build\outputs\apk\app-debug.apk

Then I tried to install only app-debug.apk from command line by:

adb install -d E:\Android_Projects\ActivityLifecycle\app\build\outputs\apk\app-debug.apk

App was installed successfully but was failed to run on my phone.

And finally:

  1. I recompiled app-debug.apk from command line as:

gradlew.bat assembleDebug

  1. Repeat installation of app-debug.apk from command line and became happy:

adb install -rd E:\Android_Projects\ActivityLifecycle\app\build\outputs\apk\app-debug.apk

This is definitely some gradle problem in AndroidStudio 2.3.

Go to USB Debugging and disable MIUI Inspection and allow the phone to reboot. Things should be fine from here

Try disabling the Instant run in Settings.

This is caused by "instant run" feature, you can disable it by:

Open the Settings or Preferences dialog. Navigate to Build, Execution, Deployment > Instant Run.

Uncheck the box next to Enable Instant Run and u are ready to go.

I had the same issue in Android studio 2.3 when I tried to test the app using Xiaomi's Mi5 and Mi4 phones. Disabling instant run didn't help me. So here is what I did.

Turn Off MIUI optimization in the Developer Options in the phone.

enter image description here
enter image description here

Then the device will be rebooted and then you'll be able to test the app over the phone.

Используя этот метод, вы все равно можете использовать опцию мгновенного запуска в студии Android. Так что это исправит вашу проблему, по крайней мере, временно. Надеюсь, что мы сможем использовать оптимизацию MIUI в ближайших обновлениях :)

Allow or enable "Installation from USB" in the developer options.

In my case, it was because my emulator ran out of disk space.

just close your emulator and run again the problem will be solved happy coding

In my own case, it was because my phone was out of space. For people that are facing this problem right now, if Clean Project + Build APKs does not work, check the available space on your phone or emulator.

I hope this helps.. Merry coding!

Go to Build --> Clean Project --> Run

Thats all it takes.

Just do the following step...

Build>Clean Project

после этого снова запустить проект, это сработало для меня

At me such error arose after renaming of a folder with the project.

Disabling Instance Run helped, but what if you do not need to disable it?

I deleted all the tags mentioning the old folder name from the file myproject\app\build\intermediates\restart-dex\debug\build-info.xml

The error has disappeared.

Here's my solution (there's no need to deactivate instant run) Do all these steps in the stated order:

1- Gradle Build (root level)


2 - Gradle build + clean (app level)

gradle app

3 - Choose app on the top bar (left of Run 'app')

4 - Clean Project:

Navigate to Build > Clean Project

And it should work now! You shouldn't disable instant run if you follow these steps

For those, who still having troubles with APK installing, just check your phone storage. In my case app failed to install always because I had not enough space to install the APK.

I found the solution go to

settings>build,execute,deployment>instant run>Enable instant run to hot swap code /resource change on deploy(unchecked this option)

This will work on 3.4 android studio too. thanks

Before trying anything else in this post, I would do Build >> Clean Project. It solved my problem and it is the simplest solution. Sometimes, the cleaning doesnt get some links, so I also recommend you to restart your devices, either virtual or physical.

Если не работает, попробуйте включить Instant Run by File> Settings> Build, Execution, Deployment> Instant Run> Un-check.

Only after trying this two simple solutions, I would try the others.

I also had the problem after globally changing the project name, applicationid and the folders containing the java files.

Disabling Instant run helped, but was not a good option, so this helped:

  • close Android Studio
  • deleted those files and folders: rm -Rf .gradle .tags .idea/workspace.xml .idea/caches/* .idea/libraries app/build
  • start Android Studio and let it resync everything
  • press run

Faced same issues on MIUI phone resolved by making MIUI account and enable install by USB.

·clean project——that's what I consider first, but not work

·disable instant run——no this option in latest version

· Отключить оптимизацию MIUI - я не использую эмулятор MIUI

·Build apk, gradle....——no no no

You know what? When I uninstall the app in my emulator, and run the code again, it works as immediately!

2022 WebDevInsider