[android] Session 'app' error while installing APK

I am having difficulty importing a project written on Android Studio 1.1 into Android Studio 2.1.2. I keep getting this error whenever the gradle is building before testing the app on a tablet. Below is a screen shot of the error. Does anyone know what the problem could be?

I have tried adb kill-server followed by adb start-server as well as some other gradle versions compatible with the project. Other than this, I have not been able to find many more suggested solutions to the problem ("session 'app': error installing APK").

Additionally, I have tried uploading a basic Hello World project which successfully built the gradle.

Error message from Grable Build

Initial Error Message

Second set of Errors

This question is related to android android-studio-2.1

The answer is


This issue seems to be bug in Android Studio.

I tried all other workarounds but the issue was appearing randomly.

I also have custom named apk for output. But Android studio was randomly picking custom apk name and default apk name.

Adding Gradle-aware Make solved the issue.

Following are the steps.

  1. Menu Run -> Edit Configuration

  2. Select "app" configuration

  3. Add Gradle-aware Make to Before Launch actions

You are done.

enter image description here

enter image description here

enter image description here

Following article helped me in finding the solution https://android.jlelse.eu/android-studio-3-1-how-to-fix-it-b49f72eb054f


terminal:

  • deleting "build and gradle" folders under project/android

  • cd android && ./gradlew clean && cd .. && react-native run-android

  • cd android && ./gradlew clean &&


In my case, going to Settings>Build, Execution, Development>Compiler>Command-line options and removing the --dry-run flag fixed it for me. Not sure why that was there in the first place, but it solved it for me.

image


Odd reasoning for me - I had deleted the project and pulled from repo. Because of this, the build/ files were missing.


Best step to resolve this error is- Uncheck the instant run in File >Settings >Build,Execution,Deployment > Instant Run


None of the above worked for me, the simplest solution was to go to

File > invalidate caches/restart > invalidate and restart

enter image description here


You just need to restart your adb. Instruction for that is given in this Link


your device can be the problem too

'cmd package install-create -r -t --full  -S 85640035' returns error 'Unknown failure: Exception occurred while executing:
        android.os.ParcelableException: java.io.IOException: Requested internal only, but not enough space
        at android.util.ExceptionUtils.wrap(ExceptionUtils.java:34)

when there is not enough storage


Try this: 1) Clean project 2) Rebuild project 3) Turn off Antivirus 4) Run App


Turning off the instant run(File >>Settings >>Build,Execution,Deployment >> Instant Run), solved my issue


I was facing same problem.Tried every think mentioned here in blog.

But it was basic error to permit device "allow installing app from USB" which did it for me.


In my case, my project location contained the special character.

E:\Android_Projects\T&PUIET,KUK\app\build\outputs\apk\app-debug.apk

close android studio > rename folder containing the special character(here T&PUIET,KUK ) > restart android studio.

Hope this Solution helps!


I was facing similar kind of problem.There is image of error attached.Error is highlighted in red. Turning off the Instant run removed error for Android Studio 2.3 and 3.1.4.

Error, after running the app Turning off the Instant run


I had similar problem. In my device I have two accounts and the app was remained installed in another account. I have deleted app from both of the accounts and it was done.


i was also getting the same error repeatedly but could not solve it as i am complete new to android development. But then it came to my mind that the error is appearing because its not able to install the apk in the device as the error says. So i make sure that my Oneplus3 is in debugging mode and also allowing file transfer when connected via USB. And this solved the problem.

Also previously it was not doing the instant run but now it does.

So check whether your android device is allowed to transfer files while connected via USB. This might help.


This error happens due to Gradle not synced with the project. go to Tools- Android- Sync Project with Gradle files. Then Run it again. On newer Android Studio versions, go to File-> Sync project with gradle files


If your device is listed, but shown as "OFFLINE", yet no popup to accept USB debugging has occured on the phone: Disconnect/reconnect USB cable, and the popup may show.

Probably this is a common cause, it's mentioned by others, but not in simplest terms.


Try to this way :

1) In Instance Run is Enable then desable it. 2) Save it and Rebuild the project. 3) Check devices is online or USB debugging On your device. 4) Then Run It App On your devices.

Note :

If you use mobile device is MI (Xiaomi) Then Check : => setting>Additional setting> Developer options> Install via USB (ON it) => setting>Additional setting> Developer options> USB debugging (ON it) => setting>Additional setting> Developer options> Verify apps over USB (ON/Off it)


You can clean your project with gradle wrapper of your project. In linux:

$./gradlew clean

In windows:

>gradlew.bat clean

Note: The top answers recommend to disable Instant Run. Try this before exploring my listed solutions to prevent wasting more time than needed.

Here are some possible solutions:

1) Make sure that your phone is properly connected to your PC with a USB cable: Before going over these fixes, make sure that you have at least connected your phone to your computer properly. If it's properly connected, your phone should be charging.

2) Make sure that your device's driver software is up-to-date: Simply go to your File Explorer and then right click Computer. Then, select Manage (requires administrator privileges). In your Computer Management window, find a tab on the left pane that says Device or Device Manager. Search for your device from there. Mine was under Portable Devices and the name started with SAMSUNG, so finding your device shouldn't be too hard. Right click the device, and then select Update Driver Software.... I chose the Search automatically for updated driver software option, since it's much easier.

