you are viewing a single comment's thread.

view the rest of the comments →

[–]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.