Repository navigation
Flutter seemingly not pushing new dev builds without first running flutter clean #147752
Description
Steps to reproduce
I have repeatedly seen $ flutter run not ship new builds to a test device (which has included physical Android and iOS devices, and also macOS desktop) without first running $ flutter clean.
I first encountered this bug earlier this week when @schmidt-sebastian was unable to successfully rebuild an example on his test Android device in a project we are working on together.
Then, I saw the error myself yesterday pushing the same project to my iOS device.
And then this morning while livestreaming, I encountered it again on an unrelated project. The part where I start encountering new code not getting executed begins here, after some unrelated distractions resumes with a compilation error during an attempted hot reload here, and then concludes with me eventually using $ flutter clean here.
Expected results
$ flutter run should either ship the new app or fail loudly.
Actual results
$ flutter run either silently fails to compile and ships the old build, or just ships the old build regardless.
Code sample
I will revisit a minimal reproduction soon, but wanted to at least start documenting this since I no longer believe it is simple user error.
Screenshots or Video
No response
Logs
No response
Flutter Doctor output
Doctor output
$ flutter doctor -v
[✓] Flutter (Channel master, 3.22.0-18.0.pre.77, on macOS 14.4.1 23E224 darwin-arm64, locale en)
• Flutter version 3.22.0-18.0.pre.77 on channel master at /Users/craiglabenz/Dev/git/flutter/flutter
• Upstream repository [email protected]:flutter/flutter.git
• Framework revision 3e399c1578 (2 days ago), 2024-04-30 13:25:24 -0700
• Engine revision 0ce67714ce
• Dart version 3.5.0 (build 3.5.0-114.0.dev)
• DevTools version 2.35.0-dev.16
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/craiglabenz/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• ANDROID_SDK_ROOT = /Users/craiglabenz/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15A507
• CocoaPods version 1.13.0
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2023.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
[✓] IntelliJ IDEA Community Edition (version 2023.1.4)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
[✓] VS Code (version 1.88.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.88.0
[✓] Connected device (4 available)
• Craig's iPhone 15 (mobile) • 00008130-0019391C0061401C • ios • iOS 17.4.1 21E236
• macOS (desktop) • macos • darwin-arm64 • macOS 14.4.1 23E224 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 14.4.1 23E224 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 124.0.6367.119
! Error: Browsing on the local area network for Craig's iPhone 11. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this
Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources
• All expected network resources are available.
• No issues found!
Activity
craiglabenz commentedon May 2, 2024
To whomever first tries to look at this - I am available to pair up and investigate what is going on.
christopherfujino commentedon May 2, 2024
cc @andrewkolos
AbdeMohlbi commentedon May 3, 2024
@craiglabenz
I've observed this behavior myself, when dealing with large trees of nested widgets and complex conditions. Sometimes, even after triggering a hot reload, the changes aren't accurately reflected, especially in deeper parts of the tree. This issue became more noticeable for me around version 3.16.
borjandev commentedon May 3, 2024
Reproducible on master
Hot Restart seems to push the updated code
flutter clean+ recompile seemingly updates the state of the code to the point whenflutter cleanwas run.Changing code and recompiling will now build that state instead rather than the latest state.
This issue is very disruptive as it can easily mislead the developer.
This is especially bad if the developer is trying to fix a difficult bug as it can make him think that his new code is not fixing the bug in question.
borjandev commentedon May 4, 2024
It just happened to me in production!
With
fvm flutter build apkBuild took shorter time and installing the release with
adb install build/app/outputs/flutter-apk/app-release.apkResulted in an old version being installed on the device.
This is now much more serious @christopherfujino @andrewkolos
Running
flutter cleanand re-runningadb install build/app/outputs/flutter-apk/app-release.apklead to the correct version being installed.Same with iOS releases it actually deployed a wrong build!
timmaffett commentedon May 6, 2024
Hot reload/restart definitely is affected also - it no longer works in all cases either - it may seem to work in some cases, but it often no longer works. It does not matter if the debugger is being used or not.
The only way to develop with the current master channel is to ALWAYS
flutter cleanafter ANY change - it is no longer possible to due any hotreloading - you simply can no longer depend on it.This bug should be of the highest priority - the build environment is essentially totally broken in all cases.
timmaffett commentedon May 6, 2024
This may be related to #147643
craiglabenz commentedon May 6, 2024
Great news - that would also mean #147709 should be our fix.
craiglabenz commentedon May 6, 2024
Update: #147709 does seem to fix this broken behavior for me. For anyone on the
masterchannel who wants this know, if you build Flutter from a clone of the repo, checking out this and runningflutter doctorwill get you this patch immediately.timmaffett commentedon May 6, 2024
I can confirm that #147709 does fix this issue for me. I have been testing it for the last few hours on several projects and changes I make are being correctly incorporated into builds and hot reloads.
(I applied the changes to my
packages/flutter_tools/lib/src/build_system/targets/common.dartfile (also adding a debug print statement to thebuild()method around line 167 so I could verify each build was using the changes))(Once your
common.dartis patched you need to delete thebin/cachedirectory so that it forces rebuilds of the tools (or runningflutter doctor))Here's to hoping that #147709 gets merged into the master channel ASAP (for others sake - my environment works now 😄 )
This bug was and will continue to be a real time waster for developers on the master channel until it is fixed. It is confusing as heck when changes you are making are not being incorporated into builds!
andrewkolos commentedon May 7, 2024
#147709 has merged, so I believed this issue should be resolved. Feel free to reopen if this is not the case.
github-actions commentedon May 21, 2024
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.