Android Gradle合并Values.xml使用错误的命名空间

red*_*olf 11 android android-gradle-plugin

在将项目转换为Android构建系统的过程中,每当我尝试编译时都会收到此错误.

Gradle: Error parsing XML: prefix must not be bound to one of the reserved namespace names

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

<resources xmlns:ns1="http://www.w3.org/2000/xmlns/">

导致此错误的原因是什么?如何解决?

fri*_*mle 15

我花了大约2个小时来挖掘Git提交,打破了我们的Gradle构建.此提交包含超过200个已更改的文件,其中包含4000多条修改后 你可以想象它有多么有趣;)

无论如何,这就是为我们造成这个模糊的Gradle错误的原因:一些带有xmlns:custom属性的样式定义在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>
Run Code Online (Sandbox Code Playgroud)

如您所见,custom甚至没有使用命名空间.由于某种原因,Ant和ADT构建不关心此属性,但Gradle :processDebugResources任务禁止使用不太有用的错误消息.

删除xmlns:custom="http://schemas.android.com/apk/res-auto"固定它.

使用的版本:Gradle 1.10和 'com.android.tools.build:gradle:0.8.0'