HarmonyOS 怎么获取项目的versionName?

像其他系统可以 BuildConfig.VERSION_NAME直接获取到versionName,那HarmonyOS 当中怎么获取呢?还有就是其他系统中可以在build.gradle中创建buildConfigField,如:buildConfigField ‘String’, ‘xxxxx’, ‘“xxxxxxxx”’,HarmonyOS 当中可以创建吗?创建完又如何获取呢?

HarmonyOS
2024-12-28 07:59:59
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
superinsect

我们可以通过bundleManager.getBundleInfo获取versionName,具体详情请参考以下文档:

https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-bundlemanager-bundleinfo-V5

build-profile.json5配置文件中buildModeSet可以生成构建模式集合,具体参考以下文档:

https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/ide-hvigor-get-build-profile-para-guide-0000001759228286-V5#section863683255419

分享
微博
QQ
微信
回复
2024-12-28 11:18:32
相关问题
如何获取HarmonyOS 项目的SHA1?
5681浏览 • 1回复 待解决
HarmonyOS 项目的防抖和截流怎么实现
501浏览 • 1回复 待解决
如何获取versionName
586浏览 • 1回复 待解决
HarmonyOS 更改项目的bundlename后报错
2013浏览 • 1回复 待解决