redwoolf redwoolf - 1 year ago 218
Android Question

Android Gradle merged Values.xml uses wrong namespace

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

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

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

<resources xmlns:ns1="">

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

Answer Source

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 ;)

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="">
    <item name="android:textSize">14sp</item>
    <item name="android:textColor">@color/content</item>

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.

Removing xmlns:custom="" fixed it.

Versions used: Gradle 1.10 and ''