摇篮resValue导致重复的字符串资源 [英] Gradle resValue causes duplicate string resources

查看:2901
本文介绍了摇篮resValue导致重复的字符串资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Andr​​oid manifest文件定义了应用程序名称如下:

My Android manifest file defines the app name as follows:

android:label="@string/app_name"

APP_NAME的相应条目在res /价值/ strings.xml中存在

A corresponding entry for app_name exists in res/values/strings.xml

现在,在我的build.gradle,我重新定义了应用程序名称为公测打造如下:

Now, in my build.gradle, I redefine the app name for beta build as follows:

buildTypes {

    beta {
        applicationIdSuffix ".beta"
        debuggable true
        resValue "string", "app_name", "MyTest Beta"
    }
}

然而,当我组装包,摇篮抱怨重复的字符串资源。

However, when I assemble the package, Gradle complains of a duplicate string resource.

我可以简单地从string.xml删除APP_NAME令牌。然而,在这种情况下,Android的Studio报表中的清单文件有问题。

I could simply remove the app_name token from string.xml. However, in that case, Android Studio reports a problem with the manifest file.

我该如何解决这个问题?问候。

How do I fix this? Regards.

推荐答案

本来就不乱用resValue。您可以使用调试sourceset,让您重新定义其他字符串在调试为好。创建以下文件并重新定义APP_NAME串在了那里。

Shouldn't have to mess with a 'resValue.' You can use the debug sourceset which will allow you to redefine other strings in debug as well. Create the following file and redefine the 'app_name' string in there.

src/debug/res/values/strings.xml

只要确保你没有像你的build.gradle的sourceSets以下任何

Just make sure you don't have anything like the following in your build.gradle's sourceSets

debug.setRoot('build-types/debug')

这篇关于摇篮resValue导致重复的字符串资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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