简体   繁体   English

Android / Gradle:基于构建类型*和*产品风格的应用程序名称

[英]Android/Gradle: App name based on build type *and* product flavor

I have 3 build types (debug, UAT and release) and 2 flavors (international and local). 我有3种构建类型(调试,UAT和发布​​)和2种口味(国际和本地)。

I have my app name defined in a xml file named "product_name.xml": 我在名为“product_name.xml”的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). 我想根据构建变体(构建类型+风格)更改应用程序名称。 Eg: 例如:

  • For variant InternationalDebug -> Awesome App (intl) debug 对于变体InternationalDebug - > Awesome App(intl)debug
  • For variant InternationalUAT -> Awesome App (intl) UAT 对于变体InternationalUAT - > Awesome App(intl)UAT
  • For variant LocalUAT -> Awesome App (local) UAT 对于变体LocalUAT - > Awesome App(本地)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文件夹,并将自定义字符串放在那里:

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.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM