DEV Community

HarmonyOS
HarmonyOS

Posted on

How to Obtain Key Logs for Compilation and Build Issues

Read the original article:How to Obtain Key Logs for Compilation and Build Issues

Problem Description

During daily development, developers frequently use IDEs to develop and run projects, often encountering various IDE-related compilation and build issues and errors. How can one collect information to identify the root cause of these problems?

Background Knowledge

The hvigor-config.json5 file primarily contains the following:

  • Specifies the version number of the development-state build tools for the current project, build tasks, and script dependencies.
  • Specifies relevant capabilities of the build tools, including log levels and execution policies.
  • Specifies runtime node configuration parameters for the build, as well as additional parameters passed to the build scripts.

A daemon is a computer program that runs as a background process rather than under the direct control of an interactive user. The Hvigor daemon is a persistent background process that reduces the time required to run builds.

The Build Analyzer is a tool used to analyze and optimize project build processes. It helps developers visually analyze and troubleshoot performance and memory issues during builds.

Analysis Conclusion

Most issues can be resolved by analyzing logs, while others require additional context about the runtime scenario and conditions. When collecting logs, note the following:

  • Log timeliness: Some logs may be lost after a device restart. Export and analyze logs immediately after discovering an issue.
  • Obfuscated projects: For crashes in Release builds, use the IDE's deobfuscation tool to restore the symbol table and ensure it can be linked to the source code.

Solution

Compilation Errors in the Build Window;

  • First, obtain the IDE version, SDK version (compilation toolchain version, strongly related to hvigor), hvigor version, and hvigor-config.json5 configuration information.Set stacktrace to true and recompile.

1.png

  • Recompile and provide the compilation error information (including stack traces) from the Build window. Ensure the complete build log includes the error stack context (preferably the full error text in a .txt file).

2.png

Daemon-Related Issues;

  • Obtain the hvigor version and a screenshot of hvigor-config.json5.

3.png

  • Retrieve the daemon logs from the Build window.
  • If the error message indicates a specific daemon issue, retrieve the corresponding daemon logs. If not, reproduce the issue and collect the daemon logs again. The logs can typically be found at;
  • **C:\Users\xxxxx.hvigor\daemon\log\5.19.0**
  • Retrieve the idea.log logs by navigating to Help > Show Log in Explorer in the IDE.

5.png

Build Time Issues;

  • Obtain the IDE and hvigor versions.

6.png

  • Enable advanced mode and rebuild the project to collect new analysis logs. In Settings, search for Hvigor, enable "Use build analysis mode," and select verbose (older versions) or advanced (newer versions).

7.png

8.jpg

  • Identify the most time-consuming tasks.
  • Expand the tasks to locate the longest-running subtasks.
  • Finally, retrieve the report.json (preferably for the current compilation). Click the export button in the top-right corner to export the report.

9.png

FAQ

Q: The IDE reports many build errors during compilation. How can I quickly locate the error information?

A: Search for "hvigor ERROR" in the IDE's Build window to quickly locate hvigor-related build errors.

Q: Error messages in the Build Output window are often buried among warnings. How can I filter them out quickly?

A: Under Build Output, click the second button on the left ("Open Build Analyzer") and navigate to Tasks. Click "Error" to view specific error messages.

Related Documents or Links

Analyzing the Build Process

Using the Daemon Process

Written by Can Kankaya

Top comments (0)