未采用其它三方加固,打生产包时是否需要主动在entry的build\_profile.json5中开启加固,还有obfuscation-rules.txt这个文件中未添加自定义的混淆配置,混淆规则是全部都有吗,还是不混淆?
"buildOptionSet": [
{
"name": "release",
"arkOptions": {
"obfuscation": {
"ruleOptions": {
"enable": true,
"files": [
"./obfuscation-rules.txt"
]
},
"consumerFiles": [
"./consumer-rules.txt"
]
}
}
}
]
1、加固没有强制要求,可以根据实际需求进行加固,但不建议过多加固。
2、从DevEco Studio 5.0.3.600开始,新建工程默认关闭代码混淆功能,如果在模块配置文件build-profile.json5开启代码混淆,混淆规则配置文件obfuscation-rules.txt中默认开启-enable-property-obfuscation、-enable-toplevel-obfuscation、-enable-filename-obfuscation、-enable-export-obfuscation四项推荐选项,可进一步在obfuscation-rules.txt文件中更改配置。
使用约束如下:仅支持Stage工程、编译模式为release、模块及模块依赖的HAR均未配置关闭混淆的规则-disable-obfuscation。
文档说明如下:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5\#%E6%B7%B7%E6%B7%86%E8%A7%84%E5%88%99%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6