【问题标题】:Android - The prefix "xmlns" cannot be bound to any namespace explicitly; neither can the namespace for "xmlns" be bound to any prefix explicitlyAndroid - 前缀“xmlns”不能显式绑定到任何命名空间; “xmlns”的命名空间也不能显式绑定到任何前缀
【发布时间】:2015-03-23 21:57:14
【问题描述】:

有人遇到这个“xmlns”命名空间问题吗(见下文)?我不能再构建我的工作项目了。

  • 起初我以为是我的 git 分支,所以我切换到 origin 的开发和主分支 - 问题仍然存在。
  • 我清理并重建了我的项目 - 问题仍然存在。
  • 我清理并同步了成绩文件 - 问题仍然存在。
  • 最后我尝试重新安装 Android Studio 并重新创建我的 git 存储库 - 问题仍然存在。

    The prefix "xmlns" cannot be bound to any namespace explicitly; neither can the namespace for "xmlns" be bound to any prefix explicitly.
    Error: The prefix "xmlns" cannot be bound to any namespace explicitly; neither can the namespace for "xmlns" be bound to any prefix explicitly.
    :{project}:mergeReleaseResources FAILED
    Execution failed for task ':{project}:mergeReleaseResources'.
    > {project}/build/intermediates/incremental/mergeResources/release/merger.xml:1:61: Error: The prefix "xmlns" cannot be bound to any namespace explicitly; neither can the namespace for "xmlns" be bound to any prefix explicitly.
    

注意:问题似乎类似于Android Gradle merged Values.xml uses wrong namespace,但我找不到未使用的命名空间。我进行了检查,但没有找到未使用的命名空间。

【问题讨论】:

标签: android git android-studio gradle xml-namespaces


【解决方案1】:

在我的例子中,删除 com_crashlytics_export_strings.xml 文件修复了这个错误。

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<resources>
<!--
  This file is automatically generated by Crashlytics to uniquely 
  identify individual builds of your Android application.

  Do NOT modify, delete, or commit to source control!
-->
<string xmlns:ns0="http://schemas.android.com/tools" name="com.crashlytics.android.build_id" ns0:ignore="UnusedResources,TypographyDashes" translatable="false">xxxxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</string>
</resources>

【讨论】:

  • 这很有道理...我最近从使用不带fabric.io的crashlytics迁移到带fabric.io的crashlytics。那时它正在工作,但也许有什么东西在分支之间蔓延。
  • 这个文件不是在每次构建时都生成的吗?所以简单地删除文件并不能真正解决问题。
  • 我在我的 build.gradle 中添加了:preBuild &lt;&lt; { delete('src/main/res/values/com_crashlytics_export_strings.xml') } 至少可以自动清除它,尽管我确实同意这个问题应该最终解决。
  • 谢谢@Michael,你拯救了我的一天
【解决方案2】:

您需要从 ma​​in\res\values\style.xml 中删除所有 xmlns:android="http://schemas.android.com/apk/res/android" 文件 style 标记。 您的 style.xml 文件应该是这样的:(确保您的样式标签中没有 xmlns 字段)

<resources xmlns:android="http://schemas.android.com/apk/res/android">
    <style name="AppBaseTheme" parent="android:Theme.Light">
    </style>
    <style name="AppTheme" parent="AppBaseTheme">
    </style>

    <style name="RadioButton" parent="@android:style/Widget.CompoundButton">
        <item name="android:button">@null</item>
        <item name="android:padding">5dp</item>
    </style>

    <style name="EditText" parent="@android:style/Widget.EditText">
        <item name="android:textSize">15sp</item>
    </style>
</resources>

【讨论】:

    【解决方案3】:

    我能够通过“编辑”我的 build.gradle(删除空格等)和 THEN 清理我的构建来清除此错误。在没有先编辑 gradle 构建文件的情况下,Android Studio 不会接受更改。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-29
      • 1970-01-01
      • 2013-05-06
      • 2013-02-01
      • 2013-06-01
      相关资源
      最近更新 更多