在将项目转换为 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模板网!
更新到 Android Build Tools 25.1.6 GCM/FCM 后出现 IncompIncompatibleClassChangeError after updating to Android Build Tools 25.1.6 GCM / FCM(更新到 Android Build Tools 25.1.6 GCM/FCM 后出现 Incompatible
如何在 gradle 中获取当前风味How to get current flavor in gradle(如何在 gradle 中获取当前风味)
如何修复“意外元素<查询>在“清单How to fix quot;unexpected element lt;queriesgt; found in lt;manifestgt;quot; error?(如何修复“意外元素lt;查询gt;在“清单中找到错误
基于 Android Gradle 中多风味库的多风味应用Multi flavor app based on multi flavor library in Android Gradle(基于 Android Gradle 中多风味库的多风味应用)
Android 依赖在编译和运行时有不同的版本Android dependency has different version for the compile and runtime(Android 依赖在编译和运行时有不同的版本)
本地 aar 库的传递依赖Transitive dependencies for local aar library(本地 aar 库的传递依赖)