如何排除使用摇篮和Android Studio的资源文件? [英] How to exclude file from resources using Gradle and Android Studio?
问题描述
我在这是从一个.template扩展名的文件生成我的项目生成的字符串资源的XML文件。我试图排除此模板的构建,因为它给了我重复的资源错误。以下不为我工作,我坚持:
I have a generated string resource xml file in my project which is generated from a file with a .template extension. I'm trying to exclude this template from the build since it gives me duplicate resource error. The following does not work for me and I'm stuck:
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['res']
resources.exclude '**/build_id.template'
res.srcDirs = ['res']
res.exclude '**/build_id.template'
assets.srcDirs = ['assets']
}
}
错误:
Error:Error: Duplicate resources: <project-dir>/res/values/build_id.template:string/build_id, <project-dir>/res/values/build_id.xml:string/build_id
我怎样才能排除特定的资源文件是否正确?
How can I exclude a particular resource file properly?
推荐答案
有关其他人的工作项目中的理智,我强烈反对把模板(输入),并自动生成的文件(输出)在同一目录下。你可以创建你自己的,独立的模板目录,以保持它被包含在构建。
For the sanity of other folks working on your project, I strongly discourage putting templates (input) and auto-generated files (output) in the same directory. You could create your own, independent 'templates' directory to keep it from being included in your build.
这篇关于如何排除使用摇篮和Android Studio的资源文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!