How to use flutter hot reload in console?
Asked Answered
F

3

12

I want to develop android apps with flutter without using Android Studio or some other IDE. I'm currently installing everything on my arch based linux distribution. Everything works fine for me except for the hot reload feature. When I do flutter run (or even flutter run --hot), the command execution gets stuck at the following point:

$ flutter run --hot                                                                                                                                      ✔  926  10:53:42
Using hardware rendering with device AOSP on IA Emulator. If you get graphics artifacts, consider enabling software rendering with "--enable-software-rendering".
Launching lib/main.dart on AOSP on IA Emulator in debug mode...
Running Gradle task 'assembleDebug'...                             16.0s
✓ Built build/app/outputs/apk/debug/app-debug.apk.
Installing build/app/outputs/apk/app.apk...                         2.1s
D/FlutterActivity( 5356): Using the launch theme as normal theme.
D/FlutterActivityAndFragmentDelegate( 5356): Setting up FlutterEngine.
D/FlutterActivityAndFragmentDelegate( 5356): No preferred FlutterEngine was provided. Creating a new FlutterEngine for this FlutterFragment.
D/FlutterActivityAndFragmentDelegate( 5356): Attaching FlutterEngine to the Activity that owns this Fragment.
D/FlutterView( 5356): Attaching to a FlutterEngine: io.flutter.embedding.engine.FlutterEngine@a4c3a46
D/FlutterActivityAndFragmentDelegate( 5356): Executing Dart entrypoint: main, and sending initial route: /
Syncing files to device AOSP on IA Emulator...
I/Choreographer( 5356): Skipped 39 frames!  The application may be doing too much work on its main thread.

D/EGL_emulation( 5356): eglMakeCurrent: 0xee21eda0: ver 2 0 (tinfo 0xebee8750)

I/OpenGLRenderer( 5356): Davey! duration=855ms; Flags=1, IntendedVsync=1732977740059, Vsync=1733627740033, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=1733631371135, AnimationStart=1733631552307, PerformTraversalsStart=1733631557297, DrawStart=1733706388536, SyncQueued=1733709834031, SyncStart=1733711094512, IssueDrawCommandsStart=1733711517055, SwapBuffers=1733737182985, FrameCompleted=1733834775355, DequeueBufferDuration=28144000, QueueBufferDuration=9171000,

D/EGL_emulation( 5356): eglMakeCurrent: 0xec205360: ver 2 0 (tinfo 0xec2033b0)

D/eglCodecCommon( 5356): setVertexArrayObject: set vao to 0 (0) 1 0

By stuck I mean, that the program is just outputing log messages and is ignoring all my input. I already tried things like pressing r or R but it just results in

D/eglCodecCommon( 5356): setVertexArrayObject: set vao to 0 (0) 1 0
rR

and no reaction of the emulated device.

Here are some outputs if you are interested:

flutter doctor results in:

[✓] Flutter (Channel stable, v1.12.13+hotfix.8, on Linux, locale en_US.UTF-8)
    • Flutter version 1.12.13+hotfix.8 at /opt/flutter
    • Framework revision 0b8abb4724 (4 weeks ago), 2020-02-11 11:44:36 -0800
    • Engine revision e1e6ced81d
    • Dart version 2.7.0

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /opt/android-sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • ANDROID_HOME = /opt/android-sdk
    • Java binary at: /usr/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-b08)
    • All Android licenses accepted.

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/setup/#android-setup for detailed instructions).

[✓] Connected device (1 available)
    • AOSP on IA Emulator • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)

Since it was requested, here is thelast part of the output of flutter run -v:

[  +23 ms] Android Debug Bridge version 1.0.41
           Version 29.0.6-6198805
           Installed as /opt/android-sdk/platform-tools/adb
[   +1 ms] executing: /opt/android-sdk/platform-tools/adb start-server
[  +19 ms] Installing build/app/outputs/apk/app.apk...
[        ] executing: /opt/android-sdk/platform-tools/adb -s emulator-5554 install -t -r /home/fox/tmp/testy/build/app/outputs/apk/app.apk
[+2544 ms] Performing Streamed Install
           Success
