Android Studio is installing old apk on device
Asked Answered
L

16

24

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.

Lao answered 14/9, 2014 at 7:33 Comment(2)
I'm seeing this in 1 RC2, did you find anything on this?Dissert
@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 BetaLao
L
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

Lao answered 13/7, 2015 at 18:4 Comment(1)
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!Revere
N
30

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!

Nightwear answered 14/2, 2016 at 21:2 Comment(2)
So what happens if I'm having the same issue (old APK keeps getting installed) and I have the "Gradle-aware Make" option there?Hegyera
I couldn't understand why but it worked like magic. Do you know if "Gradle-aware Make" is used to anything else besides fixing this issue ?Breunig
A
7

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

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

Ammadas answered 3/5, 2016 at 23:3 Comment(2)
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 classesCurst
this didn't work for me unfortunately. Changes are requiring two deployments to appear on the emulator.Owenowena
A
4

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.

enter image description here

Almuce answered 1/12, 2021 at 14:13 Comment(1)
This worked for me on Android HedgeHogAnderlecht
L
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

Lao answered 13/7, 2015 at 18:4 Comment(1)
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!Revere
C
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

Checkoff answered 1/5, 2017 at 21:32 Comment(0)
G
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

Gannon answered 16/3, 2019 at 16:22 Comment(1)
This is really useful, solved my problems, thanks.Priam
H
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.

Harald answered 24/4, 2020 at 9:15 Comment(0)
J
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.

Jenifferjenilee answered 24/7, 2020 at 18:7 Comment(0)
W
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

Williamson answered 27/1, 2015 at 17:35 Comment(0)
S
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.

Semaphore answered 10/7, 2015 at 22:21 Comment(0)
G
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.

Gamete answered 9/1, 2019 at 9:13 Comment(0)
C
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?

Carse answered 6/2, 2021 at 15:48 Comment(0)
S
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

Suspiration answered 30/10, 2021 at 18:5 Comment(0)
L
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.

Longlimbed answered 24/11, 2021 at 19:55 Comment(0)
E
0

I did "Clear Cache" in App settings and then it launched properly

Essonite answered 18/9, 2023 at 4:2 Comment(0)
A
0

I clicked here I clicked here

Then I removed this configuration(the name can be different) Then removed this configuration

And then I added it again by clicking on this button and then I added it again by clicking on this button

Appraise answered 22/7 at 13:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.