Android Studio not deploying changes to app

AndroidDeploymentAndroid Studio

Android Problem Overview


Sometimes this scenario occurs when developing. I would make a change in my source code, hit save all and then run but the change wouldn't be apparently not reflected in the app -(I'm using a device for testing). I can even uninstall the app on my device, and hit run again and the newly installed app still hasn't reflected the change in the source code. When this happens I have to edit the source, hit run and maybe then a new version with the changes I expected will be on the device.

I also tried the solution here, but it doesn't seem to work often.

https://stackoverflow.com/questions/28183822/android-studio-deploys-my-app-without-new-changes

Android Solutions


Solution 1 - Android

EDIT2 (2020-03-09)

If you are using gradle 6.0 in your gradle-wrapper.properties, you may also encounter a similar situation because there is this bug in 6.0 version. Try 6.0.1 instead.


Yesterday (2018-03-27) Android Studio published an official update from 3.0.1 to 3.1, and it looks like a lot of people (including me) start running into this issue again.

Credit to #5 comment here, below is how it solved:

In Android Studio, go to Run > Edit Configuration.

Under Before launch:, if you cannot find Gradle-aware Make, just like below:

enter image description here

Add Gradle-aware Make and leaving Task empty.

enter image description here

Warning: I don't know what these action means, and whether it will cause any side-effects. Appreciate if someone can give more explanation on it!

EDIT

Thanks to @ChristopherSmit referenced, this page mentions that Gradle-aware make means "Compile the project and run Gradle".
At first I guess this may make Runs take longer time even if no code has been changed; but after testing, the second time is still much faster if no code has been changed.
Given that fact that this is a default option if you create a new project using AS 3.1, I think this configuration is pretty safe.

Solution 2 - Android

I've got the same problem. This thread popped up first when I've searched for it. Solved it (hoping so) by not using the Instant Run feature. Might not be the best solution but it works for now.

Just go to "File -> Settings -> Build, Execution, Deployement -> Instant Run" and just disable it. With this Android Studio builds from scratch each time but it's better than not building it right.

Mini rant: Almost each version of Android Studio comes with an annoying bug. They're about to release the version 2 but its beta is still buggy. I hope they stabilize the IDE in the near future.

Solution 3 - Android

I had the same Problem, using Android Studio 2.0.0, solved it by rebuilding my Project.

Build > Rebuild Project

GUI Picture

or by Clean and Rerun

Run > Clean and Rerun

Clean and Rerun

Solution 4 - Android

This was a real stumper until I realized that my changes must not be propagated to all relevant files ...

If you're having trouble with layouts, as I was, you may find that you need to update the layout in the res > layout-v17 folder. I had made changes via the Design View in the layout folder and those changes seemed to be propagated automatically to layout-v17, initially. However, later changes WEREN'T.

Check your res > layout-v17 folder and see if the .xml files in that folder reflect the changes you are seeing in your res > layout folder. You will probably find that they don't. Fix this and re-deploy. Like me, you should see the new code mods.

Hope this helps.

Solution 5 - Android

In Android Studio 3.6.3 you can enable auto restart if the instant run fails.

Just go to File | Settings | Build, Execution, Deployment | Deployment and check the checkboxes.

Settings

Solution 6 - Android

Android Studio Bumblebee | 2021.1.1 Patch 1 Build #AI-211.7628.21.2111.8139111, built on February 1, 2022

"Edit Configurations" Check "Always install with package manager (disables deploy optimization on Android 11 and later)

Solution 7 - Android

For now I solved the issue by closing the app and run again. It worked like a charm. Not sure yet if it is a coincidence, but i guess it worths give it a try.

I really wonder if it works some other people too. Lets give it a try and let me know.

Solution 8 - Android

See the screenshot below. The underline is Instant Run. Working better in Android Studio 4.1.1

The undercircle is Apply Changes.

enter image description here


The Android Studio 4 even renders a view without running the app. Change anything and see the results. Very useful for custom view developers.

enter image description here

Solution 9 - Android

I had the same issue , I tried everything like clean and rebuild , gradle-sync , even uninstalling and installing the app but noting worked. The other devices were working fine but in my mobile the problem was still going on. Then I realised that I accidentally a duplicate layout file layout-v26 and was doing change in that file that why the design was not updating . So I just deleted the duplicate layout from the Project>app>main>res>layout-v26 and the problem was solved . So please make sure that you have not created any of these files without realising.

Solution 10 - Android

Was also seeing this issue intermittently in Android Studio 4.2.2, none of the suggestions here worked. But I found a workaround that seems to work for me: turn on the option "Always install with package manager (disables deploy optimizations on Android 11 and later)" which is located under Run -> Edit Configurations.

