问题
I am developing an Android app using Android Studio (0.89 Build #AI-135.1404660, Built on Sept 3,2014) using both emulator and Nexus 4 device.
I had the same issue with a version prior to that.
The problem is that after I changed my code and resource files, I still get the old apk installed on the device or emulator.
What do I need to do to get it to run current code? Is it a building config?
Is it a known issue with Android Studio?
Or with a Nexus 4 device?
This is the second time it has happened, and I resolved it(then) after trying one of the steps below. They have not worked for me again.
Here is what I've tried
- Build > Clean Project > Restart Android Studio > Run
- Build > Rebuild Project > Run
- Step 1 plus Uninstalling of apk on device
- Step 2 plus Unistalling of apk on device
- Adding erroneous resource entry then running.
I have read the following:
- Android apk install: How to clear files from old version?
- adb - How to reinstall an app, without retaining the data?
- Device still has the old apk
- Android build doesn't update code base or resources for target .apk on device
None has worked so far.
回答1:
I had the same problem. After trying numerous methods that didn't work, I realized that I had accidentally changed an option in my "Run Configuration". Here's exactly what I did to fix the issue.
- Run --> Edit Configurations
- With your configuration selected on the left panel (mine says "app"), in the General tab on the right panel, there is a section called "Before launch". This section should have an option added called "Gradle-aware Make", but I had accidentally removed it.
- I re-added it by pressing the "+", then clicking OK in the popup (leave the input box in the popup blank).
- Click apply.
This fixed the problem immediately. Hope this helps someone!
回答2:
Run / Debug Configurations / Miscellaneous TAB [] Uncheck: Skip installation if APK has not changed
Android Studio doesn't always detect small changes in code.
回答3:
The behaviour is erratic. I solved it by reviewing my code.It turned out that there was a resource file that was invalid. Try reverting back to the last working version of your code before the current changes... Probably a known issue that will be/was resolved out of Beta
回答4:
Google thinks it is a feature, not a bug
https://code.google.com/p/android/issues/detail?id=156263
Their proposed solution is to copy the apk(s) instead of manipulating the filename, as in e.g.
Copying APK file in Android Gradle project
回答5:
I was also facing this issue and get solution by deleting build folder manually because some time ide cannot be able to delete this. So go to the app folder and find build folder delete this and after clean and build project and run again. projectname->app->build
回答6:
You should select "Deploy default APK" option in Run/Debug Configurations. After that Android Studio will upload and install new apk to your emulator/device when you run application.
回答7:
In android studio. at right side. see gradle option. click it. and then press circular arrows button shown in red square.
回答8:
I've spent way too many hours to keep this to myself. The way I fixed it was that I noticed some hours later that I was using different layout version in res/ .... I have actually two versions of layout (layout-v26) and (layout). All this time I was modifying the other one and uploading different one. Maybe its just a newbie mistake but I hope somebody will find it useful.
The reason why there are 2 version was because of " autofillHints="" -> quickfix -> create new version of layout "
image of my tree
来源:https://stackoverflow.com/questions/25831082/android-studio-is-installing-old-apk-on-device