可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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
回答1:
tldr;
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.
回答2:
Turning off the Instant run removed my error for Androdi Studio 2017.03.03 v2.3
回答3:
You have to enable Developer options and enable USB Debugging:
- Go to the settings menu, and scroll down to "About phone." Tap it.
- 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. (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
回答4:
I fix this by delete the build folder then run project again
回答5:
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
回答6:
Make sure that your device is not out of Memory!
回答7:
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.
回答8:
I changed my USB port and that fixed it for me.
回答9:
Make sure that project name doesn't contain special character.
回答10:
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).
回答11:
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.
回答12:
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
回答13:
Usage of easily changing variable value will often happen in build.gradle
(like the Date)
回答14:
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!
回答15:
Just rebuild and clean project, then run project.
回答16:
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.
回答17:
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.
回答18:
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!
回答19:
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.
回答20:
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.
回答21:
If you are using android emulator, try changing a device.