How to change app name per Gradle build type(如何更改每个 Gradle 构建类型的应用程序名称)
问题描述
我正在尝试找出一种方法,能够在 gradle 中更改每个构建类型的应用程序的应用程序名称.
I am trying to figure out a way to be able to change my application's app name per build type in gradle.
例如,我希望调试版本具有 <APP_NAME>-debug
,而 qa 版本具有 <APP-NAME>-QA
.
For instance, I would like the debug version to have <APP_NAME>-debug
and the qa version to have <APP-NAME>-QA
.
我熟悉:
debug {
applicationIdSuffix '.debug'
versionNameSuffix '-DEBUG'
}
但是,在启动器中,我似乎找不到 gradle 命令来应用应用程序的更改.
However, I can't seem to find a gradle command to apply the change of the app when in the launcher.
推荐答案
如果应用名称"是指 上的
android:label
,则最简单的解决方案是将该点指向一个字符串资源(例如,android:label="@string/app_name"
),然后在 src/debug 中使用该字符串资源的不同版本/
源集.
If by "app name", you mean android:label
on <application>
, the simplest solution is to have that point at a string resource (e.g., android:label="@string/app_name"
), then have a different version of that string resource in a src/debug/
sourceset.
您可以在 这个示例项目中看到这一点,我在 src/debug/res/values/strings.xml
中替换了 app_name
,它将应用于 debug
构建.release
构建将使用 src/main/
中的 app_name
版本.
You can see that in this sample project, where I have a replacement for app_name
in src/debug/res/values/strings.xml
, which will be applied for debug
builds. release
builds will use the version of app_name
in src/main/
.
这篇关于如何更改每个 Gradle 构建类型的应用程序名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何更改每个 Gradle 构建类型的应用程序名称


基础教程推荐
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01