问题描述
在将项目转换为 Android 构建系统的过程中,每当我尝试编译时都会收到此错误.
In the process of converting a project to the Android build system I get this error whenever I attempt to compile.
Gradle:解析 XML 时出错:前缀不能绑定到保留的命名空间名称之一
合并后的 values.xml 文件包含以下根元素:
The merged values.xml file contains the following root element:
<资源 xmlns:ns1="http://www.w3.org/2000/xmlns/">
此错误的原因是什么?如何解决?
What is the cause of this error and how can it be fixed?
推荐答案
我刚刚花了大约 2 个小时来挖掘破坏了我们的 Gradle 构建的 Git 提交.此提交包含超过 200 个更改的文件,其中包含 4000 多条修改的行.你可以想象它是多么有趣;)
I just spent around 2 hours digging through the Git commit that broke our Gradle build. This commit contained over 200 changed files with 4000+ modified lines. You can imagine how much fun it was ;)
无论如何,这就是导致我们这个模糊的 Gradle 错误的原因:在 res/values/styles.xml 中定义了一些具有 xmlns:custom 属性的样式:
Anyway, here is what caused this obscure Gradle error for us: Some styles with a xmlns:custom attribute were defined in res/values/styles.xml:
<style name="content" xmlns:custom="http://schemas.android.com/apk/res-auto">
<item name="android:textSize">14sp</item>
<item name="android:textColor">@color/content</item>
</style>
如您所见,甚至没有使用 custom 命名空间.出于某种原因,Ant 和 ADT 构建并不关心这个属性,但是 Gradle :processDebugResources 任务却出现了一条不太有用的错误消息.
As you can see the custom namespace is not even used. For some reason the Ant and ADT builds did not care about this attribute, but the Gradle :processDebugResources task barfed with a not very helpful error message.
删除 xmlns:custom="http://schemas.android.com/apk/res-auto" 修复它.
使用的版本:Gradle 1.10 和 'com.android.tools.build:gradle:0.8.0'
Versions used: Gradle 1.10 and 'com.android.tools.build:gradle:0.8.0'
这篇关于Android Gradle 合并 Values.xml 使用错误的命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)