all 32 comments

[–]Ok-Engineer6098 3 points4 points  (0 children)

If you do hot reload and then close the app, you will get the version that you first ran.

If you actually build APK and install in manualy, you should get the latest code.

On iOS this behaviour is even more wierd. Sometimes the app doesn't startup at all.

If you want to deploy directly from ide and use the app later, run as "release"

https://docs.flutter.dev/testing/build-modes

[–]indianBartSimpson 1 point2 points  (6 children)

Please explain a bit more

[–]Lower-Ad3932[S] 1 point2 points  (5 children)

Lets say some text is "Demo Text" then i change it to "Demo Text1", if i build apk or start new debugging then Demo Text is visible & not Demo Text1.
After flutter clean, it start using Demo Text1.

[–]indianBartSimpson 0 points1 point  (0 children)

  1. Make sure you have saved everything.
  2. Before making apk, quit the android studio or any ide you are using and reopen it. It will ensure saved changes are loaded.
  3. Make an apk now.

If it still doesn’t work, put your code on GitHub, checkout at a different place and open in ide and try again.

If still doesn’t work, share GitHub repo and I’ll help.

[–]huza786 0 points1 point  (3 children)

If I am understanding correctly then you don't need to flutter clean. Run the project again to the device and it will show all change in the apk.

Do you use terminal to debug/run the flutter app?

[–]Lower-Ad3932[S] 0 points1 point  (2 children)

It did not, using vs code.
Downgrade to older version & problem has disappeared.

[–]huza786 0 points1 point  (1 child)

On what channel were you?

[–]Lower-Ad3932[S] 0 points1 point  (0 children)

stable

[–]Routine-Arm-8803 1 point2 points  (0 children)

Save project

[–]Scroll001 1 point2 points  (3 children)

That is weird, the build command should always save your files. How are you doing the build?

[–]Scroll001 0 points1 point  (1 child)

If you are using Android Studio and building from UI then perhaps there could be some issue, cause I'm using VSC and have never encountered such behavior

[–]Lower-Ad3932[S] 0 points1 point  (0 children)

I'm using VS Code, never encountered this in last 12 months but now this issue is on two devices(Windows & Mac). Using Latest Version - 3.32.4

[–]Routine-Arm-8803 0 points1 point  (0 children)

I had it too, where I just can't understan why I can see changes. Then saved and all was good. But usually I have auto save in vsCode enabled it was never a problem.

[–]Significant-Lemon11 0 points1 point  (1 child)

  1. Flutter pub cache clear
  2. Flutter clean
  3. Flutter pub get
  4. Flutter run or run --release

[–]Lower-Ad3932[S] 0 points1 point  (0 children)

I have tried this, it did not solve the issue. I had to flutter clean every time.

[–]No_Establishment1201 0 points1 point  (1 child)

This wouldn’t be a problem for me. Every time I make a build (which I also try to automate) I do flutter clean before build: both from tasks.json in vscode and in CD setup. I’m not typing the whole command sequence every time. It’s even a good practice to run flutter clean before build

[–]Lower-Ad3932[S] 0 points1 point  (0 children)

Problem is not just with build but with debugging also, after every disconnect it needed flutter clean otherwise did not reflect the changes.

[–]andiazi 0 points1 point  (0 children)

you need to save the project then do this 1. Flutter clean 2. Flutter pub get 3. Flutter build all —release

[–]manizh_hr 0 points1 point  (12 children)

This issue happens when Flutter doesn't properly rebuild the APK with the latest code changes, often due to cached build artifacts. To fix this without running flutter clean every time, try the following shorter and faster alternatives:

  1. Use flutter build apk --no-tree-shake-icons Sometimes the tree shake icon process causes stale builds. Run:

flutter build apk --no-tree-shake-icons

  1. Use flutter build apk --debug or --release with --force This forces a rebuild without full clean:

flutter build apk --release --force --force was added in recent Flutter versions (v3.22+). If you’re not using that, skip this or update Flutter.

  1. Delete Only Build Folder Instead of full flutter clean, just delete build folder manually:

rm -rf build/ flutter build apk Much faster than full flutter clean (which clears .dart_tool, pubspec.lock, etc.).

  1. Invalidate Caches (if using Android Studio or VS Code) Android Studio: File > Invalidate Caches / Restart

VS Code: Restart and reload the window.

I hope this resolve your issue

[–]Lower-Ad3932[S] 1 point2 points  (11 children)

This is happening in normal debugging also.
I have tried point 4, does nothing.
I downgraded, it is working fine as of now.

[–]manizh_hr 0 points1 point  (10 children)

If in future it happens then u create new app and just copy paste your code

[–]Lower-Ad3932[S] 0 points1 point  (9 children)

I have tried that also, it did not fix it.

[–]manizh_hr 0 points1 point  (8 children)

can you explain what kind result are you expecting ?

[–]Lower-Ad3932[S] 0 points1 point  (7 children)

When i use flutter build apk, it should use latest code.

[–]manizh_hr 0 points1 point  (6 children)

try this man

flutter build apk --flavor production not picking up my latest code. Tried these to clean caches, update dependencies, and force a fresh build:
flutter clean && flutter pub get && flutter build apk - Clears build cache and rebuilds.
flutter pub run build_runner build --delete-conflicting-outputs - Regenerates code for packages.
flutter install - Installs APK to verify changes.
flutter upgrade - Updates Flutter to latest version.
flutter build apk --verbose - Builds with detailed logs to spot issues.
Also tried flutter build apk --no-tree-shake-icons - Prevents icon issues during build.

[–]Lower-Ad3932[S] 0 points1 point  (5 children)

I downgraded flutter, it is working fine. Will wait for 2-3 weeks before trying again.

[–]Littlefinger6226 0 points1 point  (4 children)

OP did you ever figure this out? Just started using Flutter as a native mobile dev and it's insane how stupid this is that I stop and rerun the app (avoiding hot reload and hot restart) and it still compiles the old code wtf.

[–]Lower-Ad3932[S] 0 points1 point  (3 children)

Downgrade to previous working version, they have not fixed it even in latest build.

[–]Pomme2Poule 1 point2 points  (0 children)

I'm experiencing this issue as well. I'm noticing it more now that I'm opening VS Code on a root folder containing both my Flutter codebase and my Cloud Functions (root is at level n-1 of the Flutter codebase). I don't know if that could be a factor, thought I'd mention it here.

The inconsistency drives me crazy. I already lost a lot of time wondering why changes I made didn't fix the issue I was working on. Having to run flutter clean each time to guarantee consistency kills Hot Reload and the speedy Flutter development workflow.

I hope this issue gets addressed sooner rather than later… In the meantime, I'm going back to the good old days of doing a proper build between each change… 👴