gpt4 book ai didi

android - 如何在控制台中使用 flutter 热重载?

转载 作者:行者123 更新时间:2023-12-04 13:15:44 27 4
gpt4 key购买 nike

我想在不使用 Android Studio 或其他 IDE 的情况下开发带有 flutter 的 android 应用程序。我目前正在我的基于 Arch 的 linux 发行版上安装所有东西。除了热重载功能外,一切对我来说都很好。当我做 flutter run (甚至 flutter run --hot ),命令执行卡在以下点:

$ 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

卡住我的意思是,程序只是输出日志消息,而忽略了我的所有输入。我已经尝试过按 rR但它只会导致

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

并且仿真设备没有反应。

如果您有兴趣,这里有一些输出:
flutter doctor结果是:

[✓] 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)

由于它被请求,这里是 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
flutter devices -v 的输出是

$ 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.

最佳答案

该命令没有“卡住”。它在您退出应用程序之前不会结束,它会捕获输入以触发某些操作。

在此状态下,键入以下任何字母以触发特定操作:

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=/

关于android - 如何在控制台中使用 flutter 热重载?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60651709/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com