Android / Gradle:基于构建类型*和*产品风格的应用程序名称 [英] Android/Gradle: App name based on build type *and* product flavor

查看:114
本文介绍了Android / Gradle:基于构建类型*和*产品风格的应用程序名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3种构建类型(debug,UAT和release)和2种flavor(国际化和本地化)。 我有我的应用程序名称定义在一个名为xml文件product_name.xml:

 < resources xmlns:tools =http://schemas.android.com/tools 
工具:ignore =MissingTranslation>

< string name =app_title> Awesome App< / string>

< /资源>

我想根据构建变体(构建类型+风格)更改应用程序名称。例如:


  • 对于变体InternationalDebug - > Awesome App(intl)调试

  • >真棒应用程序(intl)UAT

  • 对于变体LocalUAT - >真棒应用程序(本地)UAT



等等。



我该如何处理这件事?我见过的所有示例都向我展示了如何根据 构建类型或风格但 更改名称。



 

code> src
| - > InternationalDebug
| | - > res / values / strings.xml< - 将您的app_title放置在这里
| - > LocalUAT
| | - > res / values / strings.xml< - 将您的app_title放置在这里
| - > main(包含你的主要源代码)


I have 3 build types (debug, UAT and release) and 2 flavors (international and local).

I have my app name defined in a xml file named "product_name.xml":

<resources xmlns:tools="http://schemas.android.com/tools"
    tools:ignore="MissingTranslation">

   <string name="app_title">Awesome App</string>

</resources>

I want to change the app name based on the build variant (build type + flavor). E.g:

  • For variant InternationalDebug -> Awesome App (intl) debug
  • For variant InternationalUAT -> Awesome App (intl) UAT
  • For variant LocalUAT -> Awesome App (local) UAT

and so on.

How would I do about this? All the examples I've seen show me how to change the name based on either build type or the flavor but not both.

解决方案

You could create src-folders for your variants and place your custom strings there:

src
|-> InternationalDebug
|   |->res/values/strings.xml <-- place your app_title here
|-> LocalUAT
|   |->res/values/strings.xml <-- place your app_title here
|-> main (contains your main source code.

这篇关于Android / Gradle:基于构建类型*和*产品风格的应用程序名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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