如何改变应用程序的名称每个摇篮生成类型 [英] How to change app name per Gradle build type

查看:121
本文介绍了如何改变应用程序的名称每个摇篮生成类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出一个办法能够改变我的应用程序的应用程序名称每个生成类型的摇篮。举例来说,我想调试版本有-debug和QA版本有-qa。

I am trying to figure out a way to be able to change my application's app name per build type in gradle. For instance, I would like the debug version to have -debug and the qa version to have -QA.

我所熟悉的:

调试{         applicationIdSuffix的.debug         versionNameSuffix-DEBUG }

debug { applicationIdSuffix '.debug' versionNameSuffix '-DEBUG' }

不过,我似乎无法找到一个摇篮命令应用程序的变化,在启动的时候。

However, I can't seem to find a gradle command to apply the change of the app when in the launcher.

推荐答案

如果按应用程序名,你的意思是安卓标签&LT ;用途> ,最简单的解决办法是有一个字符串资源这一点(例如,机器人:标签=@字符串/ APP_NAME) ,然后在不同版本的该字符串资源一个的src /调试/ sourceset。

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.

您可以看到,在此示例项目,在那里我有一个替代品 APP_NAME 的src /调试/ RES /价值/ strings.xml中,这将用于调试构建。 发布构建将使用 APP_NAME 的版本的src /主/

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/.

这篇关于如何改变应用程序的名称每个摇篮生成类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