[        ] Installing build/app/outputs/apk/app.apk... (completed in 2.5s)
[   +4 ms] executing: /opt/android-sdk/platform-tools/adb -s emulator-5554 shell echo -n d26fd49fc8a8132a5b3be06672c852791523c0be > /data/local/tmp/sky.com.example.testy.sha1
[  +92 ms] AOSP on IA Emulator startApp
[   +4 ms] executing: /opt/android-sdk/platform-tools/adb -s emulator-5554 shell am start -a android.intent.action.RUN -f 0x20000000 --ez enable-background-compilation true --ez enable-dart-profiling
true --ez enable-checked-mode true --ez verify-entry-points true com.example.testy/com.example.testy.MainActivity
[ +379 ms] Starting: Intent { act=android.intent.action.RUN flg=0x20000000 cmp=com.example.testy/.MainActivity (has extras) }
[   +1 ms] Waiting for observatory port to be available...
[+1187 ms] D/FlutterActivity( 5901): Using the launch theme as normal theme.
[   +5 ms] D/FlutterActivityAndFragmentDelegate( 5901): Setting up FlutterEngine.
[        ] D/FlutterActivityAndFragmentDelegate( 5901): No preferred FlutterEngine was provided. Creating a new FlutterEngine for this FlutterFragment.
[+1996 ms] D/FlutterActivityAndFragmentDelegate( 5901): Attaching FlutterEngine to the Activity that owns this Fragment.
[  +95 ms] D/FlutterView( 5901): Attaching to a FlutterEngine: io.flutter.embedding.engine.FlutterEngine@a4c3a46
[  +54 ms] D/FlutterActivityAndFragmentDelegate( 5901): Executing Dart entrypoint: main, and sending initial route: /
[ +140 ms] Observatory URL on device: http://127.0.0.1:34706/KylafuV8tWY=/
[   +3 ms] executing: /opt/android-sdk/platform-tools/adb -s emulator-5554 forward tcp:0 tcp:34706
[  +14 ms] 44911
[        ] Forwarded host port 44911 to device port 34706 for Observatory
[  +12 ms] Connecting to service protocol: http://127.0.0.1:44911/KylafuV8tWY=/
[ +698 ms] Successfully connected to service protocol: http://127.0.0.1:44911/KylafuV8tWY=/
[   +5 ms] Sending to VM service: getVM({})
[  +20 ms] Result: {type: VM, name: vm, architectureBits: 32, hostCPU: Android virtual processor, operatingSystem: android, targetCPU: ia32, version: 2.7.0 (Fri Dec 6 16:26:51 2019 +0100) on
"android_ia32", _profilerMode: VM, _nativeZoneMemoryUsage: 0, pid: 5901, st...
[  +14 ms] Sending to VM service: getIsolate({isolateId: isolates/2827659313742019})
[  +11 ms] Sending to VM service: _flutter.listViews({})
[  +76 ms] Result: {type: Isolate, id: isolates/2827659313742019, name: main, number: 2827659313742019, _originNumber: 2827659313742019, startTime: 1584009467451, _heaps: {new: {type: HeapSpace,
name: new, vmName: Scavenger, collections: 2, avgCollectionPeriodMillis...
[  +30 ms] Result: {type: FlutterViewList, views: [{type: FlutterView, id: _flutterView/0xebf68710, isolate: {type: @Isolate, fixedId: true, id: isolates/2827659313742019, name:
main.dart$main-2827659313742019, number: 2827659313742019}}]}
[  +25 ms] DevFS: Creating new filesystem on the device (null)
[   +2 ms] Sending to VM service: _createDevFS({fsName: testy})
[  +58 ms] Result: {type: FileSystem, name: testy, uri: file:///data/user/0/com.example.testy/code_cache/testyTKZBNK/testy/}
[        ] DevFS: Created new filesystem on the device (file:///data/user/0/com.example.testy/code_cache/testyTKZBNK/testy/)
[   +2 ms] Updating assets
[ +137 ms] Syncing files to device AOSP on IA Emulator...
[   +3 ms] Scanning asset files
[   +3 ms] <- reset
[        ] Compiling dart to kernel with 0 updated files
[  +12 ms] /opt/flutter/bin/cache/dart-sdk/bin/dart /opt/flutter/bin/cache/artifacts/engine/linux-x64/frontend_server.dart.snapshot --sdk-root
/opt/flutter/bin/cache/artifacts/engine/common/flutter_patched_sdk/ --incremental --target=flutter -Ddart.developer.causal_async_stacks=true --output-dill /tmp/flutter_tool.RFJESY/app.dill --packages
/home/fox/tmp/testy/.packages -Ddart.vm.profile=false -Ddart.vm.product=false
--bytecode-options=source-positions,local-var-info,debugger-stops,instance-field-initializers,keep-unreachable-code,avoid-closure-call-instructions --enable-asserts --track-widget-creation
--filesystem-scheme org-dartlang-root
[  +20 ms] <- compile package:testy/main.dart
[  +69 ms] D/EGL_emulation( 5901): eglMakeCurrent: 0xee21f400: ver 2 0 (tinfo 0xee22aaf0)
[   +5 ms] D/eglCodecCommon( 5901): setVertexArrayObject: set vao to 0 (0) 1 0

The output of flutter devices -v is

$ flutter devices -v                                                                                                                                               ✔  936  14:29:36
[  +14 ms] executing: [/opt/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[  +40 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] 0b8abb4724aa590dd0f429683339b1e045a1594d
[        ] executing: [/opt/flutter/] git describe --match v*.*.* --first-parent --long --tags
[   +9 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
[        ] v1.12.13+hotfix.8-0-g0b8abb472
[   +8 ms] executing: [/opt/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[   +8 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] origin/stable
[        ] executing: [/opt/flutter/] git ls-remote --get-url origin
[   +7 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[  +68 ms] executing: [/opt/flutter/] git rev-parse --abbrev-ref HEAD
[  +11 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] stable
[  +41 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[   +5 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[  +83 ms] executing: /opt/android-sdk/platform-tools/adb devices -l
[  +18 ms] Exit code 0 from: /opt/android-sdk/platform-tools/adb devices -l
[        ] List of devices attached
           emulator-5554          device product:sdk_gphone_x86_arm model:AOSP_on_IA_Emulator device:generic_x86_arm transport_id:4
[  +36 ms] 1 connected device:

[  +14 ms] /opt/android-sdk/platform-tools/adb -s emulator-5554 shell getprop
[  +87 ms] ro.hardware = ranchu
[   +6 ms] AOSP on IA Emulator • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)
[  +15 ms] "flutter devices" took 320ms.
Farver answered 12/3, 2020 at 10:4 Comment(8)
does flutter -v run say more interesting stuff? -v stands for "verbose"Warranty
You may as well put your code because this sounds more like a code issue than an issue with the command lineCurvilinear
@Warranty I will post the output of flutter run -v shortly.Farver
@RémiRousselet The project is just the standard flutter demo project created by flutter create NAMEFarver
so on your emulator you see that std demo app and you can interact with the bottom floating button but simply app does not reload?Warranty
@Warranty exactlyFarver
what does flutter -v devices print?Warranty
@Warranty just added it to the original postFarver
F
0

Ok so I was able to fix the problem. It seems to be related to the recent Linux Kernel Versions 5.x.x. You can read about it yourself here:

https://github.com/flutter/flutter/issues/49185

If you don't want to read it: I uninstalled the flutter package and installed the flutter-git package. Then it worked.

Farver answered 19/3, 2020 at 11:53 Comment(0)
A
36

The command is not "stuck". It does not end until you exit the app, and it captures inputs to be able to trigger some actions.

In this state, type any of the following letters to trigger a specific action:

Flutter run key commands.
r Hot reload. 🔥🔥🔥
R Hot restart.
h Repeat this help message.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).
s Save a screenshot to flutter.png.
w Dump widget hierarchy to the console.                                                     (debugDumpApp)
t Dump rendering tree to the console.                                                (debugDumpRenderTree)
L Dump layer tree to the console.                                                     (debugDumpLayerTree)
S Dump accessibility tree in traversal order.                                         (debugDumpSemantics)
U Dump accessibility tree in inverse hit test order.                                  (debugDumpSemantics)
i Toggle widget inspector.                                        (WidgetsApp.showWidgetInspectorOverride)
p Toggle the display of construction lines.                                        (debugPaintSizeEnabled)
o Simulate different operating systems.                                            (defaultTargetPlatform)
z Toggle elevation checker.
P Toggle performance overlay.                                          (WidgetsApp.showPerformanceOverlay)
a Toggle timeline events for all widget build methods.                          (debugProfileWidgetBuilds)
An Observatory debugger and profiler on sdk gphone x86 is available at:
http://127.0.0.1:50607/ZMvxTxjmDD0=/
Acetify answered 12/3, 2020 at 10:11 Comment(5)
I changed the primary color of the demo project and did what you said. The result is D/eglCodecCommon( 5607): setVertexArrayObject: set vao to 0 (0) 1 0 r and nothing changedFarver
You need to press r or RCurvilinear
I know what you mean. I tested it on the laptop of a friend who has it working on windows. The issue is, that the flutter run related process doesn't detach really. I can type whatever I want there. It has no real effect or impact on the program.Farver
Like I said, it is not supposed to "detach".Curvilinear
Alright. Then I was wrong on that one. Still: It doesn't have any effect if I press r. I updated the question, if you want to have a look at it. Thanks for your efforts.Farver
F
0

Ok so I was able to fix the problem. It seems to be related to the recent Linux Kernel Versions 5.x.x. You can read about it yourself here:

https://github.com/flutter/flutter/issues/49185

If you don't want to read it: I uninstalled the flutter package and installed the flutter-git package. Then it worked.

Farver answered 19/3, 2020 at 11:53 Comment(0)
T
-5

You should disable realtime protection of your antivirus

Teneshatenesmus answered 28/10, 2021 at 15:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.