68

Trying to install app on real device following instructions:- http://developer.android.com/tools/device.html. At end Android Studio giving error:

Session 'app': Error Installing APK 

I guess the problem probably can be in my android device(it is chinese Doogee X5). It does not have a given USB Vendor ID in developer docs so I decided to follow instructions with random vendor ID from HTC.

I'm sure there is a way to run application on any android device, but yet I didn't find an answer on how to do that.

I'm running through Linux Ubuntu 14.04 LTS

Shirish Herwade
  • 11,461
  • 20
  • 72
  • 111
Stanislav Barabanov
  • 879
  • 1
  • 8
  • 13
  • Have you enabled Debugging mode and Installation from unknown sources in your mobile Settings? You can simple generate a signed apk and them install it on your mobile or else use a Android AVD manager to create a virtual device. – Basu May 03 '16 at 21:56
  • Of course I enabled Debugging mode and installation from unknown sources on my device. AVD is working properly but I don't need AVD in this case – Stanislav Barabanov May 03 '16 at 21:58

29 Answers29

87

Edit:

In newer Android Studio versions you can re-sync the project using this button:

enter image description here

For older versions:

Open Gradle window (on the right side in Android Studio) and click on the refresh button.

However it is not a 100% sure fix.

Solutions for other cases:

Open terminal window and type "adb kill-server", then type "adb start-server". Usually after a few hours of inactivity, adb used to disconnect the device. (If you don't have the sdk/platform-tools in the PATH environment variable, then you should open a terminal in that folder)

One tip if these solutions don't help you: If you open the Event Log window in the right bottom corner of Android Studio, you can see a detailed error message.

Other edge case If you see this error: INSTALL_FAILED_INVALID_APK:... signatures are inconsistent. Then unfortunately a gradle refresh isn't enough, you have to go to Build -> Clean Project and then Run again.

Issue with Android emulator If you want to deploy the APK to an Android Emulator and you see the "Error installing APK" message, your emulator may be frozen and need restart.

Andras Kloczl
  • 8,415
  • 2
  • 21
  • 23
54

Turning off the Instant run removed my error for Androdi Studio 2017.03.03 v2.3

enter image description here

Zero
  • 2,764
  • 1
  • 17
  • 20
  • 2
    Using latest Android Studio (v2.3), suddenly stopped working and I had that annoying issue. I lost 3 days of my spare time to make it work and finally what you suggested did the trick. – joninx Mar 08 '17 at 18:48
  • Thank you man..you just saved me couple of more hours work to find out the problem. – MBH Mar 21 '17 at 07:45
  • 1
    Windows 10 with Android Studio 2.3 : To open this window, File => Settings, in the left pane Build, Execution, Deployment => Instant Run – Saravanan Sachi Jun 21 '17 at 13:15
  • 1
    I'm using Xioami Mi4 and this solution works for me. But when I try it on Asus Zenfone 2, it is not necessary to disable "Instant Run". Also, you need to enable "Install via USB" in the developer options if you use Xiaomi. – Alperen Jan 17 '18 at 05:59
12

You have to enable Developer options and enable USB Debugging:

  1. Go to the settings menu, and scroll down to "About phone." Tap it.
  2. Scroll down to the bottom again, where you see "Build number." (Your build number may vary from ours here.)
  3. Tap it seven (7) times. After the third tap, you'll see a playful dialog that says you're four taps away from being a developer. (If only it were that simple, eh?) Keep on tapping, and poof, you've got the developer settings back.

http://www.androidcentral.com/how-enable-developer-settings-android-42

Inside Developer Options, enable USB Debugging

enter image description here

Jorgesys
  • 124,308
  • 23
  • 334
  • 268
8

Try using a different version of Gradle(stable version). To summarize:

  • Check your gradle file for debuggable false/true
  • Invalidate caches & restart
  • Check your install location
  • Restart adb
Anatoly
  • 112
  • 4
8

I fix this by delete the build folder then run project again

enter image description here

Linh
  • 57,942
  • 23
  • 262
  • 279
7

Make sure that your device is not out of Memory!

Tripathee Gaurav
  • 371
  • 3
  • 11
3

I changed my USB port and that fixed it for me.

Zach Wymer
  • 540
  • 9
  • 11
2

Make sure that project name doesn't contain special character.

2

Another possibility may be the USB driver on your PC. In my case, switching from my 3.0 USB port to my 2.0 port fixed the problem.

Paul Weber
  • 21
  • 3
2

Ensure you android device has enough memory to install the app. Sometimes it so happens working with multimedia app where the device storage keeps on increasing and you keep wondering about the error.

Therefore, free up some memory and try installing again!

Adil B
  • 14,635
  • 11
  • 60
  • 78
1

A bit late to the party, but be sure that you are trying to build a proper build variant. It sometimes happens to me that when I update AS, the build variants are totally messed up, so instead of building the "debug" variant I am actually building the "release" variant, which outputs apk to a different location (not to app/build directory, but to app directly) and I get the following error:

The APK file /path/to/file/app.apk does not exist on disk.
Error while Installing APK

To fix this just open the menu in left bottom corner, click on "Build Variants" and select the debug variant (it might have a different name, depending on how many modules/flavors or custom gradle build types you have).

vanomart
  • 1,739
  • 1
  • 18
  • 39
1

Try to remove the .idea folder and .gradle folder, then click Sync Project with Gradle Files, when the process finished, try to run app again.

Hope it works.

Kapil Rajput
  • 11,429
  • 9
  • 50
  • 65
1

just press Build button from menu bar and then press build app wait for it finished then press build APK and then run your emulator, it will work

1

Usage of easily changing variable value will often happen in build.gradle(like the Date)

enter image description here

byJeevan
  • 3,728
  • 3
  • 37
  • 60
chany
  • 11
  • 1
1

In my case with Android 8.0(Oreo), no one of this solutions worked! If you have more than 1 user, then you should go to Settings->Applications->All Applications->Find the application and uninstall for all users! After this steps, it worked!

Shahen Kosyan
  • 124
  • 1
  • 5
1

Just rebuild and clean project, then run project.

Houssin Boulla
  • 2,687
  • 1
  • 16
  • 22
1

This happens because the gradle is not synced with the app. Go to : Tools -> Android -> Sync Project with Gradle files. Re-run and you should be good to go.

1

Nothing above helped me. The fingerprint dialog did not appear. I checked another android device and the dialog appeared and debug was possible. So the problem was on device side not on computer side I made reset "to factory settings" on device and this helped me.

0x000f
  • 1,700
  • 1
  • 13
  • 8
1

I fixed my issue, simply by using :

Build->Clean Project

then

Build->Rebuild Project

1

I had this same issue and none of the other solutions worked for me.

Although no errors were shown nor expanded upon in my IDE GUI, I opened up a second Android Studio window window with a different project and noticed in the bottom that the "Event Log" showed an error in a different window, but not in the project I had opened. The issue stated was:

Error: INSTALL_FAILED_CONFLICTING_PROVIDER

Which lead me here - Install shows error in console: INSTALL FAILED CONFLICTING PROVIDER :

I had this FileProvider labeled in the manifest:

<provider
    android:name="androidx.core.content.FileProvider"
    android:authorities="myapp.sameonehere.android.fileprovider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/file_paths" />
</provider>

Which I had copied from another project and forgotten to rename the 'authorities' String in. After changing it to something unique, it ran without issue.

Make sure you don't have any conflicting authority Strings like in my example.

Also, if no errors are showing up, try opening a second project and see if the "Event Log" shows errors in that location instead.

PGMacDesign
  • 6,092
  • 8
  • 41
  • 78
1

Uninstall the app, and re-install and it should work!

Karan Khurana
  • 575
  • 8
  • 20
0

Go to avd manager and click on Wipe Data of the device you want to run. Worked for me. The size of device on disk will reduce after wiping the data. I hope it helps someone.

Fidan Gill
  • 63
  • 7
0

You have to enable Developer options and enable USB Debugging:

1:Go to the settings menu, and scroll down to "About phone." Tap it. 2:Scroll down to the bottom again, where you see "Build number." (Your build number may vary from ours here.) Tap it seven (7) times. After the third tap, you'll see a playful dialog that says you're four taps away from being a developer. Keep on tapping, and poof, you've got the developer settings back.

Usman Ali
  • 425
  • 1
  • 9
  • 31
0

My issue was solved by Clean --> ReBuild --> Run and in my case it was because i accidentally deleted the project folder and when i clicked ctrl+z to restore something wrong happened.

Zeyad
  • 537
  • 2
  • 7
  • 15
0

My problem was that I didn't accept the connection from the computer after turning on remote debugging. Once I accept the mac address, it went away. Silly mistake, but I didn't see the dialog box the first time. Worth a quick check if the others don't resolve the issue. But likely only a problem the first time you set up a phone.

brocky34
  • 168
  • 1
  • 11
0

What worked for me is deleting the app from the emulator (which was an app built from an older commit) and re-running from Android Studio.

mt0s
  • 5,781
  • 10
  • 42
  • 53
0

It was written above: in my case it was just out of memory on device storage. Add more empty space - and error will disappear

Eugene Voronoy
  • 1,384
  • 1
  • 14
  • 18
0

I tried invalidating cache, deleting build folder and gradle sync. Also, I couldn't uninstall because the app is not visible on device. So I tried uninstalling through ADB and it worked.

adb uninstall <package_name>
mihirjoshi
  • 12,161
  • 7
  • 47
  • 78
-1

If you are using android emulator, try changing a device.

loick
  • 27
  • 2