环境:
macos
android studio
安卓原生项目融合单独的flutter项目
flutter热更新调试步骤如下:
1、先打开安卓模拟器,关闭或卸载需要调试的app,然后进入flutter目录(/Users/who/space/flutter_project)
whodeMacBook-Pro:flutter_project who$ pwd
/Users/who/flutter_project
whodeMacBook-Pro:flutter_project who$flutter attach
Waiting for a connection from Flutter on Android SDK built for x86...
如果有多个模拟器,可通过命令指定
whodeMacBook-Pro:flutter_project who$ adb devices
List of devices attached
emulator-5554 device
whodeMacBook-Pro who$ flutter attach -d 'emulator-5554'
2、run模式启动安卓项目(不需要debug模式),项目启动后控制台会有提示:
whodeMacBook-Pro:flutter_project who$ flutter attach
Waiting for a connection from Flutter on Android SDK built for x86...
**Syncing files to device Android SDK built for x86...
9,090ms (!)
🔥 To hot reload changes while running, press "r". To hot restart (and rebuild state), press "R".
An Observatory debugger and profiler on Android SDK built for x86 is available at: http://127.0.0.1:51053/H2OAWGkKPvI=/
For a more detailed help message, press "h". To detach, press "d"; to quit, press "q".**
3、改动flutter代码,测试热加载/热重启
To hot reload changes while running, press "r". To hot restart (and rebuild state), press "R".
An Observatory debugger and profiler on Android SDK built for x86 is available at: http://127.0.0.1:51053/H2OAWGkKPvI=/
For a more detailed help message, press "h". To detach, press "d"; to quit, press "q".
//flutter代码改动后,这里键入 r
Initializing hotreload...
Reloaded 2 of 978 libraries in 386ms.
//flutter代码改动后,这里键入 R
Performing hotreload...
Reloaded 0 of 978 libraries in 147ms.
观察flutter界面内容,内容已change。
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。