Android的摇篮合并Values​​.xml使用错误的命名空间摇篮、错误、空间、Android

2023-09-04 03:53:42 作者:浅怀感伤

在一个项目转换到Android编译系统,每当我试图编译我得到这个错误的过程。

In the process of converting a project to the Android build system I get this error whenever I attempt to compile.

摇篮:错误解析XML:preFIX不能绑定到保留的命名空间的名称之一

合并后的values​​.xml文件包含以下根元素:

The merged values.xml file contains the following root element:

<资源的xmlns:NS1 =htt​​p://www.w3.org/2000/xmlns/>

这是什么错误的原因和如何能解决吗?

What is the cause of this error and how can it be fixed?

推荐答案

我只花了约2小时通过的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 ;)

总之,这里是什么我们造成这种模糊的摇篮错误:有些款式有一个的xmlns:定制属性是在 RES /值定义/ styles.xml

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>

正如你可以看到自定义命名空间甚至不使用。出于某种原因,蚂蚁和ADT构建没在意这个属性,但摇篮:processDebugResources 任务barfed一个不是非常有帮助的错误信息

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:定制=htt​​p://schemas.android.com/apk/res-auto固定它

版本中使用:摇篮1.10和com.android.tools.build:gradle:0.8.0

Versions used: Gradle 1.10 and 'com.android.tools.build:gradle:0.8.0'