1. Environment construction
Refer to the article HarmonyOS Flutter Practice: 01-Building the development environment to build the development environment. IDE Install DevEco and VsCode/Android Studio.
2. Configuration
If it is vscode, you can add the following configuration in the .vscode/launch.json file
{
"name": "ohos-app (attach mode)",
"cwd": "packages/apps/ohos_app",
"request": "attach",
"type": "dart",
},
{
"name": "ohos_app",
"cwd": "packages/apps/ohos_app",
"request": "launch",
"type": "dart"
},
After adding successfully, the launch option will appear in the Tab column of running and scheduling. Two configurations are added here, one is the Attach mode and the other is the normal running mode.
3. View logs
To view logs, you can view the Flutter project logs in the IDE debugging console where Flutter is running, and you can use the hdc hilog
command or DevEco to view the system logs.
4. Debug Flutter
There are two main debugging solutions.
Solution 1
Run the Flutter project directly in the IDE. You can choose Andriod Studio or VsCode for the IDE. Click Debug in the debug bar to run.
Solution 2
Adapt to DecEco to run the Harmony project. Note that you need to open the ohos Harmony directory code. After the IDE analysis is completed, click Run.
When the app is successfully launched on the Harmony device, immediately call up the Command Pallet in Vscode, find Flutter Attach, and connect the Flutter debugger to the host machine
Then add breakpoints, use hot reload to reload Flutter, and debug the project code.
Debug ArkTs
You need to use DevEcho to open the project, click the Debug Entry button next to Run, and start program debugging.
Debug Webview
Refer to the article Harmony Flutter Practice: 04-How to use DevTools to debug Webview for Webview debugging.
Top comments (0)