HarmonyOS 踩坑日记(1)

文章描述了在HarmonyOS项目中遇到的编译错误,涉及到修改module.json中的模块类型、移除entryModules、以及修复hvigorFILE.ts文件的问题,主要关注资源名未知和编译器设置。
摘要由CSDN通过智能技术生成

主模块引入子模块报 

> hvigor ERROR: Failed :entry:default@CompileArkTS... 
> hvigor ERROR: ArkTS Compiler Error
ERROR: ArkTS:ERROR File: D:\code\harmonyOs\xxx\xxx\src\main\ets\common\Constants.ets:2:18
 Unknown resource name 'main_text_color'.
ERROR: ArkTS:ERROR File: D:\code\harmonyOs\xxx\xxx\src\main\ets\common\Constants.ets:3:13
 Unknown resource name 'color_ffffff'.

一、修改子模块module.json5模块类型:

{
  "module": {
    "name": "XygjProvinceCard",
    "type": "har",
    "description": "$string:module_desc",
    "deviceTypes": [
      "phone",
      "tablet",
      "2in1"
    ],
    "installationFree": false,
  }
}

二、build-profile.json5去掉entryModules

{
  "apiType": "stageMode",
  "buildOption": {
    "arkOptions": {
      // "apPath": "./modules.ap"  /* Profile used for profile-guided optimization (PGO), a compiler optimization technique to improve app runtime performance. */
    }
  },
  "buildOptionSet": [
    {
      "name": "release",
      "arkOptions": {
        "obfuscation": {
          "ruleOptions": {
            "enable": true,
            "files": [
              "./obfuscation-rules.txt"
            ]
          }
        }
      }
    },
  ],
  "targets": [
    {
      "name": "default"
    },
    {
      "name": "ohosTest",
    }
  ]
}

三、修改hvigorfile.ts文件

export { harTasks } from '@ohos/hvigor-ohos-plugin';

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值