[android] Application Installation Failed in Android Studio

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 ?

This question is related to android android-studio installation apk

The answer is


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 :)


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

Thats all it takes.


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

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


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.


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


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


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


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


Easily can be solved this problem.

Ex:- in Huawei GR3 mobile,

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


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.


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


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


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!


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


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


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


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.


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


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


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


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.


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

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


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.


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


Try disabling the Instant run in Settings.


Your APK file is missing . So , Clean Project >> Build APK >> Run the 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.


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.


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.


Just do the following step...

Build>Clean Project

after that Run project again, this worked for me


Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to android-studio

A failure occurred while executing com.android.build.gradle.internal.tasks "Failed to install the following Android SDK packages as some licences have not been accepted" error Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util This version of Android Studio cannot open this project, please retry with Android Studio 3.4 or newer WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()' Flutter plugin not installed error;. When running flutter doctor ADB.exe is obsolete and has serious performance problems Android design support library for API 28 (P) not working Flutter command not found How to find the path of Flutter SDK

Examples related to installation

You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory. (mac user) Conda version pip install -r requirements.txt --target ./lib How to avoid the "Windows Defender SmartScreen prevented an unrecognized app from starting warning" PackagesNotFoundError: The following packages are not available from current channels: Tensorflow import error: No module named 'tensorflow' Downgrade npm to an older version Create Setup/MSI installer in Visual Studio 2017 how to install tensorflow on anaconda python 3.6 Application Installation Failed in Android Studio How to install pip for Python 3.6 on Ubuntu 16.10?

Examples related to apk

Application Installation Failed in Android Studio Difference between signature versions - V1 (Jar Signature) and V2 (Full APK Signature) while generating a signed APK in Android Studio? Session 'app': Error Installing APK Android Error Building Signed APK: keystore.jks not found for signing config 'externalOverride' Build and Install unsigned apk on device without the development server? The APK file does not exist on disk Android Studio: Application Installation Failed How to retrieve Key Alias and Key Password for signed APK in android studio(migrated from Eclipse) ADB Install Fails With INSTALL_FAILED_TEST_ONLY Upload failed You need to use a different version code for your APK because you already have one with version code 2