在 Gluon 中自定义 AndroidManifest.xml
如果我不在 Gluon 项目中创建 src/android/AndroidManifest.xml 文件,那么 mvn gluonfx:package 命令会为我创建一个具有一些相对合理的默认值的文件。但是,我需要对我的应用程序生成的 AndroidManifest.xml 进行一些更改(例如指示支持多种屏幕分辨率,并且我需要添加 BILLING 权限)。
如果我按照 gluonfx:package 期间的建议将生成的 AndroidManifest.xml 复制到 src/android/AndroidManifest.xml,则 Gluon 不再为我更新版本代码和版本名称字段。我也不确定手动编辑 AndroidManifest.xml 文件是否有任何其他副作用。
所以我的问题是:
- 管理 Gluon 项目的 AndroidManifest.xml 的最佳实践是什么?
- 作为 CI/CD 管道的一部分,人们如何处理更新手动编辑的文件中的版本代码和版本名称,而我不想为每个构建手动编辑 AndroidManifest.xml?
- 在 gluonfx:package 命令之外管理 AndroidManifest.xml 是否存在任何陷阱?
If I don't create a src/android/AndroidManifest.xml file in my Gluon project, then the mvn gluonfx:package command creates one for me with some relatively sensible defaults. However, I need to make some changes to the generated AndroidManifest.xml for my app (such as indicating support for multiple screen resolutions, and I need to add the BILLING permission).
If I copy the generated AndroidManifest.xml to src/android/AndroidManifest.xml as suggested during gluonfx:package, then Gluon no longer updates the version code and version name fields for me. I'm also not sure if there any any other side-effects to manually editing the AndroidManifest.xml file.
So my questions are:
- What's the best practice when it comes to managing AndroidManifest.xml for a Gluon project?
- How do folks deal with updating the version code and version name in a manually edited file as part of a CI/CD pipeline, where I don't want to have to manually edit AndroidManifest.xml for each build?
- Are there any pitfalls to managing the AndroidManifest.xml outside the gluonfx:package command?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如此处所述,您应该使用
来定义每个新版本所需或需要更新的值。对于 Android,除了密钥库签名属性之外,您还可以定义:
例如:
因此,如果您需要将 AndroidManifest 添加到
src/Android
(在target/gluonfx/aarch64-android/gensrc/android/AndroidManifest.xml
),为了添加/修改其中的一部分,每当您在pom。关于 CI/CD,请查看 HelloGluon CI 示例。
它没有自定义清单,但它展示了如何在 CI 环境中处理
ReleaseConfiguration
和更新发布值。pom 定义了一些使用的属性通过releaseConfiguration块:
这些属性最终是为每个配置文件:
运行 Android 时 job,使用所需的变量和秘密:
As documented here, you should use
<releaseConfiguration/>
to define the values that are required or need to be updated for each new release.For Android, besides the keystore signing properties, you can also define:
like:
So in case you need to add the AndroidManifest to
src/Android
(the one that was generated intarget/gluonfx/aarch64-android/gensrc/android/AndroidManifest.xml
), in order to add/modify part of it, it will be always updated for those three values, whenever you change them in the pom.About CI/CD, have a look at the HelloGluon CI sample.
It doesn't have a custom manifest, but it shows how to deal with
ReleaseConfiguration
and updating release values in a CI environment.The pom defines some properties that are used by the releaseConfiguration block:
These properties are ultimately defined for each profile:
When running the Android job, the required variables and secrets are used: