Error installing application in Android Studio

Yesterday my application worked perfectly from Android Studio , but today, when I started working on my application and started it, I constantly get an error message

Installation error with message Failed to establish session.

Screen:

enter image description here

When you click OK, you receive an error message

Session app: APK installation error

And the application does not exist (already uninstalled) in the device. Please suggest me what to do?

+159
android android-studio installation apk
Mar 09 '17 at 5:41 on
source share
35 answers
  • one
  • 2

Again in this release, I also found that Instant Run contains bugs. When I turn off Instant Launch and run the application again, the application launches successfully on the device without displaying an error window. I hope that Google will solve these problems with Instant Launch in the near future.

Steps to disable instant launch from Android Studio:

File > Settings > Build, Run, Deploy > Instant Run > Uncheck (Enable Instant Run for hot swap code)

+342
Mar 09 '17 at 12:17
source share

If you are using MIUI ROM

Go to the developer option and turn off MIUI optimization. You will be prompted to restart the phone. Reboot it and then run the application.

+109
Mar 09 '17 at 11:01
source share

Missing APK file. So, Clear Project >> Create APK >> Run Project.

+50
Oct. 12 '17 at 16:43 on
source share

For those using Xiaomi phones, follow these steps:

  1. Settings-> Advanced Settings-> Developer Options

  2. Turn off MIUI Optimization and restart your phone

  3. Last disable app confirmation via USB

Your device will answer correctly.

Also enable installation via USB

+30
Sep 26 '17 at 5:38 on
source share

I had the same problem in Android 2.3 when I tried to test the application using Xiaomi Mi5 and Mi4 phones. Disabling instant start did not 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 reboot, and then you can test the application by phone.

Using this method, you can use the instant launch feature in Android studio. Thus, this will solve your problem at least temporarily. I hope that in the near future we will be able to optimize MIUI.

+20
Mar 28 '17 at 11:26
source share

In my case, this was because there was not enough disk space in my emulator.

+15
Nov 25 '18 at 14:59
source share

Finally I SOLVED it!

Below is a workaround . The question was sent to Google.

First of all, I found in the startup log that Android Studion 2.3 is trying to install app-debug.apk from many fragments, for example:

$ adb install-multiple -r E: \ Android_Projects \ ActivityLifecycle \ application \ assembly \ intermediate \ split APK \ Debug \ slices \ slice_1.apk E: \ Android_Projects \ ActivityLifecycle \ application \ build \ intermediate \ split APK \ Debug \ separate \ dependencies.apk E: \ Android_Projects \ ActivityLifecycle \ application \ assembly \ intermediate \ split APK \ Debug \ slices \ slice_0.apk E: \ Android_Projects \ ActivityLifecycle \ application \ build \ intermediate \ split APK \ Debug \ slices \ slice_2.apk E : \ Android_Projects \ ActivityLifecycle \ application \ assembly \ intermediate \ split APK \ Debug \ slices \ slice_9.apk E: \ Android_Projects \ ActivityLifecycle \ application \ build \ intermediate \ split APK \ Debug \ slice \ slice_4.apk E: \ Android_Projects \ ActivityLifecycle \ application \ assembly \ intermediate \ split APK \ Debug \ slices \ slice_3.apk E: \ Android_Projects \ ActivityLifecycle \ application \ assembly \ intermediate \ split APK \ Debug \ slices \ slice_5.apk E: \ Android_Projects \ ActivityLifecycle \ application \ assembly \ intermediate \ split APK \ Debug \ slices \ slice_8.apk E: \ Android_Projects \ ActivityLifecycle \ application \ assembly \ intermediate \ split APK \ Debug \ slices \ slice_7.apk E: \ Android_Projects \ ActivityLifecycle \ application \ assembly \ intermediate \ split APK \ Debug \ slices \ slice_6.apk E: \ Android_Projects \ ActivityLifecycle \ application \ assemblies \ outputs \ APK \ debug.apk application

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

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

The application was successfully installed, but was not executed on my phone.

And finally:

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

gradlew.bat assembleDebug

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

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

This is definitely a gradle problem in AndroidStudio 2.3 .

+8
Mar 09 '17 at 8:25
source share

Go to Build -> Clean Project -> Run

That’s all you need.

+8
Dec 30 '18 at 10:38
source share

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

Go to *

Android Studio - Settings (on OSX)