3) Enable USB debugging under your Developer Options: For my Samsung Galaxy S9, I found mine under Settings > Developer Options. From there, enable USB Debugging. If you can't find your Developer Options, find your build number within the settings and tap it 7 times consecutively. I found mine under Settings > About Phone > Software information.

4) Make sure you've allowed USB debugging for your specific computer: Although you may have your USB Debugging option enabled, you still need to allow USB debugging for your specific computer. A popup should appear asking Allow USB debugging? and providing the computer's RSA key fingerprint. Before pressing OK, make sure your check Always allow from this computer, so that you don't have to go through this again in the future. If you think you've done this but yet your device is still marked as OFFLINE, select the Revoke USB debugging authorization option in 'Developer Options'. Then, re-allow your computer for USB Debugging. If the popup doesn't appear, reconnect your phone to the Computer (pull the cable out and put it back into your Phone).

5) Trying cleaning AND rebuilding your project: In Android Studio, open up the Build tab at the top left and try both the Clean and Rebuild options.

If none of the above works out: Reinstall Android Studio by Uninstalling the program and re-downloading the setup file here. Scan for any viruses that may be affecting your computer. Check for any sort of error while reinstalling Android Studio. If none of the methods presented in this answer work, fetch for support here.

Good luck.


Revoke USB debugging authorizations and then disable USB debugging on your mobile. Re-enable USB debugging, then connect to the USB port. It will ask USB debugging permission for the specific computer. Select "Always allow from this computer", then press OK. This worked for me.


Clean and Rebuild is working fine for this problem and it is good also than other solutions.


Follow this steps to overcome the issue.

  1. Disconnect all devices connected to System/Close all emulators running on System.
  2. Turn Off Instant Run feature from settings.
  3. Perform a clean build.
  4. Turn ON Instant Run feature from settings.
  5. Perform a clean build.
  6. Connect your device/start your Emulator and ensure it is online.
  7. Run the Project by selecting the device/emulator.

NOTE:-

1) You should not have different instances of Android Debug Bridge(adb) running on system.

2) If using Genymotion then make sure that you use the custom sdk path mentioned in the Genymotion settings the which you mentioned in the settings of Android Studio.

Follow all the steps and I am sure you will get the issue fix.


After trying the different solutions from the different answers, I tried changing the USB debugging cable, and the problem resolved finally.


I could install app on Nexus, but couldn't on Samsung. Nothing helped me except the change of the USB cable.


Very Simple. Follow this :

Build -> Clean Project

Then

Build -> Rebuild Project.


In my case my device didn't have enough memory. After trying out a number of the suggestions here, I finally noticed the notification on my phone about low memory. The notification had been there for hours apparently.


This problem occurs when you copy paste class and didn't change package name. Means Package name are different. Build has no problem to build but its problem to install.


It's a bit late for reply but, i've figured out how to solve this problem on Android Studio 3.1.

You can have "Instant Run" checked, what you need to do it's just to build an APK

enter image description here

and then retry to Run your app.

Hope this help!


I was using CyanogenMod 12.1 and was building with libgdx when I met with the same error. Rebuilding didn't work for me. My phone was connected as UMS or USB mass storage to my PC when I ran the app. Just changed the USB configuration from mass storage to MTP and it fixed my problem.


This is a terrible problem, i have facing it so much time, First of all when you run on emulator or real device please make sure that it is not show device is offline in Android monitor, see picture below due to bad cable connection device is showing offline, so make sure first that it is online.

enter image description here

If it's Okay then clean your project and Rebuild your project. You can do it from Build -> clean project / Build-> Rebuild project

Still problem occurs then try to Restart android studio. This is generous error happens due to above cases.But i solve it this way as described.


Look at screenshot

Here is gradle console updates:

5:01 PM Gradle build finished in 1s 252ms

5:13 PM Executing tasks: [:app:assembleDebug]

5:13 PM Gradle build finished with 15 error(s) in 1s 125ms

5:15 PM Executing tasks: [:app:assembleDebug]

5:15 PM Gradle build finished with 13 error(s) in 1s 608ms

5:16 PM Executing tasks: [:app:assembleDebug]

Trying cleaning AND rebuilding your project: In Android Studio, open up the Build tab at the top left and try both the Clean and Rebuild options.


Looking at the error message, Android Studio tried to install older version of apk (lets say 0.5.1) while current version is lets say 0.5.2. Android Studio builds 0.5.2 but tries to install 0.5.1 for some reason.

I have turned off Instant Run, invalidated and restarted, rebuilt project and didn't help.

Solution worked for me is to uninstall the app, then change the current branch on VCS to some other branch. Then come again to latest branch and Rebuilt, Install the APK again.


mi users if you are facing this type of issue follow these steps:

Step 1 : generate developer options as follow Settings>>About Device>>Click 7 times on MIUI Version>> It will Generate Developer Options.

Now Enable Following...

Step 2: Setting>Additional setting> Developer options> Enable USB Debugging

Step 3: Setting>Additional setting> Developer options> Enable Install via USB Note: Its Will get Enable Only If You Insert SIM In MI Device/Phone.

Step 4: Setting>Additional setting> Developer options> Enable Verify apps over USB.

all done now run the project and test....


non mi user:

just enable once instant run options from the settings--> Build,Execution, Deployment-->Select Instant Run and Enable Check Click On OK...

Its Will Work....


I was able to resolve it simply by opening the notification bar of the android phone , clicking on "tap for more options" and selecting PTP