Android数据绑定XML错误 [英] Android Data Binding XML Error

查看:89
本文介绍了Android数据绑定XML错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我构建,运行,清理,重建等等时,我在Android Studio项目上使用数据绑定库时,都会出现以下错误:

I'm using Data Binding Library on a Android Studio Project when whenever I build, run, clean, rebuild, etc I get the following error:

 :app:processDebugResources AGPBI:

{"kind":"error","text":"Error parsing XML: duplicate attribute","sources": [{"file":"C:\\Users\\lucia.beltran\\Desktop\\Picho\\Projects\\Personal\\ improved-tribble\\ImprovedTribble\\app\\build\\intermediates\\data-binding-layout-out\\debug\\ layout\\task_list_item.xml","position":{"startLine":16}}],"original":"","tool":"AAPT"}

C:\Users\lucia.beltran\Desktop\Picho\Projects\Personal\improved-tribble\ImprovedTribble\app\build\intermediates\data-binding-layout-out\debug\layout\task_list_item.xml:17: error: Error parsing XML: duplicate 

 FAILED

FAILURE: Build failed with an exception.

* What went wrong: Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt

* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 3.826 secs

我的布局如下

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

    <data>
        <variable
            name="task"
            type="com.pichardo.improvedtribble.models.Task" />
    </data>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal">

    </LinearLayout>

</layout>

gradle控制台说的绑定文件的布局如下:

And the layout of the binding file that gradle console says is like:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" android:tag="layout/task_list_item_0" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent">

</LinearLayout>

我知道哪些是重复属性,但是我不知道为什么崩溃.

I get which the duplicate attributes are, but I don't know why is crashing.

我阅读了这个问题,但是我没有类似的内容我的build.gradle文件.

I read this question, but I don't have any like that on my build.gradle file.

有什么建议吗?

推荐答案

尝试删除布局中的 android:layout_width android:layout_height ="match_parent" 标签

Try to remove android:layout_width and android:layout_height="match_parent" in layout tag

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

    <data>
        <variable
            name="task"
            type="com.pichardo.improvedtribble.models.Task" />
    </data>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal">

    </LinearLayout>

</layout>

这篇关于Android数据绑定XML错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