Solution 11 - Android

I Like Instant Run Feature and I don't like to disable it just because of this bug. Not a solution but as a better workaround I'd prefer to:

  1. Press "Recent Apps"
  2. Simply close my app from the list
  3. Run the app again

This takes less time than Clean or Rebuild.

UPDATE

Rerun the app also works:

enter image description here

Solution 12 - Android

For me instant run was a nightmare, 2-5 minute build times, and maddeningly often, recent changes were not included in builds. I highly recommend disabling instant run and adding this line to gradle.properties:

android.enableBuildCache=true

First build often takes some time for large projects (1-2mins), but after it's cached subsequent builds are usually lightnight fast (<10secs).

Got this tip from reddit user /u/QuestionsEverythang which has saved me SO much hassling around with instant run!

Solution 13 - Android

Make sure you do not have an alternative layout. If you do, you might be changing one and deploying another.

Solution 14 - Android

For me, uninstalling, reinstalling the app doesn't work. The same for disabling instant run.

By going to device settings >> Apps >> myApp >> Clear caches & clear data, the new changes deployed to the app.

Solution 15 - Android

Even if you didn't update anything,
this can suddenly start:
Code changes don't reflect on the app / don't take effect.
One of the step that worked for me is:

"File -> Invalidate Caches / Restart ..."


made it.

This can bee the result of machine/studio intermittently rebooting/closing (because of hardware issues / electricity down).

Solution 16 - Android

Here AS Artic Fox 2020.3.1 patch 3

Problems: Not deploying changes in app different SQLite errors like "no such table" (after coding a new table) 2 days trying to solve this and I found following:

(testing and launching in a phisical device)

Build - Clean Build - Rebuild project

no changes or effects on new deployment

what I did

file - invalidate cache and restart physical device: long press app icon + force stop, storage clear cache, free storage restart the phone

lauch old app from physical device

as soon I did this my phone recognized the new changes and new deployment that was weird but worked for me

Solution 17 - Android

Same problem started occurring after I have upgraded the buildVersion from 23. Tried removing AVDs and recreating, Synching up with Gradle Files. Nothing helped. Complete reinstallation of Andriod Studio has fixed the problem. This may not be the solution but this only worked for me.

Solution 18 - Android

Also me solved it by not using the Instant Run feature. Might not be the best solution but it works for now. I'm using Android Studio 2.0 beta 2...

Solution 19 - Android

The thing that worked for me was to add some bad xml to one of my layout xml files, try to build and get an error, then revert the change and debug again. Not pretty, but pretty fast.

Another thing that seems to work most of the time: unplug and reconnect your development phone/device. This seems to force a reinstall, at least on my Linux machine.

Solution 20 - Android

I have the same issue, I unchecked instant Run and also i tried "clean and run option" but its not working. I tried to gradle sync it, but still i had the issue. Its gets resolved only if i rebuild it completely by deleting build folder.

Solution 21 - Android

You can understand whether the code is deployed or not by putting a debug breakpoint to the new line that you added. If there is a cross on the breakpoint, this means it is not deployed. You need to clean and rebuild the project.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSimply BrianView Question on Stackoverflow
Solution 1 - AndroidSira LamView Answer on Stackoverflow
Solution 2 - AndroidGöktay K.View Answer on Stackoverflow
Solution 3 - AndroidRüdigerView Answer on Stackoverflow
Solution 4 - AndroidAlek SlodowskaView Answer on Stackoverflow
Solution 5 - AndroidSimona StoyanovaView Answer on Stackoverflow
Solution 6 - AndroidAndrey.KozyrevView Answer on Stackoverflow
Solution 7 - AndroidugurView Answer on Stackoverflow
Solution 8 - AndroidQamarView Answer on Stackoverflow
Solution 9 - AndroidNitish kumarView Answer on Stackoverflow
Solution 10 - AndroiddfinnView Answer on Stackoverflow
Solution 11 - AndroidMilad FaridniaView Answer on Stackoverflow
Solution 12 - AndroidlandonmutchView Answer on Stackoverflow
Solution 13 - AndroidnPcompView Answer on Stackoverflow
Solution 14 - AndroidZainView Answer on Stackoverflow
Solution 15 - Androidsifr_dot_inView Answer on Stackoverflow
Solution 16 - AndroidMarkTView Answer on Stackoverflow
Solution 17 - AndroidkannView Answer on Stackoverflow
Solution 18 - AndroidRocco FotiView Answer on Stackoverflow
Solution 19 - AndroidGuzView Answer on Stackoverflow
Solution 20 - AndroidLeonsView Answer on Stackoverflow
Solution 21 - AndroidMuratView Answer on Stackoverflow