136

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.

Android Studio - Deploys my app without new changes

Community
  • 1
  • 1
Simply Brian
  • 1,501
  • 2
  • 10
  • 8
  • please check [this](http://stackoverflow.com/a/37207831/2826147) and [this](http://stackoverflow.com/a/35169716/2826147) answer. – Amit Vaghela Jun 28 '16 at 05:53
  • Have you found a workaround to this problem? I've facing this before, and Clear, Rebuild, or just restart Android Studio has worked. But today, NOTHING seems to solve this. I'm uninstalling Studio and going to install it again and see if something changes. I don't believe that this is a Instant Run problem. I have a suspect that it start to happen after a manual installation that I did today using `adb` from terminal. Things I've tried: - clean, rebuild, invalidate caches and restart Studio - force stop, clean data and uninstall app from device - restart computer and device – Gabriel Gularte Aug 15 '18 at 16:56
  • 8
    Having same issue in 2021... – nibbana Jan 15 '21 at 11:34

27 Answers27

108

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.

Community
  • 1
  • 1
Sira Lam
  • 5,179
  • 3
  • 34
  • 68
  • 1
    You will find the explanation of this here: https://developer.android.com/studio/run/rundebugconfig.html. In the table below "Define before-launch operations" – Christopher Smit Mar 28 '18 at 06:19
  • Thank you! I have wasted more than 24 hours fixing my code and wondering why that code change is not working. I had no idea that there was something like this also. – Bhavesh Bansal Mar 28 '18 at 10:55
  • NOT WORKING: Error while generating dependencies split APK com.android.ide.common.process.ProcessException: Failed to execute aapt – android51130 Mar 28 '18 at 11:55
  • 1
    @android51130 Actually I found a "larger post" [here](https://stackoverflow.com/a/49506088/7870874). Seems disabling instant run will solve. – Sira Lam Mar 28 '18 at 12:16
  • @SiraLam "run" works fine with disabled instant run, the problem is "wtf is going on here" with instant run in studio 3.1. I need instant run, and you too :))) – android51130 Mar 28 '18 at 12:18
  • @android51130 just curious, why do you love instant run so much? For the speed or something else? I personally never enable it. – Sira Lam Mar 28 '18 at 12:41
  • @SiraLam speed of course. when I have multiple modules in project and the project is really big after 3 yrs - yes, code change speed for displaying results immediately is important for me :) – android51130 Mar 28 '18 at 12:48
  • Well this issue persist in AS 4.1.1 as well – Min2 Nov 20 '20 at 17:16
76

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.

Göktay K.
  • 984
  • 9
  • 12
  • 3
    I'm using Android Studio 2.1 and I still have the same issue. The only solution was to disabled the instant run :( – radu_paun May 10 '16 at 08:04
  • 5
    Have this problem even with "Instant Run" disabled, quite annoying!!! AS 2.1.2. 'Clean' helps ... – pvllnspk Jul 18 '16 at 13:16
  • 1
    If anyone else is also looking for it, on OS X you can find it under `File -> Preferences -> Build, Execution, Deployment` – Gian Luca Scoccia Aug 05 '16 at 09:19
  • I think Disabling Instant run is not a good solution. It has so many benefits and just one bug. – Milad Faridnia Jan 03 '17 at 06:31
  • 4
    I'm using the Android Studio 3.2 Canary 13 with Instant Run disabled and this issue still persist. – mr5 May 08 '18 at 18:00
  • Update your answer plz, couldnt locate `Instant Run` . `2020 3.1.canary 7` version – CodeToLife May 18 '21 at 19:39
  • Just in case. Instant run is replaced now in Android Studio . in Android Studio 4 refer to this answer for disabling it. https://stackoverflow.com/a/62936420/8136868 – Reza Jul 10 '21 at 13:48
40

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

Rüdiger
  • 1,674
  • 1
  • 20
  • 28
  • Do i need to do it every time whenever i make some changes in my XML files? As i can see that whenever i make changes in animation XML file. It doesn't deploy new changes until i Clean and rebuild app again – Jigar Jul 15 '16 at 06:56
  • that's the problem - to have to do it with every change.. google come on, fix this shit- make "run" to save, build and deploy. – NBApps Jul 21 '16 at 11:00
  • Seems like "Rebuild project" is also (occasionally?) suffering from a bug: Instead of building and installing my app's current version it installed a version from 30 min ago?! Before, when googling brought me to this thread, I was stuck at a version from 5 min ago. Looks like the Android Studio developers built in a time machine… – balu Aug 23 '16 at 05:20
  • 11
    2018 - A.S. 3.2.0 and we still have to deal with this – Androiderson Feb 19 '18 at 20:44
  • Latest Android Studio and still this BUG is there. Can't refresh the updated kotlin code on my device...yeah! – lacas Feb 20 '18 at 15:58
  • 2
    I am running seriously into this problem just after updating from AS 3.0 to 3.1. I have to rebuild the project every time.... – Sira Lam Mar 27 '18 at 03:03
  • 4
    Same issue after updating AS from 3.0 to 3.1. – Bandzio Mar 27 '18 at 07:55
  • Me too... But I found that The new project doesn't has this issue... I don't know where is being set wrong... – Chinese Cat Oct 12 '18 at 03:08
  • 7
    2020 - AS 4.1.1 and still not able to overcome completely from this. – Min2 Nov 21 '20 at 09:57
  • 2021 - Arctic Fox 2020.3.1 Patch 3 and still having this problem on one project only. Have to press 'Build Project' every time, the changes won't apply otherwise. – Ajji Oct 27 '21 at 22:29
  • this was the only suggestion that worked – FabioC Apr 01 '22 at 18:39
  • Facing this issue in electric eel for one particular project. any fix? – Programmer007 Jun 16 '23 at 10:14
