Session 'app' error while installing APK

2019-01-13 01:21发布

问题:

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

回答1:

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.



回答2:

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



回答3:

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.



回答4:

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.



回答5:

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



回答6:

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

$./gradlew clean

In windows:

>gradlew.bat clean


回答7:

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.

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.



回答8:

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!



回答9:

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

File > invalidate caches/restart > invalidate and restart



回答10:

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

and then retry to Run your app.

Hope this help!



回答11:

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



回答12:

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



回答13:

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.



回答14:

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.



回答15:

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.



回答16:

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.



回答17:

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



回答18:

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.



回答19:

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]


回答20:

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



回答21:

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.



回答22:

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.



回答23:

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



回答24:

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



回答25:

terminal:

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

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

  • cd android && ./gradlew clean &&



回答26:

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)



回答27:

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.



回答28:

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.



回答29:

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



回答30:

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