Android Gradle merged Values.xml uses wrong namespace

前端 未结 6 2042
野性不改
野性不改 2020-12-14 11:59

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 b

相关标签:
6条回答
  • 2020-12-14 12:05

    Read all my answer first : it seems that this error is due to another compilation problem...

    Initially, to deal with this error, I updated my code like this:

    <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">
     ...
    </resources>
    

    into this code:

    <resources ignore="MissingTranslation">
         ...
    </resources>
    

    And it works for me at the beginning...but I had another compilation error due tu gradle configuration...and now that these compilation errors are corrected, my previous update does not work anymore. I had to add the namespace to generate the APK file.

    So , be sure to correct all the compilation errors first before to deal with this error...

    0 讨论(0)
  • 2020-12-14 12:08

    In my case i found the following code within the styles.xml

     <item name="android:listSelector">
                    <selector xmlns:android="http://schemas.android.com/apk/res/android">
                        <item android:drawable="@color/pressed_color" android:state_pressed="true" />
                        <item android:drawable="@color/focused_color" android:state_focused="true" />
                        <item android:drawable="@color/item_list_color" />
                    </selector>
                </item>
    

    In selector exists a error

    xmlns:android="http://schemas.android.com/apk/res/android"
    

    I removed the code above and solve my problem

    0 讨论(0)
  • 2020-12-14 12:16

    Had the same issue. Mine was due to Crashlytics. Their automatically generated xml file has invalid name spaces.

    0 讨论(0)
  • 2020-12-14 12:19

    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="http://schemas.android.com/apk/res-auto">
        <item name="android:textSize">14sp</item>
        <item name="android:textColor">@color/content</item>
    </style>
    

    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="http://schemas.android.com/apk/res-auto" fixed it.

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

    0 讨论(0)
  • 2020-12-14 12:29

    I had same problem when i updated Android studio 1.5 to 2.2 version. A quick solution to this is when u open existing project in updated version, just 'ignore' the update gradle plugin/version.

    0 讨论(0)
  • 2020-12-14 12:31

    mine was close to all of this. Someone had declared a name space inside of a strings tag. Something like this:

    <string name="google_play" xmlns:tools="http://schemas.android.com/tools" >Google Play</string>
    

    i obviously removed the ns reference as it should not be there like that. I had to search the entire codebase for the word "xmlns:" and look for one that was in the wrong place. Took a while.

    0 讨论(0)
提交回复
热议问题