This skill analyzes the latest build errors from out/‹product›/last_error.log and provides targeted, actionable fix recommendations.
npx playbooks add skill openharmonyinsight/openharmony-skills --skill build-error-analyzer
This skill specializes in analyzing OpenHarmony build errors from last_error.log and providing fix recommendations only (no automatic code modifications) based on error patterns and historical case studies.
IMPORTANT: This skill provides analysis and recommendations ONLY. It does NOT automatically modify code files.
YOU MUST ALWAYS FOLLOW THIS EXACT SEQUENCE:
out/<product>/build.log → generates out/<product>/last_error.logout/<product>/last_error.logout/<product>/build.log or any other log files (error.log, build_output*.log, etc.)last_error.log contains "build success" or "no error", STOP and report successWhy?:
build.log contains the entire build history (thousands of lines)last_error.log contains ONLY the most recent error block (extracted by script)build.log directly will give you STALE or IRRELEVANT errorsBefore reading ANY errors, ALWAYS run:
# ⚠️ CRITICAL: First cd to OpenHarmony root directory, then run the script
cd <openharmony_root>
foundation/arkui/ace_engine/.claude/skills/build-error-analyzer/script/extract_last_error.sh out/<product>/build.log
⚠️ CRITICAL - CHECK FOR SUCCESS FIRST:
After reading last_error.log, if you see:
build success, no errorno errorIMMEDIATELY STOP and report:
## ✅ 构建成功
最新的构建已经成功完成,没有发现任何错误。
**构建状态**: 成功
**错误信息**: 无
建议: 您可以继续进行开发或测试工作。
DO NOT:
Always use these paths:
foundation/arkui/ace_engine/.claude/skills/build-error-analyzer/script/extract_last_error.sh (relative to OpenHarmony root)out/<product>/build.log (e.g., out/rk3568/build.log) - DO NOT READ DIRECTLYout/<product>/last_error.log (auto-generated in same directory as build.log) - READ ONLY THIS FILE⚠️ SPECIAL CASE - SDK Build Paths:
out/sdk/build.log (NOT out/ohos-sdk/build.log)out/sdk/last_error.log (NOT out/ohos-sdk/last_error.log)out/sdk/ directory instead of out/ohos-sdk/Workflow:
out/<product>/build.log using the script → creates out/<product>/last_error.logout/sdk/build.log → creates out/sdk/last_error.loglast_error.log ONLYCommon Mistakes to Avoid:
build.log directly (will get stale/wrong errors)error.log (contains outdated errors from previous builds)last_error.log shows "build success"<openharmony_root> firstlast_error.log ONLYlast_error.log shows success → STOP and report successThis skill provides ANALYSIS and RECOMMENDATIONS ONLY:
✅ DO:
❌ DO NOT:
last_error.log (error.log, build_output.log, error..log, etc.)⚠️ CRITICAL - NEVER SUGGEST CLEARING LTO CACHE:
thinlto-cache directoryllvmcache-* directoriesout/obj directoryout/ directoryWhy: The user should review and apply fixes manually to maintain control over code changes and understand the modifications. LTO cache issues are extremely rare and clearing caches as first resort masks real problems, wastes rebuild time, and disrupts incremental compilation benefits.
out/<product>/build.log FIRST before readingout/<product>/last_error.log (same directory as build.log)foundation/arkui/ace_engine/.claude/skills/build-error-analyzer/script/extract_last_error.sh (from OpenHarmony root) to generate/update last_error.log before readingout/<product>/build.log in the OpenHarmony output directorylast_error.log contains "build success" or "no error", STOP and report success - DO NOT read other log files like error.log, build_output*.log, etc.last_error.log - NEVER from error.log, build_output.log, error..log, or any other log files⚠️ CRITICAL: This step is MANDATORY and must be done BEFORE reading any errors.
Why this is required:
build.log contains the full build output (old and new errors mixed together)last_error.log is generated in the same directory as build.log⚠️ IMPORTANT: Always navigate to OpenHarmony root first, then run the script:
# Step 1: Navigate to OpenHarmony root directory
cd <openharmony_root>
# Step 2: Run the extraction script (relative path from root)
# Example for rk3568 product - extract errors from out/rk3568/build.log
foundation/arkui/ace_engine/.claude/skills/build-error-analyzer/script/extract_last_error.sh out/rk3568/build.log
# Example for SDK product - extract errors from out/sdk/build.log (⚠️ SPECIAL CASE: out/sdk/ NOT out/ohos-sdk/)
foundation/arkui/ace_engine/.claude/skills/build-error-analyzer/script/extract_last_error.sh out/sdk/build.log
# Example for other products:
foundation/arkui/ace_engine/.claude/skills/build-error-analyzer/script/extract_last_error.sh out/rk3588/build.log
The script will:
out/<product>/build.logout/<product>/last_error.log (same directory)last_error.log if it exists⚠️ DO NOT SKIP THIS STEP
last_error.log exists, RE-EXTRACT to get the latest errorsbuild.log directlylast_error.log after extraction⚠️ CRITICAL: Only read last_error.log from out/<product>/ directory in the OpenHarmony output tree.
After extraction, the error log is located at:
out/<product>/last_error.log (same directory as build.log)Read the extracted error log:
# Check for last_error.log in common product directories
cat out/rk3568/last_error.log
# or for SDK (⚠️ SPECIAL CASE: out/sdk/ NOT out/ohos-sdk/)
cat out/sdk/last_error.log
# or for other products
cat out/rk3588/last_error.log
⚠️ CRITICAL - CHECK FOR SUCCESS FIRST:
Before any analysis, CHECK if the build succeeded:
If last_error.log contains:
build success, no errorno errorIMMEDIATELY STOP and report:
## ✅ 构建成功
最新的构建已经成功完成,没有发现任何错误。
**构建状态**: 成功
**错误信息**: 无
建议: 您可以继续进行开发或测试工作。
DO NOT continue to:
Only if there are actual errors, proceed to categorize them:
Error Categories:
Compare error patterns against historical cases in references/ directory and provide specific solutions.
Case matching priority:
CRITICAL: This step provides recommendations ONLY. Do NOT use Edit/Write tools to modify code.
Based on error type and matched cases, provide:
Recommended Output Format:
## 构建错误分析
### 错误类型
[编译错误/链接错误/构建系统错误]
### 错误位置
[文件路径:行号]
### 错误信息
[完整的错误消息]
### 根本原因
[详细解释为什么会出现这个错误]
### 修复建议
**文件**: [完整文件路径:行号]
**当前代码**:
[错误代码片段]
**应修改为**:
[正确代码片段]
**修改说明**: [解释为什么要这样修改]
### 验证步骤
1. [第一步验证操作]
2. [第二步验证操作]
3. [如何确认修复成功]
### 参考
[相关的历史案例或文档链接]
DO NOT:
DO:
Error signature:
ld.lld: error: undefined symbol: <symbol_name>
>>> referenced by <file>:<line>
⚠️ CRITICAL ANALYSIS WORKFLOW (MUST FOLLOW IN ORDER):
When encountering ld.lld: error: undefined symbol: linker errors, you MUST follow this sequence:
Check the error message to determine which library has the undefined symbol:
libace.z.so, libace_compatible.z.so, libarkoala_native_ani.so, libace_ndk.z.so)>>> referenced by)Scenario 1: libace/libace_compatible Main Library Cannot Find Symbol
Symptoms:
libace.z.so or libace_compatible.z.soRoot Cause:
Solution:
grep -r "SymbolName" --include="*.cpp" frameworks/
grep -r "implementation_file.cpp" frameworks/*/BUILD.gn
ace_core_ng_source_set # Find where similar files in same directory are compiled
find frameworks/core/components_ng/pattern/<pattern_name>/ -name "*.cpp"
grep "similar_file.cpp" frameworks/core/BUILD.gn
Scenario 2: Other Library Links with libace/libace_compatible Dependency
Symptoms:
libace or libace_compatibledeps includes libace/libace_compatibleRoot Cause:
⚠️ CRITICAL: Distinguish Non-Template vs Template FIRST
Before applying any solution, determine the type:
undefined symbol error
↓
Is it a non-template class method?
→ YES: Use Non-Template Solution (Step 1A)
→ NO: Use Template Solution (Step 1B, see Scenario 3)
Solution (Step-by-Step):
Step 1A: For NON-TEMPLATE class methods ⭐
⚠️ CHECK 1: Does the class have ACE_FORCE_EXPORT?
// Case A: Class WITHOUT ACE_FORCE_EXPORT
class PaddingPropertyF {
float Width() const;
};
// Case B: Class WITH ACE_FORCE_EXPORT
class ACE_FORCE_EXPORT PaddingPropertyF {
float Width() const;
};
For Case A (Class WITHOUT export) - PREFERRED METHOD:
ACE_FORCE_EXPORT to method declaration in header (.h file)Example (PaddingPropertyF case):
// In header file (.h) - Add ACE_FORCE_EXPORT to method declarations
class PaddingPropertyF {
ACE_FORCE_EXPORT float Width() const; // ← Add here
ACE_FORCE_EXPORT float Height() const; // ← Add here
};
// In implementation file (.cpp) - NO ACE_FORCE_EXPORT here
float PaddingPropertyF::Width() const
{
return left.value_or(0.0f) + right.value_or(0.0f);
}
float PaddingPropertyF::Height() const
{
return top.value_or(0.0f) + bottom.value_or(0.0f);
}
For Case B (Class WITH export):
ACE_FORCE_EXPORT to individual methodsExample:
// In header file (.h) - Class already exported
class ACE_FORCE_EXPORT PaddingPropertyF { // ← Entire class exported
float Width() const; // Automatically exported
float Height() const; // Automatically exported
};
// In implementation file (.cpp) - No individual exports needed
float PaddingPropertyF::Width() const { /* implementation */ }
Step 1B: For TEMPLATE class methods/functions (see Scenario 3)
Template-specific rules apply - refer to Scenario 3 for detailed steps.
Step 2: Add to libace.map with fine-grained symbol names ⭐
After adding exports, add the symbol to build/libace.map:
# Check if symbol already in libace.map
grep "ClassName" build/libace.map
Required changes:
build/libace.map whitelistExample - Regular Methods:
# In build/libace.map
{
global:
# ✅ FINE-GRAINED - Export specific methods (PREFERRED for non-template)
OHOS::Ace::PaddingPropertyF::Width*;
OHOS::Ace::PaddingPropertyF::Height*;
# ⚠️ ACCEPTABLE - Export entire class (if class has ACE_FORCE_EXPORT)
OHOS::Ace::PaddingPropertyF::*;
# ⚠️ DIFFERENT - Template patterns (use wildcards)
void?OHOS::Ace::StringUtils::StringSplitter*; # Template function
OHOS::Ace::NG::LayoutConstraintT*; # Template class
};
}
Why fine-grained for non-templates?
Common Mistakes (DO NOT do):
ClassName::*; when only specific methods are neededStep 3: Verify symbol export:
nm -D out/rk3568/arkui/ace_engine/libace.z.so | grep SymbolName
Common mistakes (DO NOT do):
ClassName::*; when only specific methods are needed (⚠️ COMMON MISTAKE)ACE_FORCE_EXPORT__attribute__((visibility("default"))) directly⚠️ Example of Common Mistake - Over-Exporting:
// ❌ WRONG - Exports entire class when only constructors needed
OHOS::Ace::VelocityTracker::*; // Exports ALL members unnecessarily
// ✅ CORRECT - Fine-grained constructor export
OHOS::Ace::VelocityTracker::VelocityTracker*; // Only constructors
When to use each pattern:
ClassName::MethodName*; for specific methodsClassName::ClassName*; for all constructor overloadsClassName::*; ONLY when most/all members are exported (rare)Scenario 3: Template Function Instantiation Issues
Symptoms:
StringSplitter<Color>, TransformStrCase<std::string>)Root Cause:
Solution (3 steps required):
Step 1: Add extern template declaration in header (.h)
Add explicit template declaration for new specialization:
// In header file (.h)
extern template void StringSplitter<Color>(const std::string& source, char delimiter,
Color (*)(const std::string&), std::vector<Color>& out);
Step 2: Add ACE_FORCE_EXPORT to template function declaration
// In header file (.h) - Template function declaration
template<class T>
ACE_FORCE_EXPORT
void StringSplitter(
const std::string& source, char delimiter, T (*func)(const std::string&), std::vector<T>& out);
Step 3: Add explicit instantiation in .cpp
// In implementation file (.cpp)
template void StringSplitter<Color>(const std::string& source, char delimiter,
Color (*)(const std::string&), std::vector<Color>& out);
Step 4: Add ACE_FORCE_EXPORT to template implementation
// In implementation file (.cpp) - Template function implementation
template<class T>
ACE_FORCE_EXPORT
void StringSplitter(
const std::string& source, char delimiter, T (*func)(const std::string&), std::vector<T>& out)
{
// implementation
}
Step 5: Add to libace.map whitelist
# In build/libace.map
{
global:
OHOS::Ace::StringUtils::*;
void?OHOS::Ace::StringUtils::StringSplitter*; # Match template instantiations
void?OHOS::Ace::StringUtils::TransformStrCase*; # Match template instantiations
};
⚠️ Template Special Notes:
*Weekly roundup of top Claude Code skills, MCP servers, and AI coding tips.