如何在构建文件的gradle更改Android应用名称 [英] how to change android app name in the build gradle file

查看:494
本文介绍了如何在构建文件的gradle更改Android应用名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建的gradle用2小的Andr​​oid应用程序不同的口味,我想只知道如果我能在在的​​build.gradle xml文件编辑应用程序名称,我的不同口味。

I'm creating different flavors using gradle for 2 small android apps ,i wanna just know if i can edit app name on the xml file in the build.gradle , for my different flavors .

推荐答案

你是什么应用程序名称是什么意思?在清单或应用程序的名称应用程序包的名称,因为它出现在启动?

What do you mean by app name? the application package name in the manifest or the application name as it appears in the launcher?

如果是前者,做的:

android {
  productFlavors {
    flavor1 {
      packageName 'com.example.flavor1'
    }
    flavor2 {
      packageName 'com.example.flavor2'
    }
  }
}

这是可以覆盖的应用程序的名称很好,但你必须提供一个覆盖香味,而不是资源

It's possible to override the app name as well but you'd have to provide a flavor overlay resource instead.

因此​​,创建下列文件:

So create the following files:


  • 的src / flavor1 / RES /价值/ strings.xml中

  • 的src / flavor2 / RES /价值/ strings.xml中

  • src/flavor1/res/values/strings.xml
  • src/flavor2/res/values/strings.xml

而在他们刚刚改写包含您的应用程序名称的字符串资源(一个通过类似 @字符串/ APP_NAME您的清单中使用的主要活动标签)。根据需要也可以提供不同的翻译。

And in them just override the string resource that contains your app name (the one that your manifest use for the main activity label through something like @string/app_name). You can also provide different translations as needed.

这篇关于如何在构建文件的gradle更改Android应用名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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