DEV Community

HarmonyOS
HarmonyOS

Posted on

restool Compilation Error – 'distro' not object

Read the original article:restool Compilation Error – 'distro' not object

Problem Description

When compiling all resources using the restool command-line tool, the following error occurs:

Error: 'distro' not objectCopy codeCopy code
Enter fullscreen mode Exit fullscreen mode

Background Knowledge

  • restool is a resource compilation tool used in HarmonyOS application projects. It compiles resource files, generates resource indexes, and enables resource access via the resource management interface.
  • The tool is located in the toolchains subdirectory within the SDK installation path.

Troubleshooting Process

Common error cases observed with restool:

Error Message Cause
Error: input path empty. The -i option (input directory) is missing.
Error: output path empty. The -o option (output directory) is missing.
Error: package name empty. The -p option (package or bundle name) is missing.
Error: resource header path empty. The -j option (resource header file) is missing.
Error: set -e and --defined-ids cannot be used together. The -e and --defined-ids options cannot be used together.
Error: output path exists. The output path already exists; the -f overwrite option is missing.
Error: open json failed. The JSON file path is incorrect or does not exist.
Error: 'distro' not object. The JSON file provided through -j is malformed—wrong structure or delimiters.
Error: invalid color value. Color value format invalid; only $color:xxx, #rgb, #argb, #rrggbb, or #aarrggbb allowed.
Error: id_defined.json seq = 0 id must be in a valid range. A resource ID is out of the valid range.
Error: 'xxx' and 'xxx1' defined the same ID. Duplicate resource IDs found.
Error: invalid input 'xxx'. Input path is too long or doesn’t exist.

Analysis Conclusion

The error 'distro' not object means the JSON file specified with -j is improperly structured—likely due to a syntax mistake, incorrect delimiter, or missing braces—causing parsing failure during compilation.

Solution

  • Carefully review the JSON file used with the -j option.
  • Ensure all fields adhere to proper JSON syntax:
    • Keys and values correctly quoted.
    • Brackets {}, [] and commas appropriately placed.
  • Use an online JSON validator to verify the file is valid before re-running restool.

Verification Result

After fixing the JSON structure and validating the file, the restool compilation completes successfully, and the 'distro' not object error no longer occurs.

Related Documents or Links

Written by Merve Yonetci

Top comments (0)