gpt4 book ai didi

Android 数据绑定(bind) XML 错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:22:32 26 4
gpt4 key购买 nike

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

 :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控制台说的绑定(bind)文件的布局是这样的:

<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>

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

我读了this question ,但我的 build.gradle 文件中没有类似的内容。

有什么建议吗?

最佳答案

尝试移除 layout 标签中的 android:layout_widthandroid:layout_height="match_parent"

<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 数据绑定(bind) XML 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39865070/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com