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

Mau*_*ato 7 android android-studio

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

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

我找不到错误在哪里..我不知道哪些是行和列...也许在 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>
Run Code Online (Sandbox Code Playgroud)

Muh*_*fan 22

I had similar issue:

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
Run Code Online (Sandbox Code Playgroud)

What you need to do:

First read the error message carefully, in my case it's mentioned in error message that there is something wrong with: ConstraintLayout&layout_width attribute in my latest layout xml file.

就我而言,我错误地向标签添加了layout_height和属性,这实际上仅用于数据绑定。因此,只需删除这些行,我就能解决这个问题。layout_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">
Run Code Online (Sandbox Code Playgroud)

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

<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
Run Code Online (Sandbox Code Playgroud)


小智 2

正如此处的答案所解释的,您收到的错误被 Gradle 的更新版本所掩盖。就我而言,我还收到了 [row][col] 消息,当我将 Gradle 版本从 4.2.2 降级到 4.1.3 并再次编译时,它现在向我显示了真正的错误(我在一个错误中出现了重复的属性)我的 XML)并且我能够解决它。