Application Installation Failed in Android Studio

AndroidAndroid StudioInstallationApk

Android Problem Overview


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 ?

Android Solutions


Solution 1 - Android

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)

Solution 2 - Android

If you use 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.

Solution 3 - Android

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

Solution 4 - Android

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

Solution 5 - Android

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.

Using this method you can still use instant run option in android studio. So this will fix your problem at least temporary. Hope that we'll be able to use MIUI optimization in the near future updates :)

Solution 6 - Android

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

Solution 7 - Android

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

Solution 8 - Android

**** 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

  • then uncheck it and rebuild it will works

Solution 9 - Android

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.

Solution 10 - Android

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

Thats all it takes.

Solution 11 - Android

I had the same issue in MIUI. Enabling OEM unlocking worked for me without disabling MIUI optimization.

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

screenshot of my Redmi 3s prime developer options setting

Solution 12 - Android

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!

Solution 13 - Android

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

Solution 14 - Android

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....

Solution 15 - Android

Try disabling the Instant run in Settings.

Solution 16 - Android

Easily can be solved this problem.

Ex:- in Huawei GR3 mobile,

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

Solution 17 - Android

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.

Solution 18 - Android

> Just do the following step...

Build>Clean Project

after that Run project again, this worked for me

Solution 19 - Android

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 local.properties .idea/workspace.xml .idea/caches/* .idea/libraries app/build
  • start Android Studio and let it resync everything
  • press run

Solution 20 - Android

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

Solution 21 - Android

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.

Solution 22 - Android

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

Solution 23 - Android

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.

Solution 24 - Android

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)

gradle

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

Solution 25 - Android

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.

Solution 26 - Android

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

Solution 27 - Android

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: https://stackoverflow.com/a/58095554/3726185

Solution 28 - Android

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

Solution 29 - Android

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

Solution 30 - Android

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.

If it doesnt work out, try turning of Instant Run by File > Settings > Build,Execution,Deployment > Instant Run > Un-check

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

Solution 31 - Android

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

To fix it:

  • 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

Solution 32 - Android

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.

Solution 33 - Android

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

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

·turn off MIUI optimization——I don't use MIUI emulator

·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!

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKapil RajputView Question on Stackoverflow
Solution 1 - AndroidKapil RajputView Answer on Stackoverflow
Solution 2 - AndroidVivian DbrittoView Answer on Stackoverflow
Solution 3 - AndroidroyView Answer on Stackoverflow
Solution 4 - Androiduser7939485View Answer on Stackoverflow
Solution 5 - Androidthilina KjView Answer on Stackoverflow
Solution 6 - AndroidmliuView Answer on Stackoverflow
Solution 7 - AndroidFarruh HabibullaevView Answer on Stackoverflow
Solution 8 - AndroidMuhammed FasilView Answer on Stackoverflow
Solution 9 - AndroidBarbosSergosView Answer on Stackoverflow
Solution 10 - AndroidSarvesh ThiruppathiView Answer on Stackoverflow
Solution 11 - AndroidAyush ChaurasiaView Answer on Stackoverflow
Solution 12 - AndroidTaslim OseniView Answer on Stackoverflow
Solution 13 - AndroidRajneesh ShuklaView Answer on Stackoverflow
Solution 14 - AndroidJaganView Answer on Stackoverflow
Solution 15 - AndroidVictor CView Answer on Stackoverflow
Solution 16 - AndroidBIS TechView Answer on Stackoverflow
Solution 17 - AndroidVivekView Answer on Stackoverflow
Solution 18 - AndroidAtifSayingsView Answer on Stackoverflow
Solution 19 - Androidrubo77View Answer on Stackoverflow
Solution 20 - AndroidGautam DevView Answer on Stackoverflow
Solution 21 - AndroidPetr VaryaginView Answer on Stackoverflow
Solution 22 - AndroidharibabuView Answer on Stackoverflow
Solution 23 - AndroidNikhil SharmaView Answer on Stackoverflow
Solution 24 - AndroidGinggasView Answer on Stackoverflow
Solution 25 - AndroidAndreas OikonomouView Answer on Stackoverflow
Solution 26 - AndroidImam MustholihView Answer on Stackoverflow
Solution 27 - AndroidVivekView Answer on Stackoverflow
Solution 28 - AndroidHarish AnantharamanView Answer on Stackoverflow
Solution 29 - AndroidodiggityView Answer on Stackoverflow
Solution 30 - AndroidLeo PaimView Answer on Stackoverflow
Solution 31 - AndroidbraksView Answer on Stackoverflow
Solution 32 - AndroidOlolokingView Answer on Stackoverflow
Solution 33 - AndroidvainquitView Answer on Stackoverflow