Android Studio - File → Settings (on Windows)

  • in the menu bar then select

Build, Run, Deploy - Instant Launch

  • then uncheck and restore
+8
Apr 02 '19 at 2:23
source share

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

Below is a screenshot of how to configure the main parameters of the Redmi 3s developer:

screenshot of my Redmi 3s prime developer options setting

+6
Jul 26 '17 at 14:06
source share

Have the same problem on Xiaomi Redmi 4X. Allowed it by disabling MIUI optimization in the phone settings.

+6
Aug 29 '17 at 15:02
source share

Take the next step ...

Assembly> Clean Project

then run the project again, it worked for me

+5
Aug 31 '17 at 13:10
source share

In my case, it was because there was no place in my phone. For people who are facing this problem right now, if the Clean Project + Build APK does not work, check the available space on your phone or emulator.

I hope this helps .. Fun coding!

+5
Jan 04 '19 at 15:38
source share

Change applicationId to android/app/build.gradle file.

For example:

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

Then synchronize your gradle, and you can install your application, if the previous applicationId is your working identifier, then change it to the previous one again, now the device will allow you to install the application.

Hope this can help you ....

+4
Mar 09 '17 at 6:16
source share

Try disabling instant start in settings.

+4
Mar 15 '17 at 18:41
source share

In my case, it was a very stupid and funny mistake. I accidentally, without even suspecting it, checked "Android Debug Bridge, use the libUsb library". In fact, this should remain without control ..

In Mac Pro, go to Settings → Build, Run, Deploy → Debugger. enter image description here

+4
Oct. 15 '18 at 18:50
source share

This problem can be easily solved.

Example: - in a mobile phone Huawei GR3,

Go to setup in your mobile phone → Storage → Storage cleaner

+4
Jan 15 '19 at 16:35
source share

I found a solution to 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. thank

+4
Jun 04 '19 at 11:30
source share

This is caused by the “instant start” function, you can disable it:

Open the Preferences or Preferences dialog box. Go to build, run, deploy> Instant Run.

Uncheck the box next to Enable Instant Launch and Finish.

+3
May 2 '17 at 5:54
source share

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

Disabling instant start helped, but was not a good option, so it helped:

  • close Android Studio
  • deleted these files and folders: rm -Rf.gradle.tags local.properties.idea/workspace.xml.idea/caches/*.idea/libraries app/build
  • launch Android Studio and let it sync everything
  • press run
+3
May 18 '19 at 19:52
source share

Faced with the same problems on the MIUI phone, resolved by creating an MIUI account and enabling the installation via USB.

+2
Mar 09 '17 at 6:04 on
source share

I got this error after renaming the project folder.

Disabling instance startup helped, but what if you don't need to disable it?

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

The error has disappeared.

+2
Jul 30 '17 at 12:08
source share

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

+2
Aug 04 '17 at 13:35 on
source share

Sometimes the application does not appear on the main screen, so check your applications by going to settings → apps →, and then delete the application settings, maybe this will work.

+1
Mar 09 '17 at 5:57
source share

Here is my solution (there is no need to deactivate instant start). All these steps are in the order shown:

1- Gradle Assembly (root level)

gradle

2 - Gradle build + clean (application level)

gradle application

3 - Select the application on the top panel (to the left of the "Run" button)

4 - Clean project:

Go to Build> Clean Project

And he should work now! You should not disable instant start if you follow these steps.

+1
Jul 17 '17 at 11:01
source share

In my case, Instant Run hid the real cause of the problem, which was INSUFFICIENT_SPACE due to the small data section, and I also got the error “session failed to establish”. After disabling Instant Run, a real problem was discovered, and after fixing it and turning on Instant Run, it worked.

+1
Aug 14 '17 at 21:57
source share

Allow or enable "Install from USB" in the developer’s settings.

+1
Sep 01 '17 at 17:36 on
source share

Make sure your application is completely removed from the device, check settings> applications. Several times ap does not show you in the application, but still in the system, if the application is there, you must delete it there, then check.

0
Mar 09 '17 at 6:34
source share

Go to USB Debugging and turn off MIUI Inspection and let the phone reboot. It should be good here.

0
Jul 02 '17 at 16:39
source share

For me, I had to close the emulator and then select the cold boot when it was opened again.

0
May 03 '19 at
source share
  • one
  • 2



All Articles