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

2023-02-02移动开发问题
78

本文介绍了Android Gradle 合并 Values.xml 使用错误的命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

在将项目转换为 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 使用错误的命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

如何在 COCOS2d Android 中使用 CClistview?
How can I use CClistview in COCOS2d Android?(如何在 COCOS2d Android 中使用 CClistview?)...
2024-08-12 移动开发问题
5

cocos2d-android:如何显示分数
cocos2d-android: how to display score(cocos2d-android:如何显示分数)...
2024-08-11 移动开发问题
7

Sqlite 数据库未从资产文件夹 Android 复制
Sqlite database not copied from asset folder Android(Sqlite 数据库未从资产文件夹 Android 复制)...
2024-04-15 移动开发问题
8

SQLite 数据库副本在由设备而不是模拟器生成时出现损坏
SQLite Database Copy Appears Corrupted When Generated by Device and not Emulator(SQLite 数据库副本在由设备而不是模拟器生成时出现损坏)...
2024-04-15 移动开发问题
4

安卓文件拷贝
Android file copy(安卓文件拷贝)...
2024-04-15 移动开发问题
6

Android如何在android中检测Edittext的Copy事件
Android how to detect Copy event of Edittext in android(Android如何在android中检测Edittext的Copy事件)...
2024-04-15 移动开发问题
5