22

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

  1. Build > Clean Project > Restart Android Studio > Run
  2. Build > Rebuild Project > Run
  3. Step 1 plus Uninstalling of apk on device
  4. Step 2 plus Unistalling of apk on device
  5. Adding erroneous resource entry then running.

I have read the following:

  1. Android apk install: How to clear files from old version?
  2. adb - How to reinstall an app, without retaining the data?
  3. Device still has the old apk
  4. Android build doesn't update code base or resources for target .apk on device

None has worked so far.

Community
  • 1
  • 1
tinonetic
  • 7,751
  • 11
  • 54
  • 79
  • I'm seeing this in 1 RC2, did you find anything on this? –  Nov 29 '14 at 22:35
  • @jmcdonnell40, 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 resolved out of Beta – tinonetic Dec 01 '14 at 05:58

14 Answers14

29

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.

  1. Run --> Edit Configurations
  2. 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.
  3. I re-added it by pressing the "+", then clicking OK in the popup (leave the input box in the popup blank).
  4. Click apply.

This fixed the problem immediately. Hope this helps someone!

JamesD
  • 291
  • 3
  • 3
7

Run / Debug Configurations / Miscellaneous TAB [] Uncheck: Skip installation if APK has not changed

Android Studio doesn't always detect small changes in code.

David
  • 89
  • 1
  • 1
  • Like it is for others, this is sporadic for me (and wow does it foul up yr iterations) David's solution both conforms to the behaviour I see(AS says project unchanged in the Run window, and gets /real/ confused when I uninstall the app) plus seems to be working for a day now. Using: Dagger, data binding, and rxJava; I think the rebuild-to-refresh was working so well for me b/c of the large number of generated classes – anthropic android Jul 28 '16 at 01:20
  • this didn't work for me unfortunately. Changes are requiring two deployments to appear on the emulator. – ether_joe Sep 18 '17 at 07:01
2

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

tinonetic
  • 7,751
  • 11
  • 54
  • 79
  • Still happening for me (Feb 2017). I booted up an emulator and then it showed me the error. Fixing the error solved the issue. Weird! – MSpeed Feb 02 '17 at 19:23
2

The problem occurred on my Android 11 devices. I guess ART ran old code dex2oated.

Solution:

Run / Debug Configurations - General - Always install with package manager (disable deploy optimization on Android 11 and later), and check the option.

Xhy
  • 21
  • 2
1

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

Community
  • 1
  • 1
mir
  • 371
  • 2
  • 5
1

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

Peter
  • 51
  • 4
1

I am using android studio for building flutter app, I was facing the same issue untill I did the following:

  1. From Android Studio, go to Tools-Flutter-FlutterClean

It resolved my problem as of now.

1

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.

Zuckjet
  • 807
  • 1
  • 10
  • 19
ribhu69
  • 141
  • 1
  • 6
0

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

Rakesh
  • 1,035
  • 1
  • 14
  • 31
0

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.

0

In android studio. at right side. see gradle option. click it. and then press circular arrows button shown in red square.

In android studio. at right side. see gradle option. click it. and then press circular arrows buttons shown in red square.

Community
  • 1
  • 1
mehmoodnisar125
  • 1,469
  • 18
  • 14
0

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?

anemomylos
  • 546
  • 1
  • 6
  • 14
0

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.

  1. Expand Tasks. Find "clean" or "cleanCache" task or any task that starts with "clean". Double click to run that task.
  2. Expand "app". and do the same.

Then File> Invalidate cache and restart.

Enjoy!! Your problem is solved...

enter image description here

0

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.

Cactusroot
  • 1,019
  • 3
  • 16