Reputation: 8036
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
I have read the following:
None has worked so far.
Upvotes: 24
Views: 20581
Reputation: 31
Then I removed this configuration(the name can be different)
And then I added it again by clicking on this button
Upvotes: 0
Reputation: 41
The problem occurred on my Android 11 devices. I guess ART ran old code dex2oated.
Solution:
On Android Studio Topbar click on Run/Debug Configurations dropdown menu -> Edit Configurations.. -> General tab. Under Installation Options you will find Always install with package manager
(disable deploy optimization on Android 11 and later) option.
Check the option and press OK to apply.
Upvotes: 4
Reputation: 4062
I did "Clear Cache" in App settings and then it launched properly
Upvotes: 0
Reputation: 1058
My devices also ran old states - dont know from where in my git it has taken these.
I created a new configuration (default is "app") and it worked.
Upvotes: 0
Reputation: 156
The solution to this issue is actually very simple. Android studio is actually not detecting some small changes that you have made to the application. That is why it is installing the previous builds. The solution is easy -> Remove the previous builds.
In the right side, go to gradle tab.
Then File> Invalidate cache and restart.
Enjoy!! Your problem is solved...
Upvotes: 0
Reputation: 641
Same problem, none of the solutions mentioned here had any effect. I had to disable the "Allow parallel run" in "Menu > Run > Edit configurations...".
You can read more about this option here: How to run the same project multiple times in IntelliJ IDEA?
Upvotes: 0
Reputation: 140
Check Your Layout Files.
I ran into the same problem and I realized, it gives some problem if you have same layout in multiple orientations(portrait and landscape). If one is changed other remains unchanged and then it creates a conflict. So android studio installs the one with the previous layout
PS: This was happening in my case.
Upvotes: 1
Reputation: 11
I am using android studio for building flutter app, I was facing the same issue untill I did the following:
It resolved my problem as of now.
Upvotes: 1
Reputation: 111
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 "
Upvotes: 1
Reputation: 1529
In android studio. at right side. see gradle option. click it. and then press circular arrows button shown in red square.
Upvotes: 0
Reputation: 381
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
Upvotes: 1
Reputation: 89
Run / Debug Configurations / Miscellaneous TAB [] Uncheck: Skip installation if APK has not changed
Android Studio doesn't always detect small changes in code.
Upvotes: 7
Reputation: 301
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.
This fixed the problem immediately. Hope this helps someone!
Upvotes: 30
Reputation: 8036
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
Upvotes: 2
Reputation: 1
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.
Upvotes: 0
Reputation: 1035
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
Upvotes: 0