You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
'flutter run' doesn't rebuild the app if it's changed #7014
@abarth To answer your question we need dependency tracking and a check before running to see if any of the source files / assets are newer than the APK/IPA.
One possible solution I've considered is having flutter tools generate a BUILD.gn for the application and then rely on ninja for dependency tracking and building.
This used to work fine. There is code that verifies if the snapshot needs to be rebuilt or if the assets are changed, etc. It just got disconnected at some point recently.
In any case, the flutter run; edit; flutter run workflow absolutely must work or people are going to be pulling their hair out. This used to work, and doesn't work now. We should fix that ASAP. :-)
I don't know how this ever worked. I traced it to _needsRebuild in build_apk.dart. This function is returning false all the time.
It's not surprising because, _needsRebuild receives the list of assets, apk, and the AndroidManifest and checks if anything has been modified after the APK was built. There are no checks if any Dart sources have been modified. In fact there is even a really old and wrong comment explaining why:
// Note: This list of dependencies is imperfect, but will do for now. We// purposely don't include the .dart files, because we can load those// over the network without needing to rebuild (at least on Android).
If I recall correctly, we would check a few files to see if the native portion of the app had to be rebuilt - if we had to build a new APK. We would then always re-snapshot - and send that over to the device separately - but that was fast enough that we still had a quick turn-around time.
Maybe we always rebuilt unconditionally before?
So, yeah, I think that was the case at least for the dart files.
on Windows, haven't found exactly when it stops rebuilding.
The symptom that indicates the failure is stopping at a breakpoint and secondary window with the file opens which is read only and does NOT show recent edits.
i.e. set a breakpoint in main.dart
execute to breakpoint, a copy of main.dart now open (it's failed, old code) with path \main.dart
writable code window labeled as lib\main.dart (shows current code)
seems deleting build\app\intermediates is enough to get a correct rebuild
@eturk1 please create a new issue with flutter doctor output and all other information you can provide to allow to reproduce.
Closed issues aren't monitored.
Hello. I got the same issue even when i create new flutter projects. Every time a want to see the changes i need to delete the build folder and then re-run the app.
I found you can just delete build\app\intermediates.
Also found it's much worse when debugging. Just changing one line of code could cause failure, noted when debugging read-only window opens and codee is old.
(I'm on Windows. Is this happening on all platforms?)
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
abarth commentedon Nov 30, 2016
Do we know what needs to change here?
johnmccutchan commentedon Nov 30, 2016
AFAIK this has never worked reliably. My work flow is often
rm -rf build && flutter runjohnmccutchan commentedon Nov 30, 2016
@abarth To answer your question we need dependency tracking and a check before running to see if any of the source files / assets are newer than the APK/IPA.
johnmccutchan commentedon Nov 30, 2016
One possible solution I've considered is having flutter tools generate a BUILD.gn for the application and then rely on ninja for dependency tracking and building.
chinmaygarde commentedon Nov 30, 2016
I doubt we can rely on the user having GN or ninja on their systems.
Hixie commentedon Nov 30, 2016
This used to work fine. There is code that verifies if the snapshot needs to be rebuilt or if the assets are changed, etc. It just got disconnected at some point recently.
Hixie commentedon Nov 30, 2016
cc @devoncarew who might know more
johnmccutchan commentedon Nov 30, 2016
@chinmaygarde I was thinking that we would download them from cloud storage so that we can rely on them being present.
Hixie commentedon Dec 8, 2016
Maybe we always rebuilt unconditionally before?
In any case, the
flutter run; edit;flutter runworkflow absolutely must work or people are going to be pulling their hair out. This used to work, and doesn't work now. We should fix that ASAP. :-)johnmccutchan commentedon Dec 8, 2016
I don't know how this ever worked. I traced it to
_needsRebuildinbuild_apk.dart. This function is returning false all the time.It's not surprising because,
_needsRebuildreceives the list of assets, apk, and the AndroidManifest and checks if anything has been modified after the APK was built. There are no checks if any Dart sources have been modified. In fact there is even a really old and wrong comment explaining why:devoncarew commentedon Dec 9, 2016
If I recall correctly, we would check a few files to see if the native portion of the app had to be rebuilt - if we had to build a new APK. We would then always re-snapshot - and send that over to the device separately - but that was fast enough that we still had a quick turn-around time.
So, yeah, I think that was the case at least for the dart files.
Hixie commentedon Dec 9, 2016
It should be relatively easy to just crawl all the .dart files and see if any of them are newer than the last snapshot, right?
13 remaining items
Hixie commentedon Apr 30, 2018
@AlBiNoS14 can you file a new bug that includes precise steps for reproducing this? Thanks
mswehli commentedon May 5, 2018
Same issue, deleting the build folder seems to fix things though. But not sure how long it lasts.
Edit: Basically just needed a flutter clean
Hixie commentedon May 8, 2018
If you run into this please file a new bug with explicit steps that show how to reproduce it.
javadbat commentedon May 8, 2018
https://stackoverflow.com/questions/49695393/flutter-build-apk-create-old-version-app/49695394#49695394
eturk1 commentedon May 9, 2018
on Windows, haven't found exactly when it stops rebuilding.
The symptom that indicates the failure is stopping at a breakpoint and secondary window with the file opens which is read only and does NOT show recent edits.
i.e. set a breakpoint in main.dart
execute to breakpoint, a copy of main.dart now open (it's failed, old code) with path \main.dart
writable code window labeled as lib\main.dart (shows current code)
seems deleting build\app\intermediates is enough to get a correct rebuild
zoechi commentedon Jun 12, 2018
@eturk1 please create a new issue with
flutter doctoroutput and all other information you can provide to allow to reproduce.Closed issues aren't monitored.
lukepighetti commentedon Jun 18, 2018
VSC debug auto hot reloads on file save no problems. But
flutter rundoes not. Am I missing an argument of some kind?zoechi commentedon Jun 19, 2018
@lukepighetti I'd assume auto hot reload is an IDE feature, not a
flutterfeature.lukepighetti commentedon Jun 19, 2018
This issue seems to be related to
flutter runhaving the same functionality. Did it, or does it, have the same functionality?zoechi commentedon Jun 20, 2018
@lukepighetti I see what you mean. I'd assume that requires a command option because in the IDE Flutter plugin this can be enabled/disabled.
lvillatoro commentedon Oct 26, 2018
Hello. I got the same issue even when i create new flutter projects. Every time a want to see the changes i need to delete the build folder and then re-run the app.
eturk1 commentedon Oct 26, 2018
I found you can just delete build\app\intermediates.
Also found it's much worse when debugging. Just changing one line of code could cause failure, noted when debugging read-only window opens and codee is old.
(I'm on Windows. Is this happening on all platforms?)
lvillatoro commentedon Oct 26, 2018
Im on Windows too, using Android Studio and Visual Code, same problem in both IDEs
github-actions commentedon Sep 1, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.