12

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.

Alek Slodowska
  • 350
  • 2
  • 7
  • +1 OMGY You are a lifesaver. Upon checking my `layouts` realized I had two layouts over there: 1: `activity_main.xml` and `activity_main.xml (v21)` My changes were reflecting in just one. – fWd82 Jul 02 '21 at 08:45
11

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

Simona Stoyanova
  • 322
  • 2
  • 11
5

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)

Andrey.Kozyrev
  • 579
  • 8
  • 17
5

Aug 2023
It is a very common issue and the solution is very easy...

  1. Run ⇢ ▶ Run...Edit Configurations...

  2. Check "Always install with package manager"

  3. Click Apply button enter image description here

ucMedia
  • 4,105
  • 4
  • 38
  • 46
3

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.

ugur
  • 3,604
  • 3
  • 26
  • 57
3

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

Qamar
  • 4,959
  • 1
  • 30
  • 49
2

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!

bitanon
  • 135
  • 3
  • 12
2

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.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Nitish kumar
  • 51
  • 1
  • 2
2

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).

sifr_dot_in
  • 3,153
  • 2
  • 33
  • 42
2

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.

dfinn
  • 968
  • 1
  • 10
  • 16
1

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

Milad Faridnia
  • 9,113
  • 13
  • 65
  • 78
  • 1
    I'm using AS 4.1, and only this workaround worked for me. but very annoying that I have to do it on every single build – Shayan_Aryan Mar 10 '21 at 14:39
1

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

nPcomp
  • 8,637
  • 2
  • 54
  • 49
1

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.

Zain
  • 37,492
  • 7
  • 60
  • 84
  • Yeah, I'm rebuilding the APK and I've even changed the version. Invalidated caches/restart. Nothing I do ever creates the correct APK. Instead it's a very old version of the APK. The only way I could get the app on the device was to connect via USB and run the app from studio and it finally put the correct version on. But the APK never builds properly. – raddevus Jun 04 '21 at 21:30
1

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

MarkT
  • 378
  • 2
  • 7
  • 1
    Still having the issue on Arctic Fox 2020.3.1 patch 3. I have to press Build > Rebuild project after every code changes, otherwise the new changes won't apply. This is happening on one specific project only. Still looking for an issue. – Ajji Oct 27 '21 at 22:31
  • try this: c:/Users/me/AppData/Local/Google/AndroidStudioPreview2021.1/caches then delete all caches also allow kotlin plugging upgrade if AS suggest you it – MarkT Nov 08 '21 at 21:19
  • Still on Android Studio Bumblebee | 2021.1.1 Patch 1 – cesarsicas Feb 14 '22 at 19:18
1

I was using BumbleBee and none of these solutions worked for me. Here are two things i tried, one of them resolved my issue:

  1. From Bumble Bee, I updated Android studio to Chipmunk | 2021.2.1. (Try this one first)
  2. I am using Macbook pro 2015. The Mac OS had a bug that when you create a new folder or a file from terminal or somewhere outside, it won't show you the newly created file, unless you close and open that directory again. Then I updated Mac OS to the latest version (12.2.1). I doubt that probably this bug was somehow keeping the Android studio from deploying latest changes.

Hopefully the First one might work for you.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Ajji
  • 3,068
  • 2
  • 30
  • 31
1

Try

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/

Source: React native run-android do not updating modified code

Ovidiu Cristescu
  • 821
  • 7
  • 19
1

Refactoring a name of an activity.java simply solve the same issue for me.

HMR
  • 146
  • 1
  • 7
1

Final settings in "edit configuration" which helped to get rid of rebuilding project each time.

Android Studio: Dolphin | 2021.3.1 Patch 1

enter image description here

shehzy
  • 2,215
  • 3
  • 25
  • 45
  • i am on Android Studio Giraffe | 2022.3.1 Patch 1 and after hours of headache i finally got this to work using the gradle aware solution – Diljeet Aug 25 '23 at 12:59
0

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.

kann
  • 687
  • 10
  • 22
0

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...

Rocco Foti
  • 9
  • 1
  • 2
  • 1
    please elaborate more on your answers so other users can benefit...add step by step, etc... – Juan Boero Feb 10 '16 at 20:19
  • 4
    Someone else has already posted this as an answer. Instead of re-posting, consider upvoting the existing answer once you have enough rep. – OhBeWise Feb 10 '16 at 20:21
0

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.

Guz
  • 187
  • 1
  • 6
0

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.

Leons
  • 201
  • 1
  • 7
0

I was facing this issue for a particular one project in Android Studio Electric eel. I had to clean and rebuild project again and again for minor changes. I fixed this issue following way

Click app -> Edit Configuration

After that a window will appear like below

enter image description here

Now scroll down and you will see following screen

enter image description here

Click + and add Gradle aware make and a popup will appear and will ask to enter task. Leave it empty and add it.after that select gradle aware make and close this window. Now live changes will work . Enjoy

Programmer007
  • 181
  • 12
-3

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.

Murat
  • 3,084
  • 37
  • 55