ParseError at [row,col]:[66,34] 消息: -xml-names-19990114#AttributeNSNotUnique?按钮&layout_column



我的应用程序出现错误,错误显示

ParseError at [row,col]:[66,34] Message:         http://www.w3.org/TR/1999/REC-xml-names-19990114#AttributeNSNotUnique?        Button&layout_column 

我找不到错误在哪里…我不知道行和列是哪一个…可能在xml文件中?

这是AndroidManifest文件

AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest     xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.***">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="App Name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name="com.example.appname.MainActivity"
android:theme="@style/Theme.AppCompat.NoActionBar"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"    />
</intent-filter>
</activity>
<!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="appname"
android:value="ca-app-pub-2703074771097768~4557375307"/>. 
</application>

我遇到了类似的问题:

ParseError at [row,col]:[8,279]
Message: http://www.w3.org/TR/1999/REC-xml-names-19990114#AttributeNSNotUnique?androidx.constraintlayout.widget.ConstraintLayout&layout_width&http://schemas.android.com/apk/res/android

你需要做什么:

首先仔细阅读错误消息,在我的情况下,错误消息中提到有问题:我最新布局xml文件中的ConstraintLayout&layout_width属性。

在我的例子中,我错误地将layout_heightlayout_width属性添加到了<layout>标记中,这实际上只用于数据绑定。所以,只要去掉这些线,我就能解决这个问题。

我最初拥有的layout

<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

为了解决这个问题,我做了:

<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

正如这里的答案所解释的,您得到的错误被Gradle的更新版本所掩盖。在我的例子中,我也有[row][col]消息,当我将Gradle版本从4.2.2降级到4.1.3并再次编译时,它现在向我显示了真正的错误(我在一个XML中有一个重复的属性(,我能够解决它

如果您像我一样难以找到哪个(xml(布局文件存在导致此ParseError的错误,请尝试单击屏幕底部的"构建",然后单击mergeDebugResources构建任务。它将提供比这个愚蠢的错误更多的信息:-(

我遇到了接缝问题,就像

ParseError at [row,col]:[40,33] Message: http://www.w3.org/TR/1999/REC-xml-names-19990114#AttributePrefixUnbound?TextView&tools:text&tools

很难找到问题出在哪里。

喜欢这个答案在此处输入链接描述

我的问题在一些xml文件TextView&tools:text&tools中,所以我搜索了我所有的项目Ctrl + Shift + F,然后我找到了我的问题。

最新更新