无法解析XML -Kotlin

发布于 2025-01-21 22:25:22 字数 1248 浏览 4 评论 0原文

Caused by: 
org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A
failure occurred while executing com.android.build.gradle.internal.res.ParseLibraryResourcesTask$ParseResourcesRunnable

其他错误代码

FAILURE: Build completed with 2 failures.

1:任务失败,异常。

  • 出了什么问题: 任务执行失败':APP:PARSEDEBUGLOCALRESOURCES'。

执行com.android.build.gradle.internal.res.res.parselebraryraryresourcestask $ parseresourcesrunnable时发生故障 无法解析XML文件'/home/shinto/documents/postmethodtrialchecking/helpintern/helpintern/app/build/build/build/intermediates/packaged_res_res/debug/debug/layout/layout/fragment_signup.xignup.xml'

'

<data>
    <variable
        name="users"
        type="com.shinto.helpintern.MainViewModel" />
</data>
android:visibilities="@{users.}"
<androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/progBar"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

enter image description here

Caused by: 
org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A
failure occurred while executing com.android.build.gradle.internal.res.ParseLibraryResourcesTask$ParseResourcesRunnable

Other error codes

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.

  • What went wrong:
    Execution failed for task ':app:parseDebugLocalResources'.

A failure occurred while executing com.android.build.gradle.internal.res.ParseLibraryResourcesTask$ParseResourcesRunnable
Failed to parse XML file '/home/shinto/Documents/PostMethodTrialChecking/HelpIntern/app/build/intermediates/packaged_res/debug/layout/fragment_signup.xml'

fragment_signup.xml

<data>
    <variable
        name="users"
        type="com.shinto.helpintern.MainViewModel" />
</data>
android:visibilities="@{users.}"
<androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/progBar"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟织青萝梦 2025-01-28 22:25:22

您的XML代码是错误的。正如错误所暗示的那样,编译器期望&lt;表示开放标签。为什么?

因为这线
android:visibilities =“@{用户。}”放错了位置,并且不在任何标签中。即使处于正确的位置,它也无法使用,因为没有什么叫做可见性,它是可见性

我假设您想根据数据的任何(假设布尔值)值切换containtlayout的可见性。为此,将您的代码更改为:

<data>
    <import type="android.view.View"/>
    <variable
        name="users"
        type="com.shinto.helpintern.MainViewModel" />
</data>

<androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/progBar"
    android:visibility="@{users.yourValue? View.GONE : View.VISIBLE}"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

这将根据模型的值切换布局的可见性。

Your XML code is wrong. And as the error suggests, compiler expects a <, means an opening tag. Why?

Because this line
android:visibilities="@{users.}" is misplaced and isn't in any tag. Even if it was in its correct position, it wouldn't work, because there's nothing called visibilities, it's visibility.

I assume you want to toggle the visibility of the ContraintLayout based on any (assuming boolean) value of the data. To do that, change your code as:

<data>
    <import type="android.view.View"/>
    <variable
        name="users"
        type="com.shinto.helpintern.MainViewModel" />
</data>

<androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/progBar"
    android:visibility="@{users.yourValue? View.GONE : View.VISIBLE}"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

This will toggle the layout's visibility based on the value of your model.